Skip to content

Commit

Permalink
Enable/disable Export and Duplicate (#2820)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Feb 11, 2022
1 parent fffcb66 commit 5bfec5c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 6 deletions.
21 changes: 15 additions & 6 deletions services/web/client/source/class/osparc/dashboard/StudyBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
const renameStudyButton = this.__getRenameStudyMenuButton(studyData);
menu.add(renameStudyButton);

const duplicateStudyButton = this.__getDuplicateStudyMenuButton(studyData);
const duplicateStudyButton = this.__getDuplicateMenuButton(studyData);
menu.add(duplicateStudyButton);

const exportButton = this.__getExportMenuButton(studyData);
Expand Down Expand Up @@ -497,17 +497,26 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
});
},

__getDuplicateStudyMenuButton: function(studyData) {
const duplicateStudyButton = new qx.ui.menu.Button(this.tr("Duplicate"));
osparc.utils.Utils.setIdToWidget(duplicateStudyButton, "duplicateStudy");
duplicateStudyButton.addListener("execute", () => {
__getDuplicateMenuButton: function(studyData) {
const duplicateButton = new qx.ui.menu.Button(this.tr("Duplicate"));
duplicateButton.exclude();
osparc.utils.DisabledPlugins.isDuplicateDisabled()
.then(isDisabled => {
duplicateButton.setVisibility(isDisabled ? "excluded" : "visible");
});
duplicateButton.addListener("execute", () => {
this.__duplicateStudy(studyData);
}, this);
return duplicateStudyButton;
return duplicateButton;
},

__getExportMenuButton: function(studyData) {
const exportButton = new qx.ui.menu.Button(this.tr("Export"));
exportButton.exclude();
osparc.utils.DisabledPlugins.isExportDisabled()
.then(isDisabled => {
exportButton.setVisibility(isDisabled ? "excluded" : "visible");
});
exportButton.addListener("execute", () => {
this.__exportStudy(studyData);
}, this);
Expand Down
55 changes: 55 additions & 0 deletions services/web/client/source/class/osparc/utils/DisabledPlugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* ************************************************************************
osparc - the simcore frontend
https://osparc.io
Copyright:
2022 IT'IS Foundation, https://itis.swiss
License:
MIT: https://opensource.org/licenses/MIT
Authors:
* Odei Maiz (odeimaiz)
************************************************************************ */

/**
* Collection of methods for studies
*/

qx.Class.define("osparc.utils.DisabledPlugins", {
type: "static",

statics: {
EXPORT: "WEBSERVER_EXPORTER",
DUPLICATE: "WEBSERVER_EXPORTER",
SCICRUNCH: "WEBSERVER_SCICRUNCH",

isExportDisabled: function() {
return this.self().isPluginDisabled(this.self().EXPORT);
},

isDuplicateDisabled: function() {
return this.self().isPluginDisabled(this.self().EXPORT);
},

isScicrunchDisabled: function() {
return this.self().isPluginDisabled(this.self().SCICRUNCH);
},

isPluginDisabled: function(key) {
return new Promise((resolve, reject) => {
osparc.data.Resources.get("statics")
.then(statics => {
if ("pluginsDisabled" in statics) {
resolve(statics["pluginsDisabled"].includes(key));
}
resolve(false);
})
.catch(err => reject(err));
});
}
}
});

0 comments on commit 5bfec5c

Please sign in to comment.