diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 8d65da2689b5..1ca9f2d6da6a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -700,7 +700,7 @@ qx.Class.define("osparc.dashboard.CardBase", { } // Block card - const cantReadServices = osparc.study.Utils.getCantExecuteServices(services); + const cantReadServices = osparc.study.Utils.getCantReadServices(services); if (cantReadServices.length) { this.setBlocked("UNKNOWN_SERVICES"); const image = "@FontAwesome5Solid/ban/"; @@ -985,8 +985,17 @@ qx.Class.define("osparc.dashboard.CardBase", { throw new Error("Abstract method called!"); }, - _applyMenu: function(value, old) { - throw new Error("Abstract method called!"); + _applyMenu: function(menu) { + const menuButton = this.getChildControl("menu-button"); + if (menu) { + menuButton.setMenu(menu).set({ + appearance: "menu-wider", + position: "bottom-left", + }); + osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu"); + menu.addListener("appear", () => this.evaluateMenuButtons()); + } + menuButton.setVisibility(menu ? "visible" : "excluded"); }, _setStudyPermissions: function(accessRights) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js index 858328268c08..3cce2f18165d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js @@ -281,19 +281,5 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { } } }, - - // overridden - _applyMenu: function(menu, old) { - const menuButton = this.getChildControl("menu-button"); - if (menu) { - menuButton.setMenu(menu).set({ - appearance: "menu-wider", - position: "bottom-left", - }); - osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu"); - this.evaluateMenuButtons(); - } - menuButton.setVisibility(menu ? "visible" : "excluded"); - } } }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js index 23cc75e57145..d50a5a6e025a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js @@ -295,18 +295,5 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { }); }); }, - - _applyMenu: function(menu, old) { - const menuButton = this.getChildControl("menu-button"); - if (menu) { - menuButton.setMenu(menu).set({ - appearance: "menu-wider", - position: "bottom-left", - }); - osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu"); - this.evaluateMenuButtons(); - } - menuButton.setVisibility(menu ? "visible" : "excluded"); - } } }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 6ca86566385f..618cabf1e4cd 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1598,10 +1598,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const duplicateStudyButton = this.__getDuplicateMenuButton(studyData); menu.add(duplicateStudyButton); - const convertToPipelineButton = this.__getConvertToPipelineMenuButton(studyData); - menu.add(convertToPipelineButton); + if (writeAccess && osparc.product.Utils.showConvertToPipeline()) { + const convertToPipelineButton = this.__getConvertToPipelineMenuButton(studyData); + menu.add(convertToPipelineButton); + } - if (osparc.product.Utils.hasExportCMisEnabled()) { + if (osparc.product.Utils.showExportCMis()) { const exportStudyButton = this.__getExportCMisMenuButton(studyData); menu.add(exportStudyButton); } diff --git a/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudyUpdate.js b/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudyUpdate.js index 4b8c971c763a..2fba38e39604 100644 --- a/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudyUpdate.js +++ b/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudyUpdate.js @@ -60,7 +60,7 @@ qx.Class.define("osparc.metadata.ServicesInStudyUpdate", { osparc.store.Services.getStudyServices(this._studyData["uuid"]) .then(resp => { const services = resp["services"]; - if (osparc.study.Utils.getCantExecuteServices(services).length) { + if (osparc.study.Utils.getCantReadServices(services).length) { msg += this.tr("Some services are inaccessible. Please contact the service owner:"); msg += "

"; } diff --git a/services/static-webserver/client/source/class/osparc/navigation/StudyTitleWOptions.js b/services/static-webserver/client/source/class/osparc/navigation/StudyTitleWOptions.js index 1b86bfab8564..4e77826e91bd 100644 --- a/services/static-webserver/client/source/class/osparc/navigation/StudyTitleWOptions.js +++ b/services/static-webserver/client/source/class/osparc/navigation/StudyTitleWOptions.js @@ -89,15 +89,6 @@ qx.Class.define("osparc.navigation.StudyTitleWOptions", { }); control.addListener("execute", () => this.__convertToPipelineClicked(), this); break; - case "study-menu-restore": - control = new qx.ui.menu.Button().set({ - label: this.tr("Restore"), - icon: osparc.theme.common.Image.URLS["window-restore"] + "/20", - }); - control.addListener("execute", () => { - this.getStudy().getUi().setMode("workbench"); - }); - break; case "study-menu-open-logger": control = new qx.ui.menu.Button().set({ label: this.tr("Platform Logs..."), @@ -111,8 +102,9 @@ qx.Class.define("osparc.navigation.StudyTitleWOptions", { optionsMenu.add(this.getChildControl("study-menu-info")); optionsMenu.add(this.getChildControl("study-menu-reload")); optionsMenu.add(this.getChildControl("study-menu-conversations")); - optionsMenu.add(this.getChildControl("study-menu-convert-to-pipeline")); - optionsMenu.add(this.getChildControl("study-menu-restore")); + if (osparc.product.Utils.showConvertToPipeline()) { + optionsMenu.add(this.getChildControl("study-menu-convert-to-pipeline")); + } optionsMenu.add(this.getChildControl("study-menu-open-logger")); control = new qx.ui.form.MenuButton().set({ appearance: "fab-button", @@ -162,15 +154,12 @@ qx.Class.define("osparc.navigation.StudyTitleWOptions", { converter: mode => mode === "standalone" ? "visible" : "excluded" }); - const convertToPipelineButton = this.getChildControl("study-menu-convert-to-pipeline"); - study.getUi().bind("mode", convertToPipelineButton, "visibility", { - converter: mode => mode === "standalone" ? "visible" : "excluded" - }); - - const restoreButton = this.getChildControl("study-menu-restore"); - study.getUi().bind("mode", restoreButton, "visibility", { - converter: mode => mode === "standalone" ? "visible" : "excluded" - }); + if (osparc.product.Utils.showConvertToPipeline()) { + const convertToPipelineButton = this.getChildControl("study-menu-convert-to-pipeline"); + study.getUi().bind("mode", convertToPipelineButton, "visibility", { + converter: mode => mode === "standalone" ? "visible" : "excluded" + }); + } const loggerButton = this.getChildControl("study-menu-open-logger"); study.getUi().bind("mode", loggerButton, "visibility", { diff --git a/services/static-webserver/client/source/class/osparc/product/Utils.js b/services/static-webserver/client/source/class/osparc/product/Utils.js index 9f81c38f71a8..c62579e23740 100644 --- a/services/static-webserver/client/source/class/osparc/product/Utils.js +++ b/services/static-webserver/client/source/class/osparc/product/Utils.js @@ -230,7 +230,7 @@ qx.Class.define("osparc.product.Utils", { }, // oSPARC only - hasExportCMisEnabled: function() { + showExportCMis: function() { const product = this.getProductName(); return product === "osparc"; }, @@ -307,17 +307,15 @@ qx.Class.define("osparc.product.Utils", { }, showQuality: function() { - if (this.isProduct("osparc")) { - return true; - } - return false; + return this.isProduct("osparc"); }, showClassifiers: function() { - if (this.getProductName().includes("s4l")) { - return false; - } - return true; + return this.isProduct("osparc"); + }, + + showConvertToPipeline: function() { + return this.isS4LProduct() || this.isProduct("osparc"); }, showS4LStore: function() { diff --git a/services/static-webserver/client/source/class/osparc/store/Services.js b/services/static-webserver/client/source/class/osparc/store/Services.js index eac4a2ba3384..c77b31b54c26 100644 --- a/services/static-webserver/client/source/class/osparc/store/Services.js +++ b/services/static-webserver/client/source/class/osparc/store/Services.js @@ -37,7 +37,7 @@ qx.Class.define("osparc.store.Services", { const servicesObj = osparc.service.Utils.convertArrayToObject(servicesArray); this.__addHits(servicesObj); this.__addTSRInfos(servicesObj); - this.__addExtraTypeInfos(servicesObj); + this.__addXTypeInfos(servicesObj); Object.values(servicesObj).forEach(serviceKey => { Object.values(serviceKey).forEach(service => this.__addServiceToCache(service)); @@ -128,9 +128,6 @@ qx.Class.define("osparc.store.Services", { }; this.__servicesPromisesCached[key][version] = osparc.data.Resources.fetch("services", "getOne", params) .then(service => { - this.__addHit(service); - this.__addTSRInfo(service); - this.__addExtraTypeInfo(service); this.__addServiceToCache(service); // Resolve the promise locally before deleting it resolve(service); @@ -168,6 +165,15 @@ qx.Class.define("osparc.store.Services", { } }; this.__studyServicesPromisesCached[studyId] = osparc.data.Resources.fetch("studies", "getServices", params) + .then(resp => { + const services = resp["services"]; + services.forEach(service => { + // this service information is not complete, keep it in cache anyway + service.version = service["release"]["version"]; + this.__addServiceToCache(service); + }); + return resp; + }) .finally(() => { delete this.__studyServicesPromisesCached[studyId]; }); @@ -368,6 +374,10 @@ qx.Class.define("osparc.store.Services", { }, __addServiceToCache: function(service) { + this.__addHit(service); + this.__addTSRInfo(service); + this.__addXTypeInfo(service); + const key = service.key; const version = service.version; service["resourceType"] = "service"; @@ -375,6 +385,15 @@ qx.Class.define("osparc.store.Services", { }, __addToCache: function(key, version, value) { + // some services that go to the cache are not complete, e.g. study services + // if the one in the cache is the complete one, do not overwrite it + if ( + this.__isInCache(key, version) && + "inputs" in this.__servicesCached[key][version] + ) { + return; + } + if (!(key in this.__servicesCached)) { this.__servicesCached[key] = {}; } @@ -414,7 +433,7 @@ qx.Class.define("osparc.store.Services", { }); }, - __addExtraTypeInfo: function(service) { + __addXTypeInfo: function(service) { service["xType"] = service["type"]; if (["backend", "frontend"].includes(service["xType"])) { if (osparc.data.model.Node.isFilePicker(service)) { @@ -429,10 +448,10 @@ qx.Class.define("osparc.store.Services", { } }, - __addExtraTypeInfos: function(servicesObj) { + __addXTypeInfos: function(servicesObj) { Object.values(servicesObj).forEach(serviceWVersion => { Object.values(serviceWVersion).forEach(service => { - this.__addExtraTypeInfo(service); + this.__addXTypeInfo(service); }); }); }, diff --git a/services/static-webserver/client/source/class/osparc/study/Utils.js b/services/static-webserver/client/source/class/osparc/study/Utils.js index f657359f6130..e482ae097fe2 100644 --- a/services/static-webserver/client/source/class/osparc/study/Utils.js +++ b/services/static-webserver/client/source/class/osparc/study/Utils.js @@ -294,7 +294,7 @@ qx.Class.define("osparc.study.Utils", { return parameters.length && probes.length; }, - getCantExecuteServices: function(studyServices = []) { + getCantReadServices: function(studyServices = []) { return studyServices.filter(studyService => studyService["myAccessRights"]["execute"] === false); }, @@ -357,7 +357,7 @@ qx.Class.define("osparc.study.Utils", { __getBlockedState: function(studyData) { if (studyData["services"]) { - const cantReadServices = osparc.study.Utils.getCantExecuteServices(studyData["services"]); + const cantReadServices = osparc.study.Utils.getCantReadServices(studyData["services"]); const inaccessibleServices = osparc.store.Services.getInaccessibleServices(studyData["workbench"]); if (cantReadServices.length || inaccessibleServices.length) { return "UNKNOWN_SERVICES"; diff --git a/services/static-webserver/client/source/class/osparc/ui/form/HoverMenuButton.js b/services/static-webserver/client/source/class/osparc/ui/form/HoverMenuButton.js deleted file mode 100644 index 837e185a89f4..000000000000 --- a/services/static-webserver/client/source/class/osparc/ui/form/HoverMenuButton.js +++ /dev/null @@ -1,67 +0,0 @@ -/* ************************************************************************ - - osparc - the simcore frontend - - https://osparc.io - - Copyright: - 2023 IT'IS Foundation, https://itis.swiss - - License: - MIT: https://opensource.org/licenses/MIT - - Authors: - * Odei Maiz (odeimaiz) - -************************************************************************ */ - -qx.Class.define("osparc.ui.form.HoverMenuButton", { - extend: qx.ui.form.MenuButton, - - construct: function(label, icon, menu) { - this.base(arguments, label, icon, menu); - - this.set({ - backgroundColor: "transparent" - }); - }, - - members: { - // overriden - _onPointerOver: function() { - this.base(arguments); - - this.open(); - }, - - // overriden - _onPointerOut: function() { - this.base(arguments); - - /* - if (this.getMenu() && this.getMenu().isVisible()) { - const menu = this.getMenu(); - this.getMenu().addListener("pointerout", e => { - if (!qx.ui.core.Widget.contains(menu, e.getRelatedTarget())) { - this.getMenu().exclude(); - } - }); - } - */ - }, - - // overriden - _applyMenu: function(menu) { - this.base(arguments, menu); - - menu.set({ - padding: 10, - backgroundColor: "background-main-1" - }); - - menu.getContentElement().setStyles({ - "border-width": "0px" - }); - } - } -});