Skip to content

Commit e0f204c

Browse files
authored
🐛 [Frontend] Fix: Service catalog listing (#7559)
1 parent 96bf18b commit e0f204c

File tree

4 files changed

+12
-76
lines changed

4 files changed

+12
-76
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,15 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
260260
}
261261
},
262262

263-
__addFromResourceButton: function(menuButton, category) {
264-
let idx = null;
263+
__addFromResourceButton: function(menuButton, category, idx = null) {
265264
if (category) {
266265
idx = this.__getLastIdxFromCategory(category);
267266
}
268-
if (idx) {
267+
if (category && idx) {
269268
menuButton["categoryId"] = category;
270269
this.addAt(menuButton, idx+1);
270+
} else if (idx) {
271+
this.addAt(menuButton, idx);
271272
} else {
272273
this.addAt(menuButton, this.__itemIdx);
273274
this.__itemIdx++;
@@ -369,9 +370,12 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
369370
addListenerToButton(menuButton, latestMetadata);
370371
} else if ("myMostUsed" in buttonConfig) {
371372
const excludeFrontend = true;
372-
const excludeDeprecated = true
373+
const excludeDeprecated = true;
374+
const old = this.__itemIdx;
375+
this.__itemIdx += buttonConfig["myMostUsed"];
373376
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
374-
.then(servicesList => {
377+
.then(srvList => {
378+
const servicesList = srvList.filter(srv => srv !== null);
375379
osparc.service.Utils.sortObjectsBasedOn(servicesList, {
376380
"sort": "hits",
377381
"order": "down"
@@ -385,7 +389,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
385389
allowGrowX: true,
386390
});
387391
this.__addIcon(menuButton, null, latestMetadata);
388-
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
392+
this.__addFromResourceButton(menuButton, buttonConfig["category"], old+i);
389393
addListenerToButton(menuButton, latestMetadata);
390394
}
391395
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
6666
const excludeFrontend = true;
6767
const excludeDeprecated = true
6868
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
69-
.then(servicesList => this.__setServicesToList(servicesList));
69+
.then(servicesList => this.__setServicesToList(servicesList.filter(service => service !== null)));
7070
},
7171

7272
_updateServiceData: function(serviceData) {

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

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -888,78 +888,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
888888
// this one is different since it groups all new buttons in one new button
889889
this.__addTIPPlusButton();
890890
break;
891-
default:
892-
this.__addPlusButtons();
893-
break;
894891
}
895892
}
896893
},
897894

898-
__addPlusButtons: function() {
899-
const plusButtonConfig = osparc.store.Products.getInstance().getNewStudiesUiConfig();
900-
if (plusButtonConfig) {
901-
plusButtonConfig["resources"].forEach(newStudyData => {
902-
if (newStudyData["resourceType"] === "study") {
903-
this.__addEmptyStudyPlusButton(newStudyData);
904-
} else if (newStudyData["resourceType"] === "service") {
905-
this.__addNewStudyFromServiceButton(newStudyData);
906-
}
907-
});
908-
}
909-
},
910-
911-
__addEmptyStudyPlusButton: function(newStudyData) {
912-
const mode = this._resourcesContainer.getMode();
913-
const defTitle = this.tr("Empty") + " " + osparc.product.Utils.getStudyAlias({
914-
firstUpperCase: true
915-
});
916-
const title = newStudyData["title"] || defTitle;
917-
const desc = newStudyData["description"] || this.tr("Start with an empty study");
918-
const newEmptyStudyBtn = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title, desc) : new osparc.dashboard.ListButtonNew(title, desc);
919-
newEmptyStudyBtn.setCardKey("new-study");
920-
newEmptyStudyBtn.subscribeToFilterGroup("searchBarFilter");
921-
osparc.utils.Utils.setIdToWidget(newEmptyStudyBtn, newStudyData["idToWidget"]);
922-
newEmptyStudyBtn.addListener("tap", () => this.__newEmptyStudyBtnClicked(newStudyData["newStudyLabel"]));
923-
this._resourcesContainer.addNonResourceCard(newEmptyStudyBtn);
924-
},
925-
926-
__addNewStudyFromServiceButton: function(newStudyData) {
927-
if ("expectedKey" in newStudyData) {
928-
const key = newStudyData["expectedKey"];
929-
const latestMetadata = osparc.store.Services.getLatest(key);
930-
if (!latestMetadata) {
931-
return;
932-
}
933-
const title = newStudyData.title + " " + osparc.service.Utils.extractVersionDisplay(latestMetadata);
934-
const desc = newStudyData.description;
935-
const mode = this._resourcesContainer.getMode();
936-
const newStudyFromServiceButton = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title, desc) : new osparc.dashboard.ListButtonNew(title, desc);
937-
newStudyFromServiceButton.setCardKey("new-"+key);
938-
if (newStudyData["idToWidget"]) {
939-
osparc.utils.Utils.setIdToWidget(newStudyFromServiceButton, newStudyData["idToWidget"]);
940-
}
941-
newStudyFromServiceButton.addListener("tap", () => this.__newStudyFromServiceBtnClicked(latestMetadata["key"], latestMetadata["version"], newStudyData.newStudyLabel));
942-
this._resourcesContainer.addNonResourceCard(newStudyFromServiceButton);
943-
} else if ("myMostUsed" in newStudyData) {
944-
const excludeFrontend = true;
945-
const excludeDeprecated = true
946-
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
947-
.then(servicesList => {
948-
osparc.service.Utils.sortObjectsBasedOn(servicesList, {
949-
"sort": "hits",
950-
"order": "down"
951-
});
952-
for (let i=0; i<newStudyData["myMostUsed"]; i++) {
953-
const latestMetadata = servicesList[i];
954-
const mode = this._resourcesContainer.getMode();
955-
const newStudyFromServiceButton = (mode === "grid") ? new osparc.dashboard.GridButtonNew(latestMetadata["name"]) : new osparc.dashboard.ListButtonNew(latestMetadata["name"]);
956-
newStudyFromServiceButton.addListener("tap", () => this.__newStudyFromServiceBtnClicked(latestMetadata["key"], latestMetadata["version"], latestMetadata["name"]));
957-
this._resourcesContainer.addNonResourceCard(newStudyFromServiceButton);
958-
}
959-
});
960-
}
961-
},
962-
963895
__addTIPPlusButton: function() {
964896
const mode = this._resourcesContainer.getMode();
965897
const title = this.tr("New Plan");

services/static-webserver/client/source/class/osparc/workbench/ServiceCatalog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ qx.Class.define("osparc.workbench.ServiceCatalog", {
201201
const excludeDeprecated = true;
202202
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
203203
.then(servicesList => {
204-
this.__servicesLatest = servicesList;
204+
this.__servicesLatest = servicesList.filter(service => service !== null);
205205
this.__updateList();
206206
});
207207
},

0 commit comments

Comments
 (0)