From f6b9dd025d23a42a229ada0bf24413dab7f62896 Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:40:32 +0200 Subject: [PATCH] =?UTF-8?q?[Frontend]=20=F0=9F=8E=A8=20TIP=20enhancements?= =?UTF-8?q?=20(#6197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/source/class/osparc/data/Permissions.js | 6 +++--- .../class/osparc/desktop/account/MyAccount.js | 14 ++++++++------ .../class/osparc/share/CollaboratorsStudy.js | 7 +++++-- .../source/class/osparc/share/ShareePermissions.js | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/Permissions.js b/services/static-webserver/client/source/class/osparc/data/Permissions.js index 90dfadf612f..b1047862753 100644 --- a/services/static-webserver/client/source/class/osparc/data/Permissions.js +++ b/services/static-webserver/client/source/class/osparc/data/Permissions.js @@ -233,7 +233,7 @@ qx.Class.define("osparc.data.Permissions", { }, // https://blog.nodeswat.com/implement-access-control-in-node-js-8567e7b484d1#2405 - __canRoleDo: function(role, action) { + canRoleDo: function(role, action) { role = role.toLowerCase(); // Check if role exists const roles = this.self().ROLES_APP; @@ -250,13 +250,13 @@ qx.Class.define("osparc.data.Permissions", { return false; } // Check child roles until one returns true or all return false - return roleObj.inherits.some(childRole => this.__canRoleDo(childRole, action)); + return roleObj.inherits.some(childRole => this.canRoleDo(childRole, action)); }, canDo: function(action, showMsg) { let canDo = false; if (this.getRole()) { - canDo = this.__canRoleDo(this.getRole(), action); + canDo = this.canRoleDo(this.getRole(), action); } if (showMsg && !canDo) { let msg = "Operation not permitted"; diff --git a/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js b/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js index 0f375dd3a1c..d61bbb5f4d4 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js +++ b/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js @@ -68,12 +68,14 @@ qx.Class.define("osparc.desktop.account.MyAccount", { converter: lastName => authData.getFirstName() + " " + lastName }); - const role = authData.getFriendlyRole(); - const roleLabel = new qx.ui.basic.Label(role).set({ - font: "text-13", - alignX: "center" - }); - layout.add(roleLabel); + if (authData.getRole() !== "user") { + const role = authData.getFriendlyRole(); + const roleLabel = new qx.ui.basic.Label(role).set({ + font: "text-13", + alignX: "center" + }); + layout.add(roleLabel); + } const emailLabel = new qx.ui.basic.Label(email).set({ font: "text-13", diff --git a/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js b/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js index 337e09e50b3..0326dafb5f8 100644 --- a/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js +++ b/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js @@ -262,8 +262,11 @@ qx.Class.define("osparc.share.CollaboratorsStudy", { const uid = collab["id"]; if (this._resourceType === "study") { osparc.notification.Notifications.postNewStudy(uid, this._serializedDataCopy["uuid"]); - } else { - osparc.notification.Notifications.postNewTemplate(uid, this._serializedDataCopy["uuid"]); + } else if (this._resourceType === "template") { + // do not push TEMPLATE_SHARED notification if users are not supposed to see the templates + if (osparc.data.Permissions.getInstance().canRoleDo("user", "dashboard.templates.read")) { + osparc.notification.Notifications.postNewTemplate(uid, this._serializedDataCopy["uuid"]); + } } } }); diff --git a/services/static-webserver/client/source/class/osparc/share/ShareePermissions.js b/services/static-webserver/client/source/class/osparc/share/ShareePermissions.js index 5f3fdc9a1d9..4df66b06ca6 100644 --- a/services/static-webserver/client/source/class/osparc/share/ShareePermissions.js +++ b/services/static-webserver/client/source/class/osparc/share/ShareePermissions.js @@ -55,6 +55,7 @@ qx.Class.define("osparc.share.ShareePermissions", { .then(metadata => { label.setValue(metadata["name"] + " : " + metadata["version"]) infoButton.addListener("execute", () => { + metadata["resourceType"] = "service"; const resourceDetails = new osparc.dashboard.ResourceDetails(metadata); osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails); }, this);