Skip to content

Commit 5bfec5c

Browse files
authored
Enable/disable Export and Duplicate (ITISFoundation#2820)
1 parent fffcb66 commit 5bfec5c

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

services/web/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
435435
const renameStudyButton = this.__getRenameStudyMenuButton(studyData);
436436
menu.add(renameStudyButton);
437437

438-
const duplicateStudyButton = this.__getDuplicateStudyMenuButton(studyData);
438+
const duplicateStudyButton = this.__getDuplicateMenuButton(studyData);
439439
menu.add(duplicateStudyButton);
440440

441441
const exportButton = this.__getExportMenuButton(studyData);
@@ -497,17 +497,26 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
497497
});
498498
},
499499

500-
__getDuplicateStudyMenuButton: function(studyData) {
501-
const duplicateStudyButton = new qx.ui.menu.Button(this.tr("Duplicate"));
502-
osparc.utils.Utils.setIdToWidget(duplicateStudyButton, "duplicateStudy");
503-
duplicateStudyButton.addListener("execute", () => {
500+
__getDuplicateMenuButton: function(studyData) {
501+
const duplicateButton = new qx.ui.menu.Button(this.tr("Duplicate"));
502+
duplicateButton.exclude();
503+
osparc.utils.DisabledPlugins.isDuplicateDisabled()
504+
.then(isDisabled => {
505+
duplicateButton.setVisibility(isDisabled ? "excluded" : "visible");
506+
});
507+
duplicateButton.addListener("execute", () => {
504508
this.__duplicateStudy(studyData);
505509
}, this);
506-
return duplicateStudyButton;
510+
return duplicateButton;
507511
},
508512

509513
__getExportMenuButton: function(studyData) {
510514
const exportButton = new qx.ui.menu.Button(this.tr("Export"));
515+
exportButton.exclude();
516+
osparc.utils.DisabledPlugins.isExportDisabled()
517+
.then(isDisabled => {
518+
exportButton.setVisibility(isDisabled ? "excluded" : "visible");
519+
});
511520
exportButton.addListener("execute", () => {
512521
this.__exportStudy(studyData);
513522
}, this);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2022 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
/**
19+
* Collection of methods for studies
20+
*/
21+
22+
qx.Class.define("osparc.utils.DisabledPlugins", {
23+
type: "static",
24+
25+
statics: {
26+
EXPORT: "WEBSERVER_EXPORTER",
27+
DUPLICATE: "WEBSERVER_EXPORTER",
28+
SCICRUNCH: "WEBSERVER_SCICRUNCH",
29+
30+
isExportDisabled: function() {
31+
return this.self().isPluginDisabled(this.self().EXPORT);
32+
},
33+
34+
isDuplicateDisabled: function() {
35+
return this.self().isPluginDisabled(this.self().EXPORT);
36+
},
37+
38+
isScicrunchDisabled: function() {
39+
return this.self().isPluginDisabled(this.self().SCICRUNCH);
40+
},
41+
42+
isPluginDisabled: function(key) {
43+
return new Promise((resolve, reject) => {
44+
osparc.data.Resources.get("statics")
45+
.then(statics => {
46+
if ("pluginsDisabled" in statics) {
47+
resolve(statics["pluginsDisabled"].includes(key));
48+
}
49+
resolve(false);
50+
})
51+
.catch(err => reject(err));
52+
});
53+
}
54+
}
55+
});

0 commit comments

Comments
 (0)