Skip to content

Commit 035ceb7

Browse files
committed
[skip ci] refactor
1 parent 5e6ebca commit 035ceb7

File tree

1 file changed

+14
-20
lines changed
  • services/static-webserver/client/source/class/osparc/dashboard

1 file changed

+14
-20
lines changed

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

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,10 +1738,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
17381738
},
17391739

17401740
__deleteStudyRequested: function(studyData) {
1741-
// OM here
17421741
const preferencesSettings = osparc.Preferences.getInstance();
17431742
if (preferencesSettings.getConfirmDeleteStudy()) {
1744-
const win = this.__createConfirmDeleteWindow([studyData.name]);
1743+
const win = false ? this.__createConfirmRemoveForMeWindow(studyData.name) : this.__createConfirmDeleteWindow([studyData.name]);
17451744
win.center();
17461745
win.open();
17471746
win.addListener("close", () => {
@@ -1971,34 +1970,29 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19711970
.finally(() => this.resetSelection());
19721971
},
19731972

1974-
__removeMeFromCollaborators: 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-
if (collabGids.length > 1 && amICollaborator) {
1979-
const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]);
1980-
// remove collaborator
1981-
delete arCopy[myGid];
1982-
return osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy);
1983-
}
1984-
return null;
1985-
},
1986-
19871973
__trashStudies: function(studiesData) {
19881974
studiesData.forEach(studyData => this.__trashStudy(studyData));
19891975
},
19901976

1991-
__doDeleteStudy: function(studyData) {
1977+
__deleteOrRemoveMe: function(studyData) {
19921978
const myGid = osparc.auth.Data.getInstance().getGroupId();
19931979
const collabGids = Object.keys(studyData["accessRights"]);
19941980
const amICollaborator = collabGids.indexOf(myGid) > -1;
1981+
return (collabGids.length > 1 && amICollaborator) ? "remove" : "delete";
1982+
},
19951983

1984+
__removeMeFromCollaborators: function(studyData) {
1985+
const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]);
1986+
// remove me from collaborators
1987+
const myGid = osparc.auth.Data.getInstance().getGroupId();
1988+
delete arCopy[myGid];
1989+
return osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy);
1990+
},
1991+
1992+
__doDeleteStudy: function(studyData) {
19961993
let operationPromise = null;
1997-
if (collabGids.length > 1 && amICollaborator) {
1994+
if (this.__deleteOrRemoveMe(studyData) === "remove") {
19981995
operationPromise = this.__removeMeFromCollaborators(studyData);
1999-
if (operationPromise === null) {
2000-
return;
2001-
}
20021996
} else {
20031997
// delete study
20041998
operationPromise = osparc.store.Store.getInstance().deleteStudy(studyData.uuid);

0 commit comments

Comments
 (0)