Skip to content

Commit 0cabdeb

Browse files
committed
check workspace change
1 parent 4913f04 commit 0cabdeb

File tree

1 file changed

+71
-47
lines changed
  • services/static-webserver/client/source/class/osparc/dashboard

1 file changed

+71
-47
lines changed

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

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -522,32 +522,40 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
522522
return win;
523523
},
524524

525-
_moveFolderToRequested: function(workspaceId, folderId) {
526-
const moveFolderTo = new osparc.dashboard.MoveResourceTo(this.getCurrentWorkspaceId(), this.getCurrentFolderId());
525+
_moveFolderToRequested: function(folderId) {
526+
const currentWorkspaceId = this.getCurrentWorkspaceId();
527+
const currentFolderId = this.getCurrentWorkspaceId();
528+
const moveFolderTo = new osparc.dashboard.MoveResourceTo(currentWorkspaceId, currentFolderId);
527529
const title = this.tr("Move to...");
528530
const win = osparc.ui.window.Window.popUpInWindow(moveFolderTo, title, 400, 400);
529531
moveFolderTo.addListener("moveTo", e => {
530532
win.close();
531533
const data = e.getData();
532534
const destWorkspaceId = data["workspaceId"];
533535
const destFolderId = data["folderId"];
534-
if (destWorkspaceId !== workspaceId) {
536+
if (destWorkspaceId !== currentWorkspaceId) {
535537
const msg = this.tr("Coming soon");
536538
osparc.FlashMessenger.getInstance().logAs(msg, "WARNING");
537539
return;
538540
}
539-
// OM only if workspace changed
540-
const confirmationWin = this.__showMoveToWorkspaceWarningMessage();
541-
confirmationWin.addListener("close", () => {
542-
if (confirmationWin.getConfirmed()) {
543-
Promise.all([
544-
this.__moveFolderToWorkspace(folderId, destWorkspaceId),
545-
this.__moveFolderToFolder(folderId, destFolderId),
546-
])
547-
.then(() => this.__reloadFolders())
548-
.catch(err => console.error(err));
549-
}
550-
}, this);
541+
const moveFolder = () => {
542+
Promise.all([
543+
this.__moveFolderToWorkspace(folderId, destWorkspaceId),
544+
this.__moveFolderToFolder(folderId, destFolderId),
545+
])
546+
.then(() => this.__reloadFolders())
547+
.catch(err => console.error(err));
548+
}
549+
if (destWorkspaceId === currentWorkspaceId) {
550+
moveFolder();
551+
} else {
552+
const confirmationWin = this.__showMoveToWorkspaceWarningMessage();
553+
confirmationWin.addListener("close", () => {
554+
if (confirmationWin.getConfirmed()) {
555+
moveFolder();
556+
}
557+
}, this);
558+
}
551559
});
552560
},
553561

@@ -1045,32 +1053,40 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
10451053
visibility: "excluded",
10461054
});
10471055
moveStudiesButton.addListener("execute", () => {
1048-
const selection = this._resourcesContainer.getSelection();
1056+
const currentWorkspaceId = this.getCurrentWorkspaceId();
1057+
const currentFolderId = this.getCurrentFolderId();
1058+
const moveStudyTo = new osparc.dashboard.MoveResourceTo(currentWorkspaceId, currentFolderId);
10491059
const title = this.tr("Move to...");
1050-
const moveStudyTo = new osparc.dashboard.MoveResourceTo(this.getCurrentWorkspaceId(), this.getCurrentFolderId());
10511060
const win = osparc.ui.window.Window.popUpInWindow(moveStudyTo, title, 400, 400);
10521061
moveStudyTo.addListener("moveTo", e => {
10531062
win.close();
10541063
const data = e.getData();
10551064
const destWorkspaceId = data["workspaceId"];
10561065
const destFolderId = data["folderId"];
1057-
// OM only if workspace changed
1058-
const confirmationWin = this.__showMoveToWorkspaceWarningMessage();
1059-
confirmationWin.addListener("close", () => {
1060-
if (confirmationWin.getConfirmed()) {
1061-
selection.forEach(button => {
1062-
const studyData = button.getResourceData();
1063-
Promise.all([
1064-
this.__moveStudyToWorkspace(studyData, destWorkspaceId),
1065-
this.__moveStudyToFolder(studyData, destFolderId),
1066-
])
1067-
.then(() => this.__removeFromStudyList(studyData["uuid"]))
1068-
.catch(err => console.error(err));
1069-
});
1070-
this.resetSelection();
1071-
this.setMultiSelection(false);
1072-
}
1073-
}, this);
1066+
const moveStudies = () => {
1067+
const selection = this._resourcesContainer.getSelection();
1068+
selection.forEach(button => {
1069+
const studyData = button.getResourceData();
1070+
Promise.all([
1071+
this.__moveStudyToWorkspace(studyData, destWorkspaceId),
1072+
this.__moveStudyToFolder(studyData, destFolderId),
1073+
])
1074+
.then(() => this.__removeFromStudyList(studyData["uuid"]))
1075+
.catch(err => console.error(err));
1076+
});
1077+
this.resetSelection();
1078+
this.setMultiSelection(false);
1079+
}
1080+
if (destWorkspaceId === currentWorkspaceId) {
1081+
moveStudies();
1082+
} else {
1083+
const confirmationWin = this.__showMoveToWorkspaceWarningMessage();
1084+
confirmationWin.addListener("close", () => {
1085+
if (confirmationWin.getConfirmed()) {
1086+
moveStudies();
1087+
}
1088+
}, this);
1089+
}
10741090
}, this);
10751091
moveStudyTo.addListener("cancel", () => win.close());
10761092
}, this);
@@ -1387,26 +1403,34 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
13871403
const moveToButton = new qx.ui.menu.Button(this.tr("Move to..."), "@FontAwesome5Solid/folder/12");
13881404
moveToButton["moveToButton"] = true;
13891405
moveToButton.addListener("tap", () => {
1406+
const currentWorkspaceId = this.getCurrentWorkspaceId();
1407+
const currentFolderId = this.getCurrentWorkspaceId();
1408+
const moveStudyTo = new osparc.dashboard.MoveResourceTo(currentWorkspaceId, currentFolderId);
13901409
const title = this.tr("Move to...");
1391-
const moveStudyTo = new osparc.dashboard.MoveResourceTo(this.getCurrentWorkspaceId(), this.getCurrentFolderId());
13921410
const win = osparc.ui.window.Window.popUpInWindow(moveStudyTo, title, 400, 400);
13931411
moveStudyTo.addListener("moveTo", e => {
13941412
win.close();
13951413
const data = e.getData();
13961414
const destWorkspaceId = data["workspaceId"];
13971415
const destFolderId = data["folderId"];
1398-
// OM only if workspace changed
1399-
const confirmationWin = this.__showMoveToWorkspaceWarningMessage();
1400-
confirmationWin.addListener("close", () => {
1401-
if (confirmationWin.getConfirmed()) {
1402-
Promise.all([
1403-
this.__moveStudyToWorkspace(studyData, destWorkspaceId),
1404-
this.__moveStudyToFolder(studyData, destFolderId),
1405-
])
1406-
.then(() => this.__removeFromStudyList(studyData["uuid"]))
1407-
.catch(err => console.error(err));
1408-
}
1409-
}, this);
1416+
const moveStudy = () => {
1417+
Promise.all([
1418+
this.__moveStudyToWorkspace(studyData, destWorkspaceId),
1419+
this.__moveStudyToFolder(studyData, destFolderId),
1420+
])
1421+
.then(() => this.__removeFromStudyList(studyData["uuid"]))
1422+
.catch(err => console.error(err));
1423+
};
1424+
if (destWorkspaceId === currentWorkspaceId) {
1425+
moveStudy();
1426+
} else {
1427+
const confirmationWin = this.__showMoveToWorkspaceWarningMessage();
1428+
confirmationWin.addListener("close", () => {
1429+
if (confirmationWin.getConfirmed()) {
1430+
moveStudy();
1431+
}
1432+
}, this);
1433+
}
14101434
}, this);
14111435
moveStudyTo.addListener("cancel", () => win.close());
14121436
}, this);

0 commit comments

Comments
 (0)