Skip to content

Commit 3d8ae69

Browse files
πŸ› [Frontend] Fix: Disabled actions in Project's menu (#7808)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 873fe78 commit 3d8ae69

File tree

10 files changed

+62
-139
lines changed

10 files changed

+62
-139
lines changed

β€Žservices/static-webserver/client/source/class/osparc/dashboard/CardBase.jsβ€Ž

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
700700
}
701701

702702
// Block card
703-
const cantReadServices = osparc.study.Utils.getCantExecuteServices(services);
703+
const cantReadServices = osparc.study.Utils.getCantReadServices(services);
704704
if (cantReadServices.length) {
705705
this.setBlocked("UNKNOWN_SERVICES");
706706
const image = "@FontAwesome5Solid/ban/";
@@ -985,8 +985,17 @@ qx.Class.define("osparc.dashboard.CardBase", {
985985
throw new Error("Abstract method called!");
986986
},
987987

988-
_applyMenu: function(value, old) {
989-
throw new Error("Abstract method called!");
988+
_applyMenu: function(menu) {
989+
const menuButton = this.getChildControl("menu-button");
990+
if (menu) {
991+
menuButton.setMenu(menu).set({
992+
appearance: "menu-wider",
993+
position: "bottom-left",
994+
});
995+
osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu");
996+
menu.addListener("appear", () => this.evaluateMenuButtons());
997+
}
998+
menuButton.setVisibility(menu ? "visible" : "excluded");
990999
},
9911000

9921001
_setStudyPermissions: function(accessRights) {

β€Žservices/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.jsβ€Ž

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,5 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
281281
}
282282
}
283283
},
284-
285-
// overridden
286-
_applyMenu: function(menu, old) {
287-
const menuButton = this.getChildControl("menu-button");
288-
if (menu) {
289-
menuButton.setMenu(menu).set({
290-
appearance: "menu-wider",
291-
position: "bottom-left",
292-
});
293-
osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu");
294-
this.evaluateMenuButtons();
295-
}
296-
menuButton.setVisibility(menu ? "visible" : "excluded");
297-
}
298284
}
299285
});

β€Žservices/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.jsβ€Ž

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,5 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
295295
});
296296
});
297297
},
298-
299-
_applyMenu: function(menu, old) {
300-
const menuButton = this.getChildControl("menu-button");
301-
if (menu) {
302-
menuButton.setMenu(menu).set({
303-
appearance: "menu-wider",
304-
position: "bottom-left",
305-
});
306-
osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu");
307-
this.evaluateMenuButtons();
308-
}
309-
menuButton.setVisibility(menu ? "visible" : "excluded");
310-
}
311298
}
312299
});

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,10 +1598,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
15981598
const duplicateStudyButton = this.__getDuplicateMenuButton(studyData);
15991599
menu.add(duplicateStudyButton);
16001600

1601-
const convertToPipelineButton = this.__getConvertToPipelineMenuButton(studyData);
1602-
menu.add(convertToPipelineButton);
1601+
if (writeAccess && osparc.product.Utils.showConvertToPipeline()) {
1602+
const convertToPipelineButton = this.__getConvertToPipelineMenuButton(studyData);
1603+
menu.add(convertToPipelineButton);
1604+
}
16031605

