Skip to content

Commit d3afa52

Browse files
committed
replaceIconWithThumbnail
1 parent 7db2802 commit d3afa52

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
139139
setIcon: function(menuButton, icon, resourceMetadata) {
140140
const source = icon ? icon : osparc.utils.Utils.getIconFromResource(resourceMetadata);
141141
if (source) {
142-
const thumbnail = new osparc.ui.basic.Thumbnail(source, 24, 24).set({
143-
minHeight: 24,
144-
minWidth: 24,
145-
});
146-
thumbnail.getChildControl("image").set({
147-
anonymous: true,
148-
decorator: "rounded",
149-
});
150-
// eslint-disable-next-line no-underscore-dangle
151-
menuButton._add(thumbnail, {column: 0});
142+
osparc.utils.Utils.replaceIconWithThumbnail(menuButton, source, 24);
152143
}
153144
},
154145
},

services/static-webserver/client/source/class/osparc/utils/Utils.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ qx.Class.define("osparc.utils.Utils", {
9191

9292
FLOATING_Z_INDEX: 1000001 + 1,
9393

94+
replaceIconWithThumbnail: function(widget, thumbnailUrl, size = 24) {
95+
if (thumbnailUrl) {
96+
const thumbnail = new osparc.ui.basic.Thumbnail(thumbnailUrl, size, size).set({
97+
minHeight: size,
98+
minWidth: size,
99+
});
100+
thumbnail.getChildControl("image").set({
101+
anonymous: true,
102+
decorator: "rounded",
103+
});
104+
// eslint-disable-next-line no-underscore-dangle
105+
widget._add(thumbnail, {column: 0});
106+
}
107+
},
108+
94109
disableAutocomplete: function(control) {
95110
if (control && control.getContentElement()) {
96111
control.getContentElement().setAttribute("autocomplete", "off");

0 commit comments

Comments
 (0)