From 8b48e995f9dbacdeb68ca258fc0e2f74b1e1c90f Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 15 Nov 2024 14:59:41 +0100 Subject: [PATCH 1/6] refactor --- .../client/source/class/osparc/Application.js | 16 +--------------- .../client/source/class/osparc/NewRelease.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/Application.js b/services/static-webserver/client/source/class/osparc/Application.js index 0b18c01bd22..3d52cea0dec 100644 --- a/services/static-webserver/client/source/class/osparc/Application.js +++ b/services/static-webserver/client/source/class/osparc/Application.js @@ -366,7 +366,7 @@ qx.Class.define("osparc.Application", { __startupChecks: function() { // first, pop up new release window - this.__checkNewRelease(); + osparc.NewRelease.checkNewRelease(); const platformName = osparc.store.StaticInfo.getInstance().getPlatformName(); if (platformName !== "master") { @@ -375,20 +375,6 @@ qx.Class.define("osparc.Application", { } }, - __checkNewRelease: function() { - if (osparc.NewRelease.firstTimeISeeThisFrontend()) { - const newRelease = new osparc.NewRelease(); - const title = this.tr("New Release"); - const win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 350, 135).set({ - clickAwayClose: false, - resizable: false, - showClose: true - }); - const closeBtn = win.getChildControl("close-button"); - osparc.utils.Utils.setIdToWidget(closeBtn, "newReleaseCloseBtn"); - } - }, - __checkCookiesAccepted: function() { if (!osparc.CookiePolicy.areCookiesAccepted()) { const cookiePolicy = new osparc.CookiePolicy(); diff --git a/services/static-webserver/client/source/class/osparc/NewRelease.js b/services/static-webserver/client/source/class/osparc/NewRelease.js index bac9d1efb25..a3eaacc4466 100644 --- a/services/static-webserver/client/source/class/osparc/NewRelease.js +++ b/services/static-webserver/client/source/class/osparc/NewRelease.js @@ -57,7 +57,21 @@ qx.Class.define("osparc.NewRelease", { }) .catch(() => reject()); }); - } + }, + + checkNewRelease: function() { + if (osparc.NewRelease.firstTimeISeeThisFrontend()) { + const newRelease = new osparc.NewRelease(); + const title = qx.locale.Manager.tr("New Release"); + const win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 350, 135).set({ + clickAwayClose: false, + resizable: false, + showClose: true + }); + const closeBtn = win.getChildControl("close-button"); + osparc.utils.Utils.setIdToWidget(closeBtn, "newReleaseCloseBtn"); + } + }, }, members: { From 13cfcdbe059f267dd0993520b2cc43e9323094fe Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 15 Nov 2024 15:20:53 +0100 Subject: [PATCH 2/6] display release notes --- .../client/source/class/osparc/NewRelease.js | 50 ++++++++++++++----- .../source/class/osparc/info/ServiceUtils.js | 5 +- .../client/source/class/osparc/utils/Utils.js | 7 +++ 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/NewRelease.js b/services/static-webserver/client/source/class/osparc/NewRelease.js index a3eaacc4466..3417ca361a9 100644 --- a/services/static-webserver/client/source/class/osparc/NewRelease.js +++ b/services/static-webserver/client/source/class/osparc/NewRelease.js @@ -63,14 +63,28 @@ qx.Class.define("osparc.NewRelease", { if (osparc.NewRelease.firstTimeISeeThisFrontend()) { const newRelease = new osparc.NewRelease(); const title = qx.locale.Manager.tr("New Release"); - const win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 350, 135).set({ - clickAwayClose: false, - resizable: false, - showClose: true - }); + let win = null; + if (this.isNewReleaseLinkMarkdown()) { + win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 800, 600).set({ + clickAwayClose: false, + resizable: true, + showClose: true + }); + } else { + win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 350, 135).set({ + clickAwayClose: false, + resizable: false, + showClose: true + }); + } const closeBtn = win.getChildControl("close-button"); osparc.utils.Utils.setIdToWidget(closeBtn, "newReleaseCloseBtn"); - } + }, + + isNewReleaseLinkMarkdown: function() { + const rData = osparc.store.StaticInfo.getInstance().getReleaseData(); + const url = rData["url"] || osparc.utils.LibVersions.getVcsRefUrl(); + return osparc.utils.Utils.isMarkdownLink(url); }, }, @@ -86,12 +100,24 @@ qx.Class.define("osparc.NewRelease", { const rData = osparc.store.StaticInfo.getInstance().getReleaseData(); const url = rData["url"] || osparc.utils.LibVersions.getVcsRefUrl(); - const linkLabel = new osparc.ui.basic.LinkLabel().set({ - value: this.tr("What's new"), - url, - font: "link-label-14" - }); - this._add(linkLabel); + if (osparc.utils.Utils.isMarkdownLink(url)) { + const description = new osparc.ui.markdown.Markdown(); + this._add(description); + fetch(url) + .then(response => response.blob()) + .then(blob => blob.text()) + .then(markdown => { + description.setValue(markdown) + }) + .catch(err => console.error(err)); + } else { + const linkLabel = new osparc.ui.basic.LinkLabel().set({ + value: this.tr("What's new"), + url, + font: "link-label-14" + }); + this._add(linkLabel); + } } } }); diff --git a/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js b/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js index f8e87fa4ee3..058ad8bc3ae 100644 --- a/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js +++ b/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js @@ -184,10 +184,7 @@ qx.Class.define("osparc.info.ServiceUtils", { const description = new osparc.ui.markdown.Markdown(); // display markdown link content if that's the case - if ( - osparc.utils.Utils.isValidHttpUrl(serviceData["description"]) && - serviceData["description"].slice(-3) === ".md" - ) { + if (osparc.utils.Utils.isMarkdownLink(serviceData["description"])) { // if it's a link, fetch the content fetch(serviceData["description"]) .then(response => response.blob()) diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index b095d95eee2..8764dde5f2f 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -402,6 +402,13 @@ qx.Class.define("osparc.utils.Utils", { return url.protocol === "http:" || url.protocol === "https:"; }, + isMarkdownLink: function(link) { + return ( + osparc.utils.Utils.isValidHttpUrl(link) && + link.slice(-3) === ".md" + ); + }, + isDevelopmentPlatform: function() { const platformName = osparc.store.StaticInfo.getInstance().getPlatformName(); return (["dev", "master"].includes(platformName)); From abab4af1bd1934703f4ac191c28f9c56bbc4b5da Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 15 Nov 2024 15:21:26 +0100 Subject: [PATCH 3/6] minor --- .../static-webserver/client/source/class/osparc/NewRelease.js | 1 + 1 file changed, 1 insertion(+) diff --git a/services/static-webserver/client/source/class/osparc/NewRelease.js b/services/static-webserver/client/source/class/osparc/NewRelease.js index 3417ca361a9..be09cb30dda 100644 --- a/services/static-webserver/client/source/class/osparc/NewRelease.js +++ b/services/static-webserver/client/source/class/osparc/NewRelease.js @@ -79,6 +79,7 @@ qx.Class.define("osparc.NewRelease", { } const closeBtn = win.getChildControl("close-button"); osparc.utils.Utils.setIdToWidget(closeBtn, "newReleaseCloseBtn"); + } }, isNewReleaseLinkMarkdown: function() { From a5e36a7061485a877113186e7534293c6303deec Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 15 Nov 2024 15:25:22 +0100 Subject: [PATCH 4/6] refactor --- .../client/source/class/osparc/NewRelease.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/NewRelease.js b/services/static-webserver/client/source/class/osparc/NewRelease.js index be09cb30dda..72688a48fd8 100644 --- a/services/static-webserver/client/source/class/osparc/NewRelease.js +++ b/services/static-webserver/client/source/class/osparc/NewRelease.js @@ -82,9 +82,14 @@ qx.Class.define("osparc.NewRelease", { } }, - isNewReleaseLinkMarkdown: function() { + getReleaseNotesLink: function() { const rData = osparc.store.StaticInfo.getInstance().getReleaseData(); const url = rData["url"] || osparc.utils.LibVersions.getVcsRefUrl(); + return url; + }, + + isNewReleaseLinkMarkdown: function() { + const url = this.getReleaseNotesLink(); return osparc.utils.Utils.isMarkdownLink(url); }, }, @@ -99,8 +104,7 @@ qx.Class.define("osparc.NewRelease", { }); this._add(introLabel); - const rData = osparc.store.StaticInfo.getInstance().getReleaseData(); - const url = rData["url"] || osparc.utils.LibVersions.getVcsRefUrl(); + const url = this.self().getReleaseNotesLink(); if (osparc.utils.Utils.isMarkdownLink(url)) { const description = new osparc.ui.markdown.Markdown(); this._add(description); From a165d25c75cf25d4870f606f5c229ad0619f9799 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 15 Nov 2024 15:38:58 +0100 Subject: [PATCH 5/6] more reactive --- .../client/source/class/osparc/NewRelease.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/NewRelease.js b/services/static-webserver/client/source/class/osparc/NewRelease.js index 72688a48fd8..9b558699905 100644 --- a/services/static-webserver/client/source/class/osparc/NewRelease.js +++ b/services/static-webserver/client/source/class/osparc/NewRelease.js @@ -65,10 +65,14 @@ qx.Class.define("osparc.NewRelease", { const title = qx.locale.Manager.tr("New Release"); let win = null; if (this.isNewReleaseLinkMarkdown()) { - win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 800, 600).set({ + win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 800).set({ clickAwayClose: false, resizable: true, - showClose: true + showClose: true, + maxHeight: 800, + }); + newRelease.addListener("rendered", () => { + setTimeout(() => win.center(), 1000); }); } else { win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 350, 135).set({ @@ -94,6 +98,10 @@ qx.Class.define("osparc.NewRelease", { }, }, + events: { + "rendered": "qx.event.type.Event", + }, + members: { __buildLayout: function() { const introText = qx.locale.Manager.tr("We are pleased to announce that some new features were deployed for you!"); @@ -106,13 +114,16 @@ qx.Class.define("osparc.NewRelease", { const url = this.self().getReleaseNotesLink(); if (osparc.utils.Utils.isMarkdownLink(url)) { - const description = new osparc.ui.markdown.Markdown(); + const description = new osparc.ui.markdown.Markdown().set({ + maxWidth: 750, + }); this._add(description); fetch(url) .then(response => response.blob()) .then(blob => blob.text()) .then(markdown => { - description.setValue(markdown) + description.setValue(markdown); + this.fireEvent("rendered"); }) .catch(err => console.error(err)); } else { From 48e76cbd1c5bc4060c343939234e55dbe01e733b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 15 Nov 2024 15:44:18 +0100 Subject: [PATCH 6/6] center --- .../client/source/class/osparc/NewRelease.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/NewRelease.js b/services/static-webserver/client/source/class/osparc/NewRelease.js index 9b558699905..9b08fa617cf 100644 --- a/services/static-webserver/client/source/class/osparc/NewRelease.js +++ b/services/static-webserver/client/source/class/osparc/NewRelease.js @@ -71,9 +71,7 @@ qx.Class.define("osparc.NewRelease", { showClose: true, maxHeight: 800, }); - newRelease.addListener("rendered", () => { - setTimeout(() => win.center(), 1000); - }); + newRelease.getMarkdown().addListener("resized", () => win.center()); } else { win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 350, 135).set({ clickAwayClose: false, @@ -98,11 +96,9 @@ qx.Class.define("osparc.NewRelease", { }, }, - events: { - "rendered": "qx.event.type.Event", - }, - members: { + __markdown: null, + __buildLayout: function() { const introText = qx.locale.Manager.tr("We are pleased to announce that some new features were deployed for you!"); const introLabel = new qx.ui.basic.Label(introText).set({ @@ -114,16 +110,15 @@ qx.Class.define("osparc.NewRelease", { const url = this.self().getReleaseNotesLink(); if (osparc.utils.Utils.isMarkdownLink(url)) { - const description = new osparc.ui.markdown.Markdown().set({ + const markdown = this.__markdown = new osparc.ui.markdown.Markdown().set({ maxWidth: 750, }); - this._add(description); + this._add(markdown); fetch(url) .then(response => response.blob()) .then(blob => blob.text()) - .then(markdown => { - description.setValue(markdown); - this.fireEvent("rendered"); + .then(text => { + markdown.setValue(text); }) .catch(err => console.error(err)); } else { @@ -134,6 +129,10 @@ qx.Class.define("osparc.NewRelease", { }); this._add(linkLabel); } - } + }, + + getMarkdown: function() { + return this.__markdown; + }, } });