1604-
if (osparc.product.Utils.hasExportCMisEnabled()) {
1606+
if (osparc.product.Utils.showExportCMis()) {
16051607
const exportStudyButton = this.__getExportCMisMenuButton(studyData);
16061608
menu.add(exportStudyButton);
16071609
}

β€Žservices/static-webserver/client/source/class/osparc/metadata/ServicesInStudyUpdate.jsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ qx.Class.define("osparc.metadata.ServicesInStudyUpdate", {
6060
osparc.store.Services.getStudyServices(this._studyData["uuid"])
6161
.then(resp => {
6262
const services = resp["services"];
63-
if (osparc.study.Utils.getCantExecuteServices(services).length) {
63+
if (osparc.study.Utils.getCantReadServices(services).length) {
6464
msg += this.tr("Some services are inaccessible. Please contact the service owner:");
6565
msg += "<br><br>";
6666
}

β€Žservices/static-webserver/client/source/class/osparc/navigation/StudyTitleWOptions.jsβ€Ž

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@ qx.Class.define("osparc.navigation.StudyTitleWOptions", {
8989
});
9090
control.addListener("execute", () => this.__convertToPipelineClicked(), this);
9191
break;
92-
case "study-menu-restore":
93-
control = new qx.ui.menu.Button().set({
94-
label: this.tr("Restore"),
95-
icon: osparc.theme.common.Image.URLS["window-restore"] + "/20",
96-
});
97-
control.addListener("execute", () => {
98-
this.getStudy().getUi().setMode("workbench");
99-
});
100-
break;
10192
case "study-menu-open-logger":
10293
control = new qx.ui.menu.Button().set({
10394
label: this.tr("Platform Logs..."),
@@ -111,8 +102,9 @@ qx.Class.define("osparc.navigation.StudyTitleWOptions", {
111102
optionsMenu.add(this.getChildControl("study-menu-info"));
112103
optionsMenu.add(this.getChildControl("study-menu-reload"));
113104
optionsMenu.add(this.getChildControl("study-menu-conversations"));
114-
optionsMenu.add(this.getChildControl("study-menu-convert-to-pipeline"));
115-
optionsMenu.add(this.getChildControl("study-menu-restore"));
105+
if (osparc.product.Utils.showConvertToPipeline()) {
106+
optionsMenu.add(this.getChildControl("study-menu-convert-to-pipeline"));
107+
}
116108
optionsMenu.add(this.getChildControl("study-menu-open-logger"));
117109
control = new qx.ui.form.MenuButton().set({
118110
appearance: "fab-button",
@@ -162,15 +154,12 @@ qx.Class.define("osparc.navigation.StudyTitleWOptions", {
162154
converter: mode => mode === "standalone" ? "visible" : "excluded"
163155
});
164156

165-
const convertToPipelineButton = this.getChildControl("study-menu-convert-to-pipeline");
166-
study.getUi().bind("mode", convertToPipelineButton, "visibility", {
167-
converter: mode => mode === "standalone" ? "visible" : "excluded"
168-
});
169-
170-
const restoreButton = this.getChildControl("study-menu-restore");
171-
study.getUi().bind("mode", restoreButton, "visibility", {
172-
converter: mode => mode === "standalone" ? "visible" : "excluded"
173-
});
157+
if (osparc.product.Utils.showConvertToPipeline()) {
158+
const convertToPipelineButton = this.getChildControl("study-menu-convert-to-pipeline");
159+
study.getUi().bind("mode", convertToPipelineButton, "visibility", {
160+
converter: mode => mode === "standalone" ? "visible" : "excluded"
161+
});
162+
}
174163

175164
const loggerButton = this.getChildControl("study-menu-open-logger");
176165
study.getUi().bind("mode", loggerButton, "visibility", {

β€Žservices/static-webserver/client/source/class/osparc/product/Utils.jsβ€Ž

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ qx.Class.define("osparc.product.Utils", {
230230
},
231231

232232
// oSPARC only
233-
hasExportCMisEnabled: function() {
233+
showExportCMis: function() {
234234
const product = this.getProductName();
235235
return product === "osparc";
236236
},
@@ -307,17 +307,15 @@ qx.Class.define("osparc.product.Utils", {
307307
},
308308

309309
showQuality: function() {
310-
if (this.isProduct("osparc")) {
311-
return true;
312-
}
313-
return false;
310+
return this.isProduct("osparc");
314311
},
315312

316313
showClassifiers: function() {
317-
if (this.getProductName().includes("s4l")) {
318-
return false;
319-
}
320-
return true;
314+
return this.isProduct("osparc");
315+
},
316+
317+
showConvertToPipeline: function() {
318+
return this.isS4LProduct() || this.isProduct("osparc");
321319
},
322320

323321
showS4LStore: function() {

β€Žservices/static-webserver/client/source/class/osparc/store/Services.jsβ€Ž

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ qx.Class.define("osparc.store.Services", {
3737
const servicesObj = osparc.service.Utils.convertArrayToObject(servicesArray);
3838
this.__addHits(servicesObj);
3939
this.__addTSRInfos(servicesObj);
40-
this.__addExtraTypeInfos(servicesObj);
40+
this.__addXTypeInfos(servicesObj);
4141

4242
Object.values(servicesObj).forEach(serviceKey => {
4343
Object.values(serviceKey).forEach(service => this.__addServiceToCache(service));
@@ -128,9 +128,6 @@ qx.Class.define("osparc.store.Services", {
128128
};
129129
this.__servicesPromisesCached[key][version] = osparc.data.Resources.fetch("services", "getOne", params)
130130
.then(service => {
131-
this.__addHit(service);
132-
this.__addTSRInfo(service);
133-
this.__addExtraTypeInfo(service);
134131
this.__addServiceToCache(service);
135132
// Resolve the promise locally before deleting it
136133
resolve(service);
@@ -168,6 +165,15 @@ qx.Class.define("osparc.store.Services", {
168165
}
169166
};
170167
this.__studyServicesPromisesCached[studyId] = osparc.data.Resources.fetch("studies", "getServices", params)
168+
.then(resp => {
169+
const services = resp["services"];
170+
services.forEach(service => {
171+
// this service information is not complete, keep it in cache anyway
172+
service.version = service["release"]["version"];
173+
this.__addServiceToCache(service);
174+
});
175+
return resp;
176+
})
171177
.finally(() => {
172178
delete this.__studyServicesPromisesCached[studyId];
173179
});
@@ -368,13 +374,26 @@ qx.Class.define("osparc.store.Services", {
368374
},
369375

370376
__addServiceToCache: function(service) {
377+
this.__addHit(service);
378+
this.__addTSRInfo(service);
379+
this.__addXTypeInfo(service);
380+
371381
const key = service.key;
372382
const version = service.version;
373383
service["resourceType"] = "service";
374384
this.__addToCache(key, version, service);
375385
},
376386

377387
__addToCache: function(key, version, value) {
388+
// some services that go to the cache are not complete, e.g. study services
389+
// if the one in the cache is the complete one, do not overwrite it
390+
if (
391+
this.__isInCache(key, version) &&
392+
"inputs" in this.__servicesCached[key][version]
393+
) {
394+
return;
395+
}
396+
378397
if (!(key in this.__servicesCached)) {
379398
this.__servicesCached[key] = {};
380399
}
@@ -414,7 +433,7 @@ qx.Class.define("osparc.store.Services", {
414433
});
415434
},
416435

417-
__addExtraTypeInfo: function(service) {
436+
__addXTypeInfo: function(service) {
418437
service["xType"] = service["type"];
419438
if (["backend", "frontend"].includes(service["xType"])) {
420439
if (osparc.data.model.Node.isFilePicker(service)) {
@@ -429,10 +448,10 @@ qx.Class.define("osparc.store.Services", {
429448
}
430449
},
431450

432-
__addExtraTypeInfos: function(servicesObj) {
451+
__addXTypeInfos: function(servicesObj) {
433452
Object.values(servicesObj).forEach(serviceWVersion => {
434453
Object.values(serviceWVersion).forEach(service => {
435-
this.__addExtraTypeInfo(service);
454+
this.__addXTypeInfo(service);
436455
});
437456
});
438457
},

β€Žservices/static-webserver/client/source/class/osparc/study/Utils.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ qx.Class.define("osparc.study.Utils", {
294294
return parameters.length && probes.length;
295295
},
296296

297-
getCantExecuteServices: function(studyServices = []) {
297+
getCantReadServices: function(studyServices = []) {
298298
return studyServices.filter(studyService => studyService["myAccessRights"]["execute"] === false);
299299
},
300300

@@ -357,7 +357,7 @@ qx.Class.define("osparc.study.Utils", {
357357

358358
__getBlockedState: function(studyData) {
359359
if (studyData["services"]) {
360-
const cantReadServices = osparc.study.Utils.getCantExecuteServices(studyData["services"]);
360+
const cantReadServices = osparc.study.Utils.getCantReadServices(studyData["services"]);
361361
const inaccessibleServices = osparc.store.Services.getInaccessibleServices(studyData["workbench"]);
362362
if (cantReadServices.length || inaccessibleServices.length) {
363363
return "UNKNOWN_SERVICES";

β€Žservices/static-webserver/client/source/class/osparc/ui/form/HoverMenuButton.jsβ€Ž

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
Β (0)