Skip to content

Commit 586d2b3

Browse files
committed
tutorials and services buttons
1 parent 62c9d09 commit 586d2b3

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

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

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
2929
this.__tagButtons = [];
3030
this.__serviceTypeButtons = [];
3131

32-
this._setLayout(new qx.ui.layout.VBox(20));
32+
this._setLayout(new qx.ui.layout.VBox(5));
3333
this.__buildLayout();
3434
},
3535

3636
events: {
3737
"trashContext": "qx.event.type.Event",
38+
"templatesContext": "qx.event.type.Event",
39+
"servicesContext": "qx.event.type.Event",
3840
"trashStudyRequested": "qx.event.type.Data",
3941
"trashFolderRequested": "qx.event.type.Data",
4042
"changeSharedWith": "qx.event.type.Data",
@@ -46,14 +48,26 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
4648
__resourceType: null,
4749
__workspacesAndFoldersTree: null,
4850
__trashButton: null,
51+
__templatesButton: null,
52+
__servicesButton: null,
4953
__sharedWithButtons: null,
5054
__tagButtons: null,
5155
__serviceTypeButtons: null,
5256

5357
__buildLayout: function() {
58+
const permissions = osparc.data.Permissions.getInstance();
59+
5460
if (this.__resourceType === "study") {
5561
this._add(this.__createWorkspacesAndFoldersTree());
5662
this._add(this.__createTrashBin());
63+
const templates = this.__createTemplates();
64+
if (permissions.canDo("dashboard.templates.read")) {
65+
this._add(templates);
66+
}
67+
const services = this.__createServices();
68+
if (permissions.canDo("dashboard.services.read")) {
69+
this._add(services);
70+
}
5771
} else {
5872
this._add(this.__createSharedWithFilterLayout());
5973
}
@@ -75,6 +89,8 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
7589
this.__workspacesAndFoldersTree.contextChanged(context);
7690

7791
this.__trashButton.setValue(context === "trash");
92+
this.__templatesButton.setValue(context === "templates");
93+
this.__servicesButton.setValue(context === "services");
7894
},
7995

8096
/* WORKSPACES AND FOLDERS */
@@ -203,6 +219,46 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
203219
},
204220
/* /TRASH BIN */
205221

222+
__createTemplates: function() {
223+
const templateAlias = osparc.product.Utils.getTemplateAlias({
224+
firstUpperCase: true,
225+
plural: true
226+
});
227+
const templatesButton = this.__templatesButton = new qx.ui.toolbar.RadioButton().set({
228+
value: false,
229+
appearance: "filter-toggle-button",
230+
label: templateAlias,
231+
icon: "@FontAwesome5Solid/copy/16",
232+
paddingLeft: 10, // align it with the context
233+
});
234+
osparc.utils.Utils.setIdToWidget(templatesButton, "templatesTabBtn");
235+
templatesButton.addListener("changeValue", e => {
236+
const trashEnabled = e.getData();
237+
if (trashEnabled) {
238+
this.fireEvent("templatesContext");
239+
}
240+
});
241+
return templatesButton;
242+
},
243+
244+
__createServices: function() {
245+
const servicesButton = this.__servicesButton = new qx.ui.toolbar.RadioButton().set({
246+
value: false,
247+
appearance: "filter-toggle-button",
248+
label: this.tr("Services"),
249+
icon: "@FontAwesome5Solid/cogs/16",
250+
paddingLeft: 10, // align it with the context
251+
});
252+
osparc.utils.Utils.setIdToWidget(servicesButton, "servicesTabBtn");
253+
servicesButton.addListener("changeValue", e => {
254+
const trashEnabled = e.getData();
255+
if (trashEnabled) {
256+
this.fireEvent("servicesContext");
257+
}
258+
});
259+
return servicesButton;
260+
},
261+
206262
/* SHARED WITH */
207263
__createSharedWithFilterLayout: function() {
208264
const sharedWithLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));

0 commit comments

Comments
 (0)