Skip to content

Commit 278df26

Browse files
authored
🎨 [Frontend] Enh: Show Tags filter only in the Tutorials tab (#8320)
1 parent 479a6ab commit 278df26

File tree

4 files changed

+101
-44
lines changed

4 files changed

+101
-44
lines changed

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

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,35 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
5757
__tagButtons: null,
5858
__appTypeButtons: null,
5959

60+
_createChildControlImpl: function(id) {
61+
let control;
62+
switch (id) {
63+
case "filters-spacer":
64+
control = new qx.ui.core.Spacer(10, 10);
65+
this._add(control);
66+
break;
67+
case "shared-with-layout":
68+
control = this.__createSharedWithFilterLayout();
69+
this._add(control);
70+
break;
71+
case "app-type-layout":
72+
control = this.__createAppTypeFilterLayout();
73+
this._add(control);
74+
break;
75+
case "tags-layout": {
76+
control = this.__createTagsFilterLayout();
77+
const scrollView = new qx.ui.container.Scroll();
78+
scrollView.add(control);
79+
this._add(scrollView, {
80+
flex: 1
81+
});
82+
break;
83+
}
84+
}
85+
return control || null;
86+
},
87+
6088
__buildLayout: function() {
61-
const filtersSpacer = new qx.ui.core.Spacer(10, 10);
6289
switch (this.__resourceType) {
6390
case "study": {
6491
this._add(this.__createWorkspacesAndFoldersTree());
@@ -72,28 +99,18 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
7299
this._add(this.__createFunctions());
73100
}
74101
this._add(this.__createTrashBin());
75-
this._add(filtersSpacer);
76-
const scrollView = new qx.ui.container.Scroll();
77-
scrollView.add(this.__createTagsFilterLayout());
78-
this._add(scrollView, {
79-
flex: 1
80-
});
102+
this.getChildControl("filters-spacer");
81103
break;
82104
}
83-
case "template": {
84-
this._add(filtersSpacer);
85-
this._add(this.__createSharedWithFilterLayout());
86-
const scrollView = new qx.ui.container.Scroll();
87-
scrollView.add(this.__createTagsFilterLayout());
88-
this._add(scrollView, {
89-
flex: 1
90-
});
105+
case "template":
106+
this.getChildControl("filters-spacer");
107+
this.getChildControl("shared-with-layout");
108+
this.getChildControl("tags-layout");
91109
break;
92-
}
93110
case "service":
94-
this._add(filtersSpacer);
95-
this._add(this.__createSharedWithFilterLayout());
96-
this._add(this.__createAppTypeFilterLayout());
111+
this.getChildControl("filters-spacer");
112+
this.getChildControl("shared-with-layout");
113+
this.getChildControl("app-type-layout");
97114
break;
98115
}
99116
},
@@ -354,12 +371,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
354371
__createTagsFilterLayout: function() {
355372
const tagsLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox(2));
356373
osparc.utils.Utils.setIdToWidget(tagsLayout, this.__resourceType + "-tagsFilter");
357-
358-
this.__populateTags(tagsLayout, []);
359-
osparc.store.Tags.getInstance().addListener("tagsChanged", () => {
360-
this.__populateTags(tagsLayout, this.__getSelectedTagIds());
361-
}, this);
362-
363374
return tagsLayout;
364375
},
365376

@@ -368,11 +379,17 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
368379
return selectedTagIds;
369380
},
370381

371-
__populateTags: function(tagsLayout, selectedTagIds) {
372-
const maxTags = 5;
373-
this.__tagButtons = [];
382+
populateTags: function(presentTagIds = []) {
383+
const selectedTagIds = this.__getSelectedTagIds();
384+
const tagsLayout = this.getChildControl("tags-layout");
374385
tagsLayout.removeAll();
375-
osparc.store.Tags.getInstance().getTags().forEach((tag, idx) => {
386+
const maxTags = 10;
387+
this.__tagButtons = [];
388+
presentTagIds.forEach(tagId => {
389+
const tag = osparc.store.Tags.getInstance().getTag(tagId);
390+
if (!tag) {
391+
return;
392+
}
376393
const button = new qx.ui.form.ToggleButton(null, "@FontAwesome5Solid/tag/16");
377394
button.id = tag.getTagId();
378395
tag.bind("name", button, "label");
@@ -391,7 +408,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
391408
this.fireDataEvent("changeSelectedTags", selection);
392409
}, this);
393410

394-
button.setVisibility(idx >= maxTags ? "excluded" : "visible");
411+
button.setVisibility(this.__tagButtons.length >= maxTags ? "excluded" : "visible");
395412

396413
this.__tagButtons.push(button);
397414
});
@@ -426,6 +443,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
426443
myAccountWindow.openTags();
427444
});
428445
tagsLayout.add(editTagsButton);
446+
editTagsButton.exclude(); // excluded for now, they will be used as categories
429447

430448
if (this.__resourceType === "study") {
431449
tagsLayout.getChildren().forEach(item => item.setPaddingLeft(10)); // align them with the context

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
116116
});
117117
this.__evaluateUpdateAllButton();
118118
osparc.filter.UIFilterController.dispatch("searchBarFilter");
119+
120+
this.__populateTags();
121+
},
122+
123+
__populateTags: function() {
124+
if (this._resourceFilter) {
125+
const presentTags = new Set();
126+
this._resourcesList.forEach(template => {
127+
(template["tags"] || []).forEach(tagId => presentTags.add(tagId));
128+
});
129+
this._resourceFilter.populateTags(Array.from(presentTags));
130+
}
131+
},
132+
133+
// overridden
134+
_groupByChanged: function(groupBy) {
135+
this.base(arguments, groupBy);
136+
137+
if (this._resourceFilter) {
138+
this._resourceFilter.getChildControl("tags-layout").setVisibility(groupBy === "tags" ? "visible" : "excluded");
139+
}
119140
},
120141

121142
__itemClicked: function(card) {
@@ -143,6 +164,8 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
143164
this._addViewModeButton();
144165

145166
this._addResourceFilter();
167+
this.__populateTags();
168+
osparc.store.Tags.getInstance().addListener("tagsChanged", () => this.__populateTags(), this);
146169

147170
this._resourcesContainer.addListener("changeVisibility", () => this.__evaluateUpdateAllButton());
148171

services/static-webserver/client/source/class/osparc/data/model/Node.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -868,21 +868,35 @@ qx.Class.define("osparc.data.model.Node", {
868868
return;
869869
}
870870

871-
// create automatic port connections
872-
let autoConnections = 0;
873-
const outPorts = node1.getOutputs();
874-
const inPorts = node2.getInputs();
875-
for (const outPort in outPorts) {
876-
for (const inPort in inPorts) {
877-
if (await node2.addPortLink(inPort, node1.getNodeId(), outPort)) {
878-
autoConnections++;
879-
break;
871+
const autoConnectPorts = async () => {
872+
// create automatic port connections
873+
let autoConnections = 0;
874+
const outPorts = node1.getOutputs();
875+
const inPorts = node2.getInputs();
876+
for (const outPort in outPorts) {
877+
for (const inPort in inPorts) {
878+
if (await node2.addPortLink(inPort, node1.getNodeId(), outPort)) {
879+
autoConnections++;
880+
break;
881+
}
880882
}
881883
}
884+
if (autoConnections) {
885+
const flashMessenger = osparc.FlashMessenger.getInstance();
886+
flashMessenger.logAs(autoConnections + this.tr(" ports auto connected"), "INFO");
887+
}
882888
}
883-
if (autoConnections) {
884-
const flashMessenger = osparc.FlashMessenger.getInstance();
885-
flashMessenger.logAs(autoConnections + this.tr(" ports auto connected"), "INFO");
889+
if (node1.getMetadata() && node2.getMetadata()) {
890+
autoConnectPorts();
891+
} else {
892+
// wait for both metadata to be loaded
893+
const onMetadataChanged = () => {
894+
if (node1.getMetadata() && node2.getMetadata()) {
895+
autoConnectPorts();
896+
}
897+
};
898+
node1.addListenerOnce("changeMetadata", onMetadataChanged, this);
899+
node2.addListenerOnce("changeMetadata", onMetadataChanged, this);
886900
}
887901
},
888902

services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,10 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
328328

329329
const readAccessRole = osparc.data.Roles.ORG["read"];
330330
const newAccessRights = readAccessRole.accessRights;
331+
const orgId = this.__currentOrg.getGroupId();
332+
const userId = "id" in listedMember ? listedMember["id"] : listedMember["key"];
331333
const groupsStore = osparc.store.Groups.getInstance();
332-
groupsStore.patchMember(this.__currentOrg.getGroupId(), listedMember["id"], newAccessRights)
334+
groupsStore.patchAccessRights(orgId, userId, newAccessRights)
333335
.then(() => {
334336
osparc.FlashMessenger.logAs(this.tr(`Successfully promoted to ${readAccessRole.label}`));
335337
this.__reloadOrgMembers();
@@ -348,7 +350,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
348350
const noReadAccessRole = osparc.data.Roles.ORG["noRead"];
349351
const newAccessRights = noReadAccessRole.accessRights;
350352
const orgId = this.__currentOrg.getGroupId();
351-
const userId = "id" in listedMember ? listedMember["id"] : listedMember["key"]
353+
const userId = "id" in listedMember ? listedMember["id"] : listedMember["key"];
352354
const groupsStore = osparc.store.Groups.getInstance();
353355
groupsStore.patchAccessRights(orgId, userId, newAccessRights)
354356
.then(() => {

0 commit comments

Comments
 (0)