Skip to content

Commit 2972184

Browse files
authored
🎨 [Frontend] UX: Organization member's management (#6676)
1 parent a515c12 commit 2972184

File tree

14 files changed

+110
-54
lines changed

14 files changed

+110
-54
lines changed

services/static-webserver/client/source/class/osparc/data/Roles.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ qx.Class.define("osparc.data.Roles", {
2424
0: {
2525
id: "noRead",
2626
label: qx.locale.Manager.tr("Restricted Member"),
27-
longLabel: qx.locale.Manager.tr("Restricted user: no Read access"),
27+
longLabel: qx.locale.Manager.tr("Restricted member: no Read access"),
2828
canDo: [
2929
qx.locale.Manager.tr("- can access content shared within the Organization")
3030
]
3131
},
3232
1: {
3333
id: "read",
3434
label: qx.locale.Manager.tr("Member"),
35-
longLabel: qx.locale.Manager.tr("User: Read access"),
35+
longLabel: qx.locale.Manager.tr("Member: Read access"),
3636
canDo: [
37-
qx.locale.Manager.tr("- can see other users"),
38-
qx.locale.Manager.tr("- can share with other users")
37+
qx.locale.Manager.tr("- can see other members"),
38+
qx.locale.Manager.tr("- can share with other members")
3939
]
4040
},
4141
2: {

services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
7979

8080
members: {
8181
__currentOrg: null,
82+
__introLabel: null,
8283
__memberInvitation: null,
8384
__membersModel: null,
8485

@@ -91,9 +92,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
9192
},
9293

9394
__createIntroText: function() {
94-
const msg = this.tr("If you are a manager or administrator, you can add new members and promote or demote existing ones.");
95-
const intro = new qx.ui.basic.Label().set({
96-
value: msg,
95+
const intro = this.__introLabel = new qx.ui.basic.Label().set({
9796
alignX: "left",
9897
rich: true,
9998
font: "text-13"
@@ -105,7 +104,6 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
105104
const hBox = this.__memberInvitation = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({
106105
alignY: "middle"
107106
}));
108-
hBox.exclude();
109107

110108
const userEmail = new qx.ui.form.TextField().set({
111109
required: true,
@@ -217,8 +215,14 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
217215

218216
const canIWrite = orgModel.getAccessRights().getWrite();
219217
const canIDelete = orgModel.getAccessRights().getDelete();
218+
219+
const introText = canIWrite ?
220+
this.tr("You can add new members and promote or demote existing ones.") :
221+
this.tr("You can't add new members to this Organization. Please contact an Administrator or Manager.");
222+
this.__introLabel.setValue(introText);
223+
220224
this.__memberInvitation.set({
221-
visibility: canIWrite ? "visible" : "excluded"
225+
enabled: canIWrite
222226
});
223227

224228
const params = {

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationDetails", {
5353
orgModel.bind("thumbnail", organizationListItem, "thumbnail");
5454
orgModel.bind("label", organizationListItem, "title");
5555
orgModel.bind("description", organizationListItem, "subtitle");
56-
orgModel.bind("nMembers", organizationListItem, "contact");
56+
orgModel.bind("nMembers", organizationListItem, "role");
5757
orgModel.bind("accessRights", organizationListItem, "accessRights");
5858

5959
// set orgModel to the tab views

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
139139
ctrl.bindProperty("thumbnail", "thumbnail", null, item, id);
140140
ctrl.bindProperty("label", "title", null, item, id);
141141
ctrl.bindProperty("description", "subtitle", null, item, id);
142-
ctrl.bindProperty("nMembers", "contact", null, item, id);
142+
ctrl.bindProperty("nMembers", "role", null, item, id);
143143
ctrl.bindProperty("accessRights", "accessRights", null, item, id);
144144
},
145145
configureItem: item => {

services/static-webserver/client/source/class/osparc/desktop/organizations/ServicesList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ qx.Class.define("osparc.desktop.organizations.ServicesList", {
7070
const servicesModel = this.__servicesModel = new qx.data.Array();
7171
const servicesCtrl = new qx.data.controller.List(servicesModel, servicesUIList, "name");
7272
servicesCtrl.setDelegate({
73-
createItem: () => new osparc.desktop.organizations.SharedResourceListItem(),
73+
createItem: () => new osparc.desktop.organizations.SharedResourceListItem("service"),
7474
bindItem: (ctrl, item, id) => {
7575
ctrl.bindProperty("key", "model", null, item, id);
7676
ctrl.bindProperty("key", "key", null, item, id);

services/static-webserver/client/source/class/osparc/desktop/organizations/SharedResourceListItem.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
qx.Class.define("osparc.desktop.organizations.SharedResourceListItem", {
1919
extend: osparc.ui.list.ListItemWithMenu,
2020

21+
construct: function(resourceType) {
22+
this.__resourceType = resourceType;
23+
24+
this.base(arguments);
25+
},
26+
2127
properties: {
2228
orgId: {
2329
check: "Integer",
@@ -38,7 +44,28 @@ qx.Class.define("osparc.desktop.organizations.SharedResourceListItem", {
3844
"openMoreInfo": "qx.event.type.Data"
3945
},
4046

47+
statics: {
48+
canDelete: function(accessRights) {
49+
const canDelete = accessRights.getDelete ? accessRights.getDelete() : false;
50+
return canDelete;
51+
},
52+
53+
canWrite: function(accessRights) {
54+
let canWrite = accessRights.getWrite ? accessRights.getWrite() : false;
55+
canWrite = canWrite || (accessRights.getWriteAccess ? accessRights.getWriteAccess() : false);
56+
return canWrite;
57+
},
58+
59+
canRead: function(accessRights) {
60+
let canRead = accessRights.getRead ? accessRights.getRead() : false;
61+
canRead = canRead || (accessRights.getExecuteAccess ? accessRights.getExecuteAccess() : false);
62+
return canRead;
63+
}
64+
},
65+
4166
members: {
67+
__resourceType: null,
68+
4269
_createChildControlImpl: function(id) {
4370
let control;
4471
switch (id) {
@@ -63,6 +90,26 @@ qx.Class.define("osparc.desktop.organizations.SharedResourceListItem", {
6390
return control || this.base(arguments, id);
6491
},
6592

93+
__getRoleInfo: function(i) {
94+
if (this.__resourceType === "service") {
95+
return osparc.data.Roles.SERVICES[i];
96+
}
97+
return osparc.data.Roles.STUDY[i];
98+
},
99+
100+
// overridden
101+
_setRole: function() {
102+
const accessRights = this.getAccessRights();
103+
const role = this.getChildControl("role");
104+
if (this.self().canDelete(accessRights)) {
105+
role.setValue(this.__getRoleInfo(3).label);
106+
} else if (this.self().canWrite(accessRights)) {
107+
role.setValue(this.__getRoleInfo(2).label);
108+
} else {
109+
role.setValue(this.__getRoleInfo(1).label);
110+
}
111+
},
112+
66113
// overridden
67114
_getInfoButton: function() {
68115
const accessRights = this.getAccessRights();

services/static-webserver/client/source/class/osparc/desktop/organizations/TemplatesList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ qx.Class.define("osparc.desktop.organizations.TemplatesList", {
7070
const templatesModel = this.__templatesModel = new qx.data.Array();
7171
const templatesCtrl = new qx.data.controller.List(templatesModel, templatesUIList, "name");
7272
templatesCtrl.setDelegate({
73-
createItem: () => new osparc.desktop.organizations.SharedResourceListItem(),
73+
createItem: () => new osparc.desktop.organizations.SharedResourceListItem("template"),
7474
bindItem: (ctrl, item, id) => {
7575
ctrl.bindProperty("uuid", "model", null, item, id);
7676
ctrl.bindProperty("uuid", "key", null, item, id);

services/static-webserver/client/source/class/osparc/desktop/wallets/MemberListItem.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ qx.Class.define("osparc.desktop.wallets.MemberListItem", {
4646
},
4747

4848
// overridden
49-
_setSubtitle: function() {
49+
_setRole: function() {
5050
const accessRights = this.getAccessRights();
51-
const subtitle = this.getChildControl("contact");
51+
const role = this.getChildControl("role");
5252
if ("getWrite" in accessRights && accessRights.getWrite()) {
53-
subtitle.setValue(osparc.data.Roles.WALLET[2].label);
53+
role.setValue(osparc.data.Roles.WALLET[2].label);
5454
} else if ("getRead" in accessRights && accessRights.getRead()) {
55-
subtitle.setValue(osparc.data.Roles.WALLET[1].label);
55+
role.setValue(osparc.data.Roles.WALLET[1].label);
5656
}
5757
},
5858

services/static-webserver/client/source/class/osparc/desktop/wallets/WalletListItem.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,16 @@ qx.Class.define("osparc.desktop.wallets.WalletListItem", {
272272
},
273273

274274
// overridden
275-
_setSubtitle: function() {
275+
_setRole: function() {
276276
const accessRightss = this.getAccessRights();
277277
const myGid = osparc.auth.Data.getInstance().getGroupId();
278278
const found = accessRightss && accessRightss.find(ar => ar["gid"] === myGid);
279279
if (found) {
280-
const subtitle = this.getChildControl("contact");
280+
const role = this.getChildControl("role");
281281
if (found["write"]) {
282-
subtitle.setValue(osparc.data.Roles.WALLET[2].label);
282+
role.setValue(osparc.data.Roles.WALLET[2].label);
283283
} else if (found["read"]) {
284-
subtitle.setValue(osparc.data.Roles.WALLET[1].label);
284+
role.setValue(osparc.data.Roles.WALLET[1].label);
285285
}
286286
}
287287
},

services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
qx.Class.define("osparc.ui.list.CollaboratorListItem", {
1919
extend: osparc.ui.list.ListItem,
2020

21-
construct: function() {
22-
this.base(arguments);
23-
},
24-
2521
properties: {
2622
collabType: {
2723
check: [0, 1, 2], // 0:all, 1:org, 2:user
@@ -42,6 +38,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
4238
event: "changeShowOptions",
4339
nullable: true
4440
},
41+
4542
resourceType : {
4643
check: "String",
4744
event: "changeResourceType",
@@ -77,7 +74,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
7774
},
7875

7976
members: {
80-
_getResource: function(i) {
77+
__getRoleInfo: function(i) {
8178
const resource = this.getResourceType();
8279
if (resource === "study" || resource === "template") {
8380
return osparc.data.Roles.STUDY[i];
@@ -149,22 +146,22 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
149146
return;
150147
}
151148

152-
this.__setSubtitle();
149+
this.__setRole();
153150

154151
const menu = this.__getOptionsMenu();
155152
const optionsMenu = this.getChildControl("options");
156153
optionsMenu.setMenu(menu);
157154
},
158155

159-
__setSubtitle: function() {
156+
__setRole: function() {
160157
const accessRights = this.getAccessRights();
161-
const subtitle = this.getChildControl("contact");
158+
const role = this.getChildControl("role");
162159
if (this.self().canDelete(accessRights)) {
163-
subtitle.setValue(this._getResource(3).label);
160+
role.setValue(this.__getRoleInfo(3).label);
164161
} else if (this.self().canWrite(accessRights)) {
165-
subtitle.setValue(this._getResource(2).label);
162+
role.setValue(this.__getRoleInfo(2).label);
166163
} else {
167-
subtitle.setValue(this._getResource(1).label);
164+
role.setValue(this.__getRoleInfo(1).label);
168165
}
169166
},
170167

@@ -174,17 +171,17 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
174171
});
175172

176173
const accessRights = this.getAccessRights();
177-
let currentRole = this._getResource(1);
174+
let currentRole = this.__getRoleInfo(1);
178175
if (this.self().canDelete(accessRights)) {
179-
currentRole = this._getResource(3);
176+
currentRole = this.__getRoleInfo(3);
180177
} else if (this.self().canWrite(accessRights)) {
181-
currentRole = this._getResource(2);
178+
currentRole = this.__getRoleInfo(2);
182179
}
183180

184181
// promote/demote actions
185182
switch (currentRole.id) {
186183
case "read": {
187-
const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this._getResource(2).label}`));
184+
const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this.__getRoleInfo(2).label}`));
188185
promoteButton.addListener("execute", () => {
189186
this.fireDataEvent("promoteToEditor", {
190187
gid: this.getKey(),
@@ -196,7 +193,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
196193
}
197194
case "write": {
198195
const resource = this.getResourceType();
199-
const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this._getResource(3).label}`));
196+
const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this.__getRoleInfo(3).label}`));
200197
promoteButton.setVisibility(resource === "service" ? "excluded" : "visible");
201198
promoteButton.addListener("execute", () => {
202199
this.fireDataEvent("promoteToOwner", {
@@ -205,7 +202,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
205202
});
206203
});
207204
menu.add(promoteButton);
208-
const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this._getResource(1).label}`));
205+
const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this.__getRoleInfo(1).label}`));
209206
demoteButton.addListener("execute", () => {
210207
this.fireDataEvent("demoteToUser", {
211208
gid: this.getKey(),
@@ -216,7 +213,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
216213
break;
217214
}
218215
case "delete": {
219-
const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this._getResource(2).label}`));
216+
const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this.__getRoleInfo(2).label}`));
220217
demoteButton.addListener("execute", () => {
221218
this.fireDataEvent("demoteToEditor", {
222219
gid: this.getKey(),

0 commit comments

Comments
 (0)