Skip to content

Commit e4850d2

Browse files
authored
✨ Service deprecation: frontend (1st iteration) (ITISFoundation#3177)
1 parent 44b5f4e commit e4850d2

File tree

9 files changed

+95
-17
lines changed

9 files changed

+95
-17
lines changed

services/web/client/source/class/osparc/component/metadata/ServicesInStudyUpdate.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,28 @@ qx.Class.define("osparc.component.metadata.ServicesInStudyUpdate", {
100100
osparc.component.message.FlashMessenger.logAs(this.tr("Some service information could not be retrieved"), "WARNING");
101101
break;
102102
}
103+
const metadata = osparc.utils.Services.getMetaData(node["key"], node["version"]);
104+
const isDeprecated = osparc.utils.Services.isDeprecated(metadata);
103105
const updatable = node["version"] !== latestCompatibleMetadata["version"];
104106
if (updatable) {
105107
updatableServices.push(nodeId);
106108
}
107109

108110
const currentVersionLabel = new qx.ui.basic.Label(node["version"]).set({
109-
font: "text-14",
110-
textColor: updatable ? "text-darker" : "text",
111-
backgroundColor: updatable ? "warning-yellow" : null
111+
font: "text-14"
112112
});
113+
if (isDeprecated) {
114+
currentVersionLabel.set({
115+
textColor: "contrasted-text-dark",
116+
backgroundColor: "failed-red",
117+
toolTipText: this.tr("Service deprecated, please update")
118+
});
119+
} else if (updatable) {
120+
currentVersionLabel.set({
121+
textColor: "contrasted-text-dark",
122+
backgroundColor: "warning-yellow"
123+
});
124+
}
113125
this._add(currentVersionLabel, {
114126
row: i,
115127
column: this.self().GRID_POS.CURRENT_VERSION

services/web/client/source/class/osparc/dashboard/CardBase.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,29 @@ qx.Class.define("osparc.dashboard.CardBase", {
353353
}
354354

355355
const updateStudy = this.getChildControl("update-study");
356-
osparc.utils.Study.isWorkbenchUpdatable(workbench)
357-
.then(updatable => {
358-
if (updatable) {
359-
updateStudy.show();
360-
updateStudy.addListener("tap", e => {
361-
e.stopPropagation();
362-
this.__openUpdateServices();
363-
}, this);
364-
updateStudy.addListener("pointerdown", e => e.stopPropagation());
365-
}
356+
updateStudy.addListener("pointerdown", e => e.stopPropagation());
357+
updateStudy.addListener("tap", e => {
358+
e.stopPropagation();
359+
this.__openUpdateServices();
360+
}, this);
361+
if (osparc.utils.Study.isWorkbenchDeprecated(workbench)) {
362+
updateStudy.show();
363+
updateStudy.set({
364+
toolTipText: this.tr("Service(s) deprecated, please update"),
365+
textColor: "red"
366366
});
367+
} else {
368+
osparc.utils.Study.isWorkbenchUpdatable(workbench)
369+
.then(updatable => {
370+
if (updatable) {
371+
updateStudy.show();
372+
updateStudy.set({
373+
toolTipText: this.tr("Update available"),
374+
textColor: "text"
375+
});
376+
}
377+
});
378+
}
367379

368380
osparc.utils.Study.getUnaccessibleServices(workbench)
369381
.then(unaccessibleServices => {

services/web/client/source/class/osparc/dashboard/GridButtonItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
7070
const layout = this.getChildControl("tsr-mode-update-layout");
7171
control = new qx.ui.basic.Image().set({
7272
source: "@MaterialIcons/update/18",
73-
toolTipText: this.tr("Update available"),
7473
visibility: "excluded"
7574
});
7675
layout.add(control);

services/web/client/source/class/osparc/dashboard/ListButtonItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
138138
minWidth: 20,
139139
alignY: "middle",
140140
source: "@MaterialIcons/update/18",
141-
toolTipText: this.tr("Update available"),
142141
visibility: "excluded"
143142
});
144143
this._add(control, {

services/web/client/source/class/osparc/dashboard/ResourceMoreOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
187187
this.addListener("changeSelection", e => {
188188
const currentSelection = e.getData()[0];
189189
if (currentSelection === tabPage) {
190-
tabPage.addAt(this.__serviceVersionLayout, 0);
190+
tabPage.addAt(this.__serviceVersionLayout, 1);
191191
}
192192
}, this);
193193
}

services/web/client/source/class/osparc/data/model/Node.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ qx.Class.define("osparc.data.model.Node", {
259259

260260
isComputational: function(metaData) {
261261
return (metaData && metaData.type && metaData.type === "computational");
262+
},
263+
264+
isDeprecated: function(metaData) {
265+
return osparc.utils.Services.isDeprecated(metaData);
262266
}
263267
},
264268

@@ -311,6 +315,10 @@ qx.Class.define("osparc.data.model.Node", {
311315
return osparc.data.model.Node.isComputational(this.getMetaData());
312316
},
313317

318+
isDeprecated: function() {
319+
return osparc.data.model.Node.isDeprecated(this.getMetaData());
320+
},
321+
314322
getMetaData: function() {
315323
return this.__metaData;
316324
},

services/web/client/source/class/osparc/servicecard/Large.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ qx.Class.define("osparc.servicecard.Large", {
110110
__rebuildLayout: function() {
111111
this._removeAll();
112112

113+
const deprecated = this.__createDeprecated();
114+
if (deprecated) {
115+
this._add(deprecated);
116+
}
117+
113118
const title = this.__createTitle();
114119
const titleLayout = this.__createViewWithEdit(title, this.__openTitleEditor);
115120
this._add(titleLayout);
@@ -174,6 +179,21 @@ qx.Class.define("osparc.servicecard.Large", {
174179
return layout;
175180
},
176181

182+
__createDeprecated: function() {
183+
const isDeprecated = osparc.utils.Services.isDeprecated(this.getService());
184+
if (isDeprecated) {
185+
const chip = new osparc.ui.basic.Chip().set({
186+
label: this.tr("Service deprecated"),
187+
icon: "@FontAwesome5Solid/exclamation-triangle/12",
188+
textColor: "contrasted-text-dark",
189+
backgroundColor: "failed-red",
190+
allowGrowX: false
191+
});
192+
return chip;
193+
}
194+
return null;
195+
},
196+
177197
__createTitle: function() {
178198
const serviceName = this.getService()["name"];
179199
let text = "";
@@ -407,7 +427,7 @@ qx.Class.define("osparc.servicecard.Large", {
407427

408428
__openThumbnailEditor: function() {
409429
const title = this.tr("Edit Thumbnail");
410-
const thumbnailEditor = new osparc.component.editor.ThumbnailEditor(this.getStudy().getThumbnail());
430+
const thumbnailEditor = new osparc.component.editor.ThumbnailEditor(this.getService()["thumbnail"]);
411431
const win = osparc.ui.window.Window.popUpInWindow(thumbnailEditor, title, 300, 120);
412432
thumbnailEditor.addListener("updateThumbnail", e => {
413433
win.close();

services/web/client/source/class/osparc/utils/Services.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ qx.Class.define("osparc.utils.Services", {
279279
return null;
280280
},
281281

282+
isDeprecated: function(metadata) {
283+
if (metadata && "deprecated" in metadata && ![null, undefined].includes(metadata["deprecated"])) {
284+
const depTime = new Date(metadata["deprecated"]);
285+
const now = new Date();
286+
return depTime.getTime() < now.getTime();
287+
}
288+
return false;
289+
},
290+
282291
getFilePicker: function() {
283292
return this.self().getLatest(this.servicesCached, "simcore/services/frontend/file-picker");
284293
},

services/web/client/source/class/osparc/utils/Study.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,25 @@ qx.Class.define("osparc.utils.Study", {
7777
});
7878
},
7979

80+
isWorkbenchDeprecated: function(workbench) {
81+
const services = new Set(this.extractServices(workbench));
82+
const filtered = [];
83+
services.forEach(srv => {
84+
const idx = filtered.findIndex(flt => flt.key === srv.key && flt.version === srv.version);
85+
if (idx === -1) {
86+
filtered.push(srv);
87+
}
88+
});
89+
const deprecated = filtered.some(srv => {
90+
const srvMetadata = osparc.utils.Services.getMetaData(srv["key"], srv["version"]);
91+
if (srvMetadata) {
92+
return osparc.utils.Services.isDeprecated(srvMetadata);
93+
}
94+
return false;
95+
});
96+
return deprecated;
97+
},
98+
8099
getInaccessibleServicesMsg: function(inaccessibleServices) {
81100
let msg = qx.locale.Manager.tr("Service(s) not accessible:<br>");
82101
inaccessibleServices.forEach(unaccessibleService => {

0 commit comments

Comments
 (0)