diff --git a/services/static-webserver/client/source/class/osparc/data/Roles.js b/services/static-webserver/client/source/class/osparc/data/Roles.js index 6320c5a7003..b3a87e6c1c4 100644 --- a/services/static-webserver/client/source/class/osparc/data/Roles.js +++ b/services/static-webserver/client/source/class/osparc/data/Roles.js @@ -24,7 +24,7 @@ qx.Class.define("osparc.data.Roles", { 0: { id: "noRead", label: qx.locale.Manager.tr("Restricted Member"), - longLabel: qx.locale.Manager.tr("Restricted user: no Read access"), + longLabel: qx.locale.Manager.tr("Restricted member: no Read access"), canDo: [ qx.locale.Manager.tr("- can access content shared within the Organization") ] @@ -32,10 +32,10 @@ qx.Class.define("osparc.data.Roles", { 1: { id: "read", label: qx.locale.Manager.tr("Member"), - longLabel: qx.locale.Manager.tr("User: Read access"), + longLabel: qx.locale.Manager.tr("Member: Read access"), canDo: [ - qx.locale.Manager.tr("- can see other users"), - qx.locale.Manager.tr("- can share with other users") + qx.locale.Manager.tr("- can see other members"), + qx.locale.Manager.tr("- can share with other members") ] }, 2: { diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js index 2d065ba1dba..019f40683f0 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js @@ -79,6 +79,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", { members: { __currentOrg: null, + __introLabel: null, __memberInvitation: null, __membersModel: null, @@ -91,9 +92,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", { }, __createIntroText: function() { - const msg = this.tr("If you are a manager or administrator, you can add new members and promote or demote existing ones."); - const intro = new qx.ui.basic.Label().set({ - value: msg, + const intro = this.__introLabel = new qx.ui.basic.Label().set({ alignX: "left", rich: true, font: "text-13" @@ -105,7 +104,6 @@ qx.Class.define("osparc.desktop.organizations.MembersList", { const hBox = this.__memberInvitation = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ alignY: "middle" })); - hBox.exclude(); const userEmail = new qx.ui.form.TextField().set({ required: true, @@ -217,8 +215,14 @@ qx.Class.define("osparc.desktop.organizations.MembersList", { const canIWrite = orgModel.getAccessRights().getWrite(); const canIDelete = orgModel.getAccessRights().getDelete(); + + const introText = canIWrite ? + this.tr("You can add new members and promote or demote existing ones.") : + this.tr("You can't add new members to this Organization. Please contact an Administrator or Manager."); + this.__introLabel.setValue(introText); + this.__memberInvitation.set({ - visibility: canIWrite ? "visible" : "excluded" + enabled: canIWrite }); const params = { diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js index 83310caa341..6871348d8a0 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js @@ -53,7 +53,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationDetails", { orgModel.bind("thumbnail", organizationListItem, "thumbnail"); orgModel.bind("label", organizationListItem, "title"); orgModel.bind("description", organizationListItem, "subtitle"); - orgModel.bind("nMembers", organizationListItem, "contact"); + orgModel.bind("nMembers", organizationListItem, "role"); orgModel.bind("accessRights", organizationListItem, "accessRights"); // set orgModel to the tab views diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js index 0271fb71dcc..0e205f5d5ad 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js @@ -139,7 +139,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", { ctrl.bindProperty("thumbnail", "thumbnail", null, item, id); ctrl.bindProperty("label", "title", null, item, id); ctrl.bindProperty("description", "subtitle", null, item, id); - ctrl.bindProperty("nMembers", "contact", null, item, id); + ctrl.bindProperty("nMembers", "role", null, item, id); ctrl.bindProperty("accessRights", "accessRights", null, item, id); }, configureItem: item => { diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/ServicesList.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/ServicesList.js index 9d2d7a6fa1e..bf4f6a95c60 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/ServicesList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/ServicesList.js @@ -70,7 +70,7 @@ qx.Class.define("osparc.desktop.organizations.ServicesList", { const servicesModel = this.__servicesModel = new qx.data.Array(); const servicesCtrl = new qx.data.controller.List(servicesModel, servicesUIList, "name"); servicesCtrl.setDelegate({ - createItem: () => new osparc.desktop.organizations.SharedResourceListItem(), + createItem: () => new osparc.desktop.organizations.SharedResourceListItem("service"), bindItem: (ctrl, item, id) => { ctrl.bindProperty("key", "model", null, item, id); ctrl.bindProperty("key", "key", null, item, id); diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/SharedResourceListItem.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/SharedResourceListItem.js index 4ebe846938c..c9f7d262c32 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/SharedResourceListItem.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/SharedResourceListItem.js @@ -18,6 +18,12 @@ qx.Class.define("osparc.desktop.organizations.SharedResourceListItem", { extend: osparc.ui.list.ListItemWithMenu, + construct: function(resourceType) { + this.__resourceType = resourceType; + + this.base(arguments); + }, + properties: { orgId: { check: "Integer", @@ -38,7 +44,28 @@ qx.Class.define("osparc.desktop.organizations.SharedResourceListItem", { "openMoreInfo": "qx.event.type.Data" }, + statics: { + canDelete: function(accessRights) { + const canDelete = accessRights.getDelete ? accessRights.getDelete() : false; + return canDelete; + }, + + canWrite: function(accessRights) { + let canWrite = accessRights.getWrite ? accessRights.getWrite() : false; + canWrite = canWrite || (accessRights.getWriteAccess ? accessRights.getWriteAccess() : false); + return canWrite; + }, + + canRead: function(accessRights) { + let canRead = accessRights.getRead ? accessRights.getRead() : false; + canRead = canRead || (accessRights.getExecuteAccess ? accessRights.getExecuteAccess() : false); + return canRead; + } + }, + members: { + __resourceType: null, + _createChildControlImpl: function(id) { let control; switch (id) { @@ -63,6 +90,26 @@ qx.Class.define("osparc.desktop.organizations.SharedResourceListItem", { return control || this.base(arguments, id); }, + __getRoleInfo: function(i) { + if (this.__resourceType === "service") { + return osparc.data.Roles.SERVICES[i]; + } + return osparc.data.Roles.STUDY[i]; + }, + + // overridden + _setRole: function() { + const accessRights = this.getAccessRights(); + const role = this.getChildControl("role"); + if (this.self().canDelete(accessRights)) { + role.setValue(this.__getRoleInfo(3).label); + } else if (this.self().canWrite(accessRights)) { + role.setValue(this.__getRoleInfo(2).label); + } else { + role.setValue(this.__getRoleInfo(1).label); + } + }, + // overridden _getInfoButton: function() { const accessRights = this.getAccessRights(); diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/TemplatesList.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/TemplatesList.js index c9e54803c00..70dee6617fc 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/TemplatesList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/TemplatesList.js @@ -70,7 +70,7 @@ qx.Class.define("osparc.desktop.organizations.TemplatesList", { const templatesModel = this.__templatesModel = new qx.data.Array(); const templatesCtrl = new qx.data.controller.List(templatesModel, templatesUIList, "name"); templatesCtrl.setDelegate({ - createItem: () => new osparc.desktop.organizations.SharedResourceListItem(), + createItem: () => new osparc.desktop.organizations.SharedResourceListItem("template"), bindItem: (ctrl, item, id) => { ctrl.bindProperty("uuid", "model", null, item, id); ctrl.bindProperty("uuid", "key", null, item, id); diff --git a/services/static-webserver/client/source/class/osparc/desktop/wallets/MemberListItem.js b/services/static-webserver/client/source/class/osparc/desktop/wallets/MemberListItem.js index 23dc08b7ff9..963126fe3f8 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/wallets/MemberListItem.js +++ b/services/static-webserver/client/source/class/osparc/desktop/wallets/MemberListItem.js @@ -46,13 +46,13 @@ qx.Class.define("osparc.desktop.wallets.MemberListItem", { }, // overridden - _setSubtitle: function() { + _setRole: function() { const accessRights = this.getAccessRights(); - const subtitle = this.getChildControl("contact"); + const role = this.getChildControl("role"); if ("getWrite" in accessRights && accessRights.getWrite()) { - subtitle.setValue(osparc.data.Roles.WALLET[2].label); + role.setValue(osparc.data.Roles.WALLET[2].label); } else if ("getRead" in accessRights && accessRights.getRead()) { - subtitle.setValue(osparc.data.Roles.WALLET[1].label); + role.setValue(osparc.data.Roles.WALLET[1].label); } }, diff --git a/services/static-webserver/client/source/class/osparc/desktop/wallets/WalletListItem.js b/services/static-webserver/client/source/class/osparc/desktop/wallets/WalletListItem.js index 3387638b3de..3e3f0e34e4e 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/wallets/WalletListItem.js +++ b/services/static-webserver/client/source/class/osparc/desktop/wallets/WalletListItem.js @@ -272,16 +272,16 @@ qx.Class.define("osparc.desktop.wallets.WalletListItem", { }, // overridden - _setSubtitle: function() { + _setRole: function() { const accessRightss = this.getAccessRights(); const myGid = osparc.auth.Data.getInstance().getGroupId(); const found = accessRightss && accessRightss.find(ar => ar["gid"] === myGid); if (found) { - const subtitle = this.getChildControl("contact"); + const role = this.getChildControl("role"); if (found["write"]) { - subtitle.setValue(osparc.data.Roles.WALLET[2].label); + role.setValue(osparc.data.Roles.WALLET[2].label); } else if (found["read"]) { - subtitle.setValue(osparc.data.Roles.WALLET[1].label); + role.setValue(osparc.data.Roles.WALLET[1].label); } } }, diff --git a/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js b/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js index 6dd098e5bb3..eb881568b38 100644 --- a/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js +++ b/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js @@ -18,10 +18,6 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { extend: osparc.ui.list.ListItem, - construct: function() { - this.base(arguments); - }, - properties: { collabType: { check: [0, 1, 2], // 0:all, 1:org, 2:user @@ -42,6 +38,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { event: "changeShowOptions", nullable: true }, + resourceType : { check: "String", event: "changeResourceType", @@ -77,7 +74,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { }, members: { - _getResource: function(i) { + __getRoleInfo: function(i) { const resource = this.getResourceType(); if (resource === "study" || resource === "template") { return osparc.data.Roles.STUDY[i]; @@ -149,22 +146,22 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { return; } - this.__setSubtitle(); + this.__setRole(); const menu = this.__getOptionsMenu(); const optionsMenu = this.getChildControl("options"); optionsMenu.setMenu(menu); }, - __setSubtitle: function() { + __setRole: function() { const accessRights = this.getAccessRights(); - const subtitle = this.getChildControl("contact"); + const role = this.getChildControl("role"); if (this.self().canDelete(accessRights)) { - subtitle.setValue(this._getResource(3).label); + role.setValue(this.__getRoleInfo(3).label); } else if (this.self().canWrite(accessRights)) { - subtitle.setValue(this._getResource(2).label); + role.setValue(this.__getRoleInfo(2).label); } else { - subtitle.setValue(this._getResource(1).label); + role.setValue(this.__getRoleInfo(1).label); } }, @@ -174,17 +171,17 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { }); const accessRights = this.getAccessRights(); - let currentRole = this._getResource(1); + let currentRole = this.__getRoleInfo(1); if (this.self().canDelete(accessRights)) { - currentRole = this._getResource(3); + currentRole = this.__getRoleInfo(3); } else if (this.self().canWrite(accessRights)) { - currentRole = this._getResource(2); + currentRole = this.__getRoleInfo(2); } // promote/demote actions switch (currentRole.id) { case "read": { - const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this._getResource(2).label}`)); + const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this.__getRoleInfo(2).label}`)); promoteButton.addListener("execute", () => { this.fireDataEvent("promoteToEditor", { gid: this.getKey(), @@ -196,7 +193,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { } case "write": { const resource = this.getResourceType(); - const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this._getResource(3).label}`)); + const promoteButton = new qx.ui.menu.Button(this.tr(`Promote to ${this.__getRoleInfo(3).label}`)); promoteButton.setVisibility(resource === "service" ? "excluded" : "visible"); promoteButton.addListener("execute", () => { this.fireDataEvent("promoteToOwner", { @@ -205,7 +202,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { }); }); menu.add(promoteButton); - const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this._getResource(1).label}`)); + const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this.__getRoleInfo(1).label}`)); demoteButton.addListener("execute", () => { this.fireDataEvent("demoteToUser", { gid: this.getKey(), @@ -216,7 +213,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { break; } case "delete": { - const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this._getResource(2).label}`)); + const demoteButton = new qx.ui.menu.Button(this.tr(`Demote to ${this.__getRoleInfo(2).label}`)); demoteButton.addListener("execute", () => { this.fireDataEvent("demoteToEditor", { gid: this.getKey(), diff --git a/services/static-webserver/client/source/class/osparc/ui/list/ListItem.js b/services/static-webserver/client/source/class/osparc/ui/list/ListItem.js index 70031dc0f9a..e046f420805 100644 --- a/services/static-webserver/client/source/class/osparc/ui/list/ListItem.js +++ b/services/static-webserver/client/source/class/osparc/ui/list/ListItem.js @@ -34,7 +34,7 @@ * c.bindProperty("thumbnail", "thumbnail", null, item, id); * c.bindProperty("name", "title", null, item, id); * c.bindProperty("description", "subtitle", null, item, id); - * c.bindProperty("contact", "contact", null, item, id); + * c.bindProperty("role", "role", null, item, id); * } * }); * @@ -98,9 +98,9 @@ qx.Class.define("osparc.ui.list.ListItem", { nullable : true }, - contact: { + role: { check : "String", - apply : "__applyContact", + apply : "__applyRole", nullable : true } }, @@ -180,7 +180,7 @@ qx.Class.define("osparc.ui.list.ListItem", { column: 1 }); break; - case "contact": + case "role": control = new qx.ui.basic.Label().set({ font: "text-13", alignY: "middle" @@ -244,11 +244,11 @@ qx.Class.define("osparc.ui.list.ListItem", { label.setValue(value); }, - __applyContact: function(value) { + __applyRole: function(value) { if (value === null) { return; } - const label = this.getChildControl("contact"); + const label = this.getChildControl("role"); label.setValue(value); }, diff --git a/services/static-webserver/client/source/class/osparc/ui/list/ListItemWithMenu.js b/services/static-webserver/client/source/class/osparc/ui/list/ListItemWithMenu.js index 22e65916d08..4d9d1d054bb 100644 --- a/services/static-webserver/client/source/class/osparc/ui/list/ListItemWithMenu.js +++ b/services/static-webserver/client/source/class/osparc/ui/list/ListItemWithMenu.js @@ -80,27 +80,29 @@ qx.Class.define("osparc.ui.list.ListItemWithMenu", { return; } + this._setRole(); + this._getInfoButton(); this.__applyOptions(); }, - _setSubtitle: function() { + _setRole: function() { const accessRights = this.getAccessRights(); - const subtitle = this.getChildControl("contact"); + const role = this.getChildControl("role"); if ( "getDelete" in accessRights && accessRights.getDelete() ) { - subtitle.setValue(osparc.data.Roles.ORG[3].label); + role.setValue(osparc.data.Roles.ORG[3].label); } else if ("getWrite" in accessRights && accessRights.getWrite()) { - subtitle.setValue(osparc.data.Roles.ORG[2].label); + role.setValue(osparc.data.Roles.ORG[2].label); } else if ( ("getRead" in accessRights && accessRights.getRead()) || ("getExecute" in accessRights && accessRights.getExecute()) ) { - subtitle.setValue(osparc.data.Roles.ORG[1].label); + role.setValue(osparc.data.Roles.ORG[1].label); } else { - subtitle.setValue(osparc.data.Roles.ORG[0].label); + role.setValue(osparc.data.Roles.ORG[0].label); } }, diff --git a/services/static-webserver/client/source/class/osparc/ui/list/OrganizationListItem.js b/services/static-webserver/client/source/class/osparc/ui/list/OrganizationListItem.js index 905e520f2f8..6da8294c011 100644 --- a/services/static-webserver/client/source/class/osparc/ui/list/OrganizationListItem.js +++ b/services/static-webserver/client/source/class/osparc/ui/list/OrganizationListItem.js @@ -33,6 +33,12 @@ qx.Class.define("osparc.ui.list.OrganizationListItem", { }, members: { + // overridden + _setRole: function() { + // Role field was already filled up with the nMembers + return; + }, + // overridden _getOptionsMenu: function() { let menu = null; diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index 629468c1312..5c751c2ee8f 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -1023,20 +1023,20 @@ qx.Class.define("osparc.utils.Utils", { }, setIdToWidget: (qWidget, id) => { - if (qWidget.getContentElement) { + if (qWidget.getContentElement && qWidget.getContentElement()) { qWidget.getContentElement().setAttribute("osparc-test-id", id); } }, getIdFromWidget: qWidget => { - if (qWidget.getContentElement) { + if (qWidget.getContentElement && qWidget.getContentElement()) { return qWidget.getContentElement().getAttribute("osparc-test-id"); } return null; }, setKeyToWidget: (qWidget, id) => { - if (qWidget.getContentElement) { + if (qWidget.getContentElement && qWidget.getContentElement()) { qWidget.getContentElement().setAttribute("osparc-test-key", id); } },