Skip to content

Commit

Permalink
[Frontend] 🎨 TIP enhancements (ITISFoundation#6197)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored and giancarloromeo committed Aug 19, 2024
1 parent dc3df97 commit f6b9dd0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f6b9dd0

Please sign in to comment.