Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ qx.Class.define("osparc.data.Roles", {

if (showWording) {
const rolesText = new qx.ui.basic.Label(qx.locale.Manager.tr("Roles")).set({
alignY: "middle",
font: "text-13"
});
rolesLayout.add(rolesText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ qx.Class.define("osparc.share.Collaborators", {
return control || this.base(arguments, id);
},

__canIShare: function() {
if (this._resourceType === "study" && this._serializedDataCopy["workspaceId"]) {
// Access Rights are set at workspace level
return false;
}
let canIShare = false;
switch (this._resourceType) {
case "study":
case "template":
case "service":
canIShare = osparc.service.Utils.canIWrite(this._serializedDataCopy["accessRights"]);
break;
case "workspace":
canIShare = osparc.share.CollaboratorsWorkspace.canIDelete(this._serializedDataCopy["myAccessRights"]);
break;
}
return canIShare;
},

__canIChangePermissions: function() {
if (this._resourceType === "study" && this._serializedDataCopy["workspaceId"]) {
// Access Rights are set at workspace level
Expand Down Expand Up @@ -227,7 +246,7 @@ qx.Class.define("osparc.share.Collaborators", {
},

__buildLayout: function() {
if (this.__canIChangePermissions()) {
if (this.__canIShare()) {
this.__addCollaborators = this._createChildControlImpl("add-collaborator");
}
this._createChildControlImpl("collaborators-list");
Expand Down Expand Up @@ -330,22 +349,22 @@ qx.Class.define("osparc.share.Collaborators", {
},

__getLeaveStudyButton: function() {
const myGid = osparc.auth.Data.getInstance().getGroupId();
if (
(this._resourceType === "study") &&
// check the study is shared
(Object.keys(this._serializedDataCopy["accessRights"]).length > 1) &&
// check if I'm part of the access rights (not through an organization)
Object.keys(this._serializedDataCopy["accessRights"]).includes(myGid.toString()) &&
// check also user is not "prjOwner". Backend will silently not let the frontend remove that user.
(this._serializedDataCopy["prjOwner"] !== osparc.auth.Data.getInstance().getEmail())
) {
const myGid = osparc.auth.Data.getInstance().getGroupId();
const leaveButton = new qx.ui.form.Button(this.tr("Leave") + " " + osparc.product.Utils.getStudyAlias({
firstUpperCase: true
})).set({
allowGrowX: false,
visibility: Object.keys(this._serializedDataCopy["accessRights"]).includes(myGid.toString()) ? "visible" : "excluded"
});
leaveButton.addListener("execute", () => {
let msg = this._serializedDataCopy["name"] + " " + this.tr("will no longer be listed.");
let msg = `"${this._serializedDataCopy["name"]}" ` + this.tr("will no longer be listed.");
if (!osparc.share.CollaboratorsStudy.checkRemoveCollaborator(this._serializedDataCopy, myGid)) {
msg += "<br>";
msg += this.tr("If you remove yourself, there won't be any other Owners.");
Expand All @@ -357,8 +376,10 @@ qx.Class.define("osparc.share.Collaborators", {
win.open();
win.addListener("close", () => {
if (win.getConfirmed()) {
this._deleteMember({gid: myGid});
qx.event.message.Bus.dispatchByName("reloadStudies");
this._deleteMember({gid: myGid})
.then(() => {
qx.event.message.Bus.dispatchByName("reloadStudies");
});
}
}, this);
}, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
item.setEnabled(false);
}

osparc.info.StudyUtils.removeCollaborator(this._serializedDataCopy, collaborator["gid"])
return osparc.info.StudyUtils.removeCollaborator(this._serializedDataCopy, collaborator["gid"])
.then(() => {
this.fireDataEvent("updateAccessRights", this._serializedDataCopy);
osparc.FlashMessenger.getInstance().logAs(this.tr("Member successfully removed"));
Expand Down
Loading