Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 [Frontend] Feature: Render release notes #6734

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,48 @@ 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");
let win = null;
if (this.isNewReleaseLinkMarkdown()) {
win = osparc.ui.window.Window.popUpInWindow(newRelease, title, 800).set({
clickAwayClose: false,
resizable: true,
showClose: true,
maxHeight: 800,
});
newRelease.getMarkdown().addListener("resized", () => win.center());
} 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");
}
},

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);
},
},

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({
Expand All @@ -70,14 +108,31 @@ qx.Class.define("osparc.NewRelease", {
});
this._add(introLabel);

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);
}
const url = this.self().getReleaseNotesLink();
if (osparc.utils.Utils.isMarkdownLink(url)) {
const markdown = this.__markdown = new osparc.ui.markdown.Markdown().set({
maxWidth: 750,
});
this._add(markdown);
fetch(url)
.then(response => response.blob())
.then(blob => blob.text())
.then(text => {
markdown.setValue(text);
})
.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);
}
},

getMarkdown: function() {
return this.__markdown;
},
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading