Skip to content

Commit 0b26a7a

Browse files
committed
createConfirmRemoveForMeWindow
1 parent 26b1f48 commit 0b26a7a

File tree

1 file changed

+35
-1
lines changed
  • services/static-webserver/client/source/class/osparc/dashboard

1 file changed

+35
-1
lines changed

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,10 +1521,18 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
15211521
}
15221522
}
15231523

1524+
const myGid = osparc.auth.Data.getInstance().getGroupId();
1525+
const collabGids = Object.keys(studyData["accessRights"]);
1526+
const amICollaborator = collabGids.indexOf(myGid) > -1;
15241527
if (deleteAccess) {
1525-
const trashButton = this.__getTrashStudyMenuButton(studyData, false);
15261528
menu.addSeparator();
1529+
const trashButton = this.__getTrashStudyMenuButton(studyData, false);
15271530
menu.add(trashButton);
1531+
} else if (amICollaborator) {
1532+
// if I'm a collaborator, let me remove myself from the study. In that case it would be a Delete for me
1533+
menu.addSeparator();
1534+
const deleteButton = this.__getDeleteStudyMenuButton(studyData, false);
1535+
menu.add(deleteButton);
15281536
}
15291537

15301538
card.evaluateMenuButtons();
@@ -1730,6 +1738,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
17301738
},
17311739

17321740
__deleteStudyRequested: function(studyData) {
1741+
// OM here
17331742
const preferencesSettings = osparc.Preferences.getInstance();
17341743
if (preferencesSettings.getConfirmDeleteStudy()) {
17351744
const win = this.__createConfirmDeleteWindow([studyData.name]);
@@ -1962,6 +1971,20 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19621971
.finally(() => this.resetSelection());
19631972
},
19641973

1974+
__deleteCollaborator: function(studyData) {
1975+
const myGid = osparc.auth.Data.getInstance().getGroupId();
1976+
const collabGids = Object.keys(studyData["accessRights"]);
1977+
const amICollaborator = collabGids.indexOf(myGid) > -1;
1978+
1979+
if (collabGids.length > 1 && amICollaborator) {
1980+
const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]);
1981+
// remove collaborator
1982+
delete arCopy[myGid];
1983+
// OM here
1984+
operationPromise = osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy);
1985+
}
1986+
},
1987+
19651988
__trashStudies: function(studiesData) {
19661989
studiesData.forEach(studyData => this.__trashStudy(studyData));
19671990
},
@@ -2009,6 +2032,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
20092032
return confirmationWin;
20102033
},
20112034

2035+
__createConfirmRemoveForMeWindow: function(studyName) {
2036+
const msg = `'${studyName} ` + this.tr("will be removed from your list. Collaborators will still have access.");
2037+
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({
2038+
caption: this.tr("Remove"),
2039+
confirmText: this.tr("Remove"),
2040+
confirmAction: "delete"
2041+
});
2042+
osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn");
2043+
return confirmationWin;
2044+
},
2045+
20122046
__createConfirmDeleteWindow: function(studyNames) {
20132047
let msg = this.tr("Are you sure you want to delete");
20142048
const studyAlias = osparc.product.Utils.getStudyAlias({plural: studyNames.length > 1});

0 commit comments

Comments
 (0)