Skip to content

Commit

Permalink
✨ Service deprecation: frontend (1st iteration) (#3177)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Jul 12, 2022
1 parent 44b5f4e commit e4850d2
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,28 @@ qx.Class.define("osparc.component.metadata.ServicesInStudyUpdate", {
osparc.component.message.FlashMessenger.logAs(this.tr("Some service information could not be retrieved"), "WARNING");
break;
}
const metadata = osparc.utils.Services.getMetaData(node["key"], node["version"]);
const isDeprecated = osparc.utils.Services.isDeprecated(metadata);
const updatable = node["version"] !== latestCompatibleMetadata["version"];
if (updatable) {
updatableServices.push(nodeId);
}

const currentVersionLabel = new qx.ui.basic.Label(node["version"]).set({
font: "text-14",
textColor: updatable ? "text-darker" : "text",
backgroundColor: updatable ? "warning-yellow" : null
font: "text-14"
});
if (isDeprecated) {
currentVersionLabel.set({
textColor: "contrasted-text-dark",
backgroundColor: "failed-red",
toolTipText: this.tr("Service deprecated, please update")
});
} else if (updatable) {
currentVersionLabel.set({
textColor: "contrasted-text-dark",
backgroundColor: "warning-yellow"
});
}
this._add(currentVersionLabel, {
row: i,
column: this.self().GRID_POS.CURRENT_VERSION
Expand Down
32 changes: 22 additions & 10 deletions services/web/client/source/class/osparc/dashboard/CardBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,17 +353,29 @@ qx.Class.define("osparc.dashboard.CardBase", {
}

const updateStudy = this.getChildControl("update-study");
osparc.utils.Study.isWorkbenchUpdatable(workbench)
.then(updatable => {
if (updatable) {
updateStudy.show();
updateStudy.addListener("tap", e => {
e.stopPropagation();
this.__openUpdateServices();
}, this);
updateStudy.addListener("pointerdown", e => e.stopPropagation());
}
updateStudy.addListener("pointerdown", e => e.stopPropagation());
updateStudy.addListener("tap", e => {
e.stopPropagation();
this.__openUpdateServices();
}, this);
if (osparc.utils.Study.isWorkbenchDeprecated(workbench)) {
updateStudy.show();
updateStudy.set({
toolTipText: this.tr("Service(s) deprecated, please update"),
textColor: "red"
});
} else {
osparc.utils.Study.isWorkbenchUpdatable(workbench)
.then(updatable => {
if (updatable) {
updateStudy.show();
updateStudy.set({
toolTipText: this.tr("Update available"),
textColor: "text"
});
}
});
}

osparc.utils.Study.getUnaccessibleServices(workbench)
.then(unaccessibleServices => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
const layout = this.getChildControl("tsr-mode-update-layout");
control = new qx.ui.basic.Image().set({
source: "@MaterialIcons/update/18",
toolTipText: this.tr("Update available"),
visibility: "excluded"
});
layout.add(control);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
minWidth: 20,
alignY: "middle",
source: "@MaterialIcons/update/18",
toolTipText: this.tr("Update available"),
visibility: "excluded"
});
this._add(control, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
this.addListener("changeSelection", e => {
const currentSelection = e.getData()[0];
if (currentSelection === tabPage) {
tabPage.addAt(this.__serviceVersionLayout, 0);
tabPage.addAt(this.__serviceVersionLayout, 1);
}
}, this);
}
Expand Down
8 changes: 8 additions & 0 deletions services/web/client/source/class/osparc/data/model/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ qx.Class.define("osparc.data.model.Node", {

isComputational: function(metaData) {
return (metaData && metaData.type && metaData.type === "computational");
},

isDeprecated: function(metaData) {
return osparc.utils.Services.isDeprecated(metaData);
}
},

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

isDeprecated: function() {
return osparc.data.model.Node.isDeprecated(this.getMetaData());
},

getMetaData: function() {
return this.__metaData;
},
Expand Down
22 changes: 21 additions & 1 deletion services/web/client/source/class/osparc/servicecard/Large.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ qx.Class.define("osparc.servicecard.Large", {
__rebuildLayout: function() {
this._removeAll();

const deprecated = this.__createDeprecated();
if (deprecated) {
this._add(deprecated);
}

const title = this.__createTitle();
const titleLayout = this.__createViewWithEdit(title, this.__openTitleEditor);
this._add(titleLayout);
Expand Down Expand Up @@ -174,6 +179,21 @@ qx.Class.define("osparc.servicecard.Large", {
return layout;
},

__createDeprecated: function() {
const isDeprecated = osparc.utils.Services.isDeprecated(this.getService());
if (isDeprecated) {
const chip = new osparc.ui.basic.Chip().set({
label: this.tr("Service deprecated"),
icon: "@FontAwesome5Solid/exclamation-triangle/12",
textColor: "contrasted-text-dark",
backgroundColor: "failed-red",
allowGrowX: false
});
return chip;
}
return null;
},

__createTitle: function() {
const serviceName = this.getService()["name"];
let text = "";
Expand Down Expand Up @@ -407,7 +427,7 @@ qx.Class.define("osparc.servicecard.Large", {

__openThumbnailEditor: function() {
const title = this.tr("Edit Thumbnail");
const thumbnailEditor = new osparc.component.editor.ThumbnailEditor(this.getStudy().getThumbnail());
const thumbnailEditor = new osparc.component.editor.ThumbnailEditor(this.getService()["thumbnail"]);
const win = osparc.ui.window.Window.popUpInWindow(thumbnailEditor, title, 300, 120);
thumbnailEditor.addListener("updateThumbnail", e => {
win.close();
Expand Down
9 changes: 9 additions & 0 deletions services/web/client/source/class/osparc/utils/Services.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ qx.Class.define("osparc.utils.Services", {
return null;
},

isDeprecated: function(metadata) {
if (metadata && "deprecated" in metadata && ![null, undefined].includes(metadata["deprecated"])) {
const depTime = new Date(metadata["deprecated"]);
const now = new Date();
return depTime.getTime() < now.getTime();
}
return false;
},

getFilePicker: function() {
return this.self().getLatest(this.servicesCached, "simcore/services/frontend/file-picker");
},
Expand Down
19 changes: 19 additions & 0 deletions services/web/client/source/class/osparc/utils/Study.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ qx.Class.define("osparc.utils.Study", {
});
},

isWorkbenchDeprecated: function(workbench) {
const services = new Set(this.extractServices(workbench));
const filtered = [];
services.forEach(srv => {
const idx = filtered.findIndex(flt => flt.key === srv.key && flt.version === srv.version);
if (idx === -1) {
filtered.push(srv);
}
});
const deprecated = filtered.some(srv => {
const srvMetadata = osparc.utils.Services.getMetaData(srv["key"], srv["version"]);
if (srvMetadata) {
return osparc.utils.Services.isDeprecated(srvMetadata);
}
return false;
});
return deprecated;
},

getInaccessibleServicesMsg: function(inaccessibleServices) {
let msg = qx.locale.Manager.tr("Service(s) not accessible:<br>");
inaccessibleServices.forEach(unaccessibleService => {
Expand Down

0 comments on commit e4850d2

Please sign in to comment.