Skip to content

Commit 19a64fb

Browse files
authored
✨ [Frontend] Search Templates and Search Public Projects (#8013)
1 parent 0136ef5 commit 19a64fb

18 files changed

+322
-196
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ qx.Class.define("osparc.dashboard.AppBrowser", {
129129
this._populateCardMenu(card);
130130
});
131131
osparc.filter.UIFilterController.dispatch("searchBarFilter");
132-
133-
this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this._resourceType);
134132
},
135133

136134
__itemClicked: function(card) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
508508
const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext();
509509
return (
510510
this.getBlocked() === true || // It could be blocked by IN_USE or UNKNOWN_SERVICE
511-
(this.isResourceType("study") && (studyBrowserContext === "trash")) // It could a trashed study
511+
(this.isResourceType("study") && (studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.TRASH)) // It could a trashed study
512512
);
513513
},
514514

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ qx.Class.define("osparc.dashboard.CardContainer", {
105105
},
106106

107107
areMoreResourcesRequired: function(loadingResourcesBtn) {
108-
if (this.nextRequest !== null && loadingResourcesBtn && osparc.utils.Utils.isWidgetOnScreen(loadingResourcesBtn)) {
108+
if (
109+
this.nextRequest !== null &&
110+
loadingResourcesBtn &&
111+
osparc.utils.Utils.isWidgetOnScreen(loadingResourcesBtn)
112+
) {
109113
return true;
110114
}
111115
return false;

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,16 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", {
5555
this._removeAll();
5656

5757
const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext();
58-
if (currentContext !== "studiesAndFolders") {
59-
return;
60-
}
61-
62-
if (this.getCurrentFolderId()) {
63-
const currentFolder = osparc.store.Folders.getInstance().getFolder(this.getCurrentFolderId());
64-
this.__createUpstreamButtons(currentFolder);
65-
}
58+
if (currentContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS) {
59+
if (this.getCurrentFolderId()) {
60+
const currentFolder = osparc.store.Folders.getInstance().getFolder(this.getCurrentFolderId());
61+
this.__createUpstreamButtons(currentFolder);
62+
}
6663

67-
const currentFolderButton = this.__createCurrentFolderButton();
68-
if (currentFolderButton) {
69-
this._add(currentFolderButton);
64+
const currentFolderButton = this.__createCurrentFolderButton();
65+
if (currentFolderButton) {
66+
this._add(currentFolderButton);
67+
}
7068
}
7169
},
7270

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,19 +276,19 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
276276

277277
const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext();
278278
if (
279-
studyBrowserContext === "search" ||
280-
studyBrowserContext === "studiesAndFolders"
279+
studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS ||
280+
studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS
281281
) {
282282
const editButton = new qx.ui.menu.Button(this.tr("Rename..."), "@FontAwesome5Solid/pencil-alt/12");
283283
editButton.addListener("execute", () => this.__editFolder(), this);
284284
menu.add(editButton);
285285

286-
if (studyBrowserContext === "search") {
286+
if (studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS) {
287287
const openLocationButton = new qx.ui.menu.Button(this.tr("Open location"), "@FontAwesome5Solid/external-link-alt/12");
288288
openLocationButton.addListener("execute", () => {
289289
const folder = this.getFolder();
290290
this.fireDataEvent("changeContext", {
291-
context: "studiesAndFolders",
291+
context: osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS,
292292
workspaceId: folder.getWorkspaceId(),
293293
folderId: folder.getParentFolderId(),
294294
});
@@ -306,7 +306,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
306306
const trashButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
307307
trashButton.addListener("execute", () => this.fireDataEvent("trashFolderRequested", this.getFolderId()), this);
308308
menu.add(trashButton);
309-
} else if (studyBrowserContext === "trash") {
309+
} else if (studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.TRASH) {
310310
const restoreButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16");
311311
restoreButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolder()), this);
312312
menu.add(restoreButton);
@@ -325,7 +325,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
325325
__itemSelected: function() {
326326
const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext();
327327
// do not allow selecting workspace
328-
if (studyBrowserContext !== "trash") {
328+
if (studyBrowserContext !== osparc.dashboard.StudyBrowser.CONTEXT.TRASH) {
329329
this.fireDataEvent("folderSelected", this.getFolderId());
330330
}
331331
},

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
3535

3636
events: {
3737
"templatesContext": "qx.event.type.Event",
38-
"publicContext": "qx.event.type.Event",
38+
"publicTemplatesContext": "qx.event.type.Event",
3939
"trashContext": "qx.event.type.Event",
4040
"changeTab": "qx.event.type.Data",
4141
"trashStudyRequested": "qx.event.type.Data",
@@ -100,9 +100,9 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
100100
});
101101
this.__workspacesAndFoldersTree.contextChanged(context);
102102

103-
this.__templatesButton.setValue(context === "templates");
104-
this.__publicProjectsButton.setValue(context === "public");
105-
this.__trashButton.setValue(context === "trash");
103+
this.__templatesButton.setValue(context === osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES);
104+
this.__publicProjectsButton.setValue(context === osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES);
105+
this.__trashButton.setValue(context === osparc.dashboard.StudyBrowser.CONTEXT.TRASH);
106106
},
107107

108108
/* WORKSPACES AND FOLDERS */
@@ -158,7 +158,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
158158
publicProjectsButton.addListener("changeValue", e => {
159159
const templatesEnabled = e.getData();
160160
if (templatesEnabled) {
161-
this.fireEvent("publicContext");
161+
this.fireEvent("publicTemplatesContext");
162162
}
163163
});
164164
return publicProjectsButton;

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

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
3131
this.__foldersList = [];
3232
this.__resourcesList = [];
3333
this.__groupedContainersList = [];
34+
this.__resourceType = resourceType || "study";
3435

3536
if (resourceType === "study") {
3637
const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.CardContainer();
@@ -135,35 +136,57 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
135136
__groupedContainersList: null,
136137
__foldersContainer: null,
137138
__workspacesContainer: null,
138-
__noResourcesFound: null,
139139
__nonGroupedContainer: null,
140140
__groupedContainers: null,
141-
142-
evaluateNoResourcesFoundLabel: function(cards, context) {
143-
if (this.__noResourcesFound) {
144-
let text = null;
145-
switch (context) {
146-
case "studiesAndFolders":
147-
case "search":
148-
text = this.tr("No Projects found");
149-
break;
150-
case "templates":
151-
text = this.tr("No Templates found");
152-
break;
153-
case "public":
154-
text = this.tr("No Public Projects found");
155-
break;
156-
case "template":
157-
text = this.tr("No Tutorials found");
158-
break;
159-
case "service":
160-
text = this.tr("No Apps found");
161-
break;
141+
__resourceType: null,
142+
__noResourcesFound: null,
143+
__noResourcesFoundTimer: null,
144+
145+
__evaluateNoResourcesFoundLabel: function() {
146+
let text = null;
147+
switch (this.__resourceType) {
148+
case "study": {
149+
const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext();
150+
switch (studyBrowserContext) {
151+
case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS:
152+
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS:
153+
case osparc.dashboard.StudyBrowser.CONTEXT.TRASH:
154+
text = this.tr("No Projects found");
155+
break;
156+
case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES:
157+
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES:
158+
text = this.tr("No Templates found");
159+
break;
160+
case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES:
161+
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES:
162+
text = this.tr("No Public Projects found");
163+
break;
164+
}
165+
break;
162166
}
163-
this.__noResourcesFound.set({
164-
value: text,
165-
visibility: text && cards.length === 0 ? "visible" : "excluded",
166-
});
167+
case "template":
168+
text = this.tr("No Tutorials found");
169+
break;
170+
case "service":
171+
text = this.tr("No Apps found");
172+
break;
173+
default:
174+
text = this.tr("No Resources found");
175+
break;
176+
}
177+
178+
this.__noResourcesFound.exclude();
179+
if (this.__noResourcesFoundTimer) {
180+
clearTimeout(this.__noResourcesFoundTimer);
181+
}
182+
if (text && this.__resourcesList.length === 0) {
183+
// delay it a bit to avoid the initial flickering
184+
this.__noResourcesFoundTimer = setTimeout(() => {
185+
this.__noResourcesFound.set({
186+
value: text,
187+
visibility: "visible",
188+
});
189+
}, 2000);
167190
}
168191
},
169192

@@ -307,6 +330,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
307330

308331
setResourcesToList: function(resourcesList) {
309332
this.__resourcesList = resourcesList;
333+
334+
this.__evaluateNoResourcesFoundLabel();
310335
},
311336

312337
__cleanAll: function() {

0 commit comments

Comments
 (0)