Merge pull request #1609 from xtuple/4_5_x
[xtuple] / enyo-client / extensions / source / oauth2 / client / views / workspace.js
1 /*jshint indent:2, curly:true, eqeqeq:true, immed:true, latedef:true,
2 newcap:true, noarg:true, regexp:true, undef:true, trailing:true,
3 white:true*/
4 /*global XT:true, XV:true, Backbone:true, enyo:true, console:true */
5
6 (function () {
7
8   XT.extensions.oauth2.initWorkspace = function () {
9     enyo.kind({
10       name: "XV.Oauth2clientWorkspace",
11       kind: "XV.Workspace",
12       title: "_oauth2Client".loc(),
13       model: "XM.Oauth2client",
14       components: [
15         {kind: "Panels", arrangerKind: "CarouselArranger",
16           fit: true, components: [
17           {kind: "XV.Groupbox", name: "mainPanel", components: [
18             {kind: "onyx.GroupboxHeader", content: "_overview".loc()},
19             {kind: "XV.ScrollableGroupbox", name: "mainGroup", fit: true,
20                 classes: "in-panel", components: [
21               {kind: "onyx.GroupboxHeader", content: "_id".loc()},
22               {kind: "XV.TextArea", attr: "clientID", classes: "xv-short-textarea" },
23               {kind: "onyx.GroupboxHeader", content: "_secret".loc()},
24               {kind: "XV.TextArea", attr: "clientSecret", classes: "xv-short-textarea" },
25               {kind: "onyx.GroupboxHeader", content: "_details".loc()},
26               {kind: "XV.InputWidget", attr: "clientName", label: "_name".loc()},
27               {kind: "XV.InputWidget", attr: "clientEmail", label: "_email".loc()},
28               {kind: "XV.InputWidget", attr: "clientWebSite", label: "_website".loc()},
29               {kind: "XV.InputWidget", attr: "clientLogo", label: "_logoURL".loc()},
30               {kind: "XV.Oauth2clientTypePicker", attr: "clientType"},
31               {kind: "XV.CheckboxWidget", attr: "isActive"},
32               {kind: "XV.DateWidget", attr: "issued"},
33               {kind: "XV.InputWidget", attr: "organization"},
34               {kind: "XV.CheckboxWidget", name: "delegatedAccess", attr: "delegatedAccess"},
35               {kind: "XV.InputWidget", name: "clientX509PubCert", attr: "clientX509PubCert", label: "_x509PubCert".loc()},
36               {kind: "onyx.GroupboxHeader", content: "_fullListUrl".loc()},
37               {kind: "XV.TextArea", name: "fullListUrl", classes: "xv-short-textarea", disabled: true},
38               {kind: "onyx.GroupboxHeader", content: "_singleResourceUrl".loc()},
39               {kind: "XV.TextArea", name: "singleResourceUrl", classes: "xv-short-textarea", disabled: true},
40               {kind: "onyx.GroupboxHeader", content: "_authURI".loc()},
41               {kind: "XV.TextArea", name: "authURI", classes: "xv-short-textarea", disabled: true},
42               {kind: "onyx.GroupboxHeader", content: "_tokenURI".loc()},
43               {kind: "XV.TextArea", name: "tokenURI", classes: "xv-short-textarea", disabled: true},
44               {kind: "onyx.GroupboxHeader", content: "_tokenRevocationURI".loc()},
45               {kind: "XV.TextArea", name: "tokenRevocationURI", classes: "xv-short-textarea", disabled: true}
46             ]}
47           ]},
48           {kind: "XV.Oauth2clientRedirectBox", name: "redirectBox", attr: "redirectURIs" }
49         ]}
50       ],
51       create: function () {
52         var base = XT.getBaseUrl() + XT.getOrganizationPath();
53         this.inherited(arguments);
54
55         this.$.fullListUrl.setValue(base + "/discovery/v1alpha1/apis/v1alpha1/rest");
56         this.$.singleResourceUrl.setValue(base + "/discovery/v1alpha1/apis/:model/v1alpha1/rest");
57         this.$.authURI.setValue(base + "/dialog/authorize");
58         this.$.tokenURI.setValue(base + "/oauth/token");
59         this.$.tokenRevocationURI.setValue(base + "/oauth/revoke-token");
60       },
61       attributesChanged: function (model, options) {
62         this.inherited(arguments);
63
64         this.$.delegatedAccess.setShowing(model.get("clientType") === 'jwt bearer');
65         this.$.clientX509PubCert.setShowing(model.get("clientType") === 'jwt bearer');
66         // Enyo messes this one up for some reason, so use CSS
67         if (model.get("clientType") === 'web server') {
68           this.$.redirectBox.applyStyle("visibility", "showing");
69         } else {
70           this.$.redirectBox.applyStyle("visibility", "hidden");
71         }
72
73       }
74     });
75
76     XV.registerModelWorkspace("XM.Oauth2client", "XV.Oauth2clientWorkspace");
77   };
78 }());