Skip to content

Little UI improvements for Monday demo #1515

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

Merged
merged 11 commits into from
May 21, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

************************************************************************ */

/**
* @ignore(SVGElement)
*/

/**
* Widget containing the layout where NodeUIs and EdgeUIs, and when the model loaded
* is a container-node, also NodeInput and NodeOutput are rendered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

************************************************************************ */

/**
* @ignore(Headers)
* @ignore(fetch)
*/

/**
* Widget that shows all the information available regarding services.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
},

__getMoreInfoMenuButton: function(studyData, isTemplate) {
const moreInfoButton = new qx.ui.menu.Button(this.tr("Info"));
const moreInfoButton = new qx.ui.menu.Button(this.tr("More Info"));
moreInfoButton.addListener("execute", () => {
const studyDetailsEditor = this.__createStudyDetailsEditor(studyData, isTemplate);
const win = new qx.ui.window.Window(this.tr("Study Details Editor")).set({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ qx.Class.define("osparc.dashboard.StudyBrowserButtonItem", {
},

_applyStudyDescription: function(value, old) {
/*
if (value !== "" && this.getIsTemplate()) {
const label = this.getChildControl("description");
label.setValue(value);
}
*/
},

_applyLastChangeDate: function(value, old) {
Expand Down
6 changes: 3 additions & 3 deletions services/web/client/source/class/osparc/data/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ qx.Class.define("osparc.data.Permissions", {
"user": [
"studies.user.read",
"studies.user.create",
"studies.template.create",
"studies.template.update",
"studies.template.delete",
"storage.datcore.read",
"preferences.user.update",
"preferences.apikey.create",
Expand All @@ -158,6 +155,9 @@ qx.Class.define("osparc.data.Permissions", {
"study.tag"
],
"tester": [
"studies.template.create",
"studies.template.update",
"studies.template.delete",
"services.all.read",
"preferences.role.update",
"study.nodestree.uuid.read",
Expand Down
4 changes: 2 additions & 2 deletions services/web/client/source/class/osparc/file/FileTreeItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ qx.Class.define("osparc.file.FileTreeItem", {

// Add lastModified
const lastModifiedWidget = new qx.ui.basic.Label().set({
width: 120,
maxWidth: 120,
width: 140,
maxWidth: 140,
textAlign: "right"
});
let that = this;
Expand Down
12 changes: 11 additions & 1 deletion services/web/client/source/class/osparc/ui/markdown/Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,17 @@ qx.Class.define("osparc.ui.markdown.Markdown", {
*/
_applyMarkdown: function(value) {
this.__loadMarked.then(() => {
const html = marked(value);
const renderer = new marked.Renderer();
const linkRenderer = renderer.link;
renderer.link = (href, title, text) => {
const html = linkRenderer.call(renderer, href, title, text);
// eslint-disable-next-line quotes
const linkWithRightColor = html.replace(/^<a /, '<a style="color:'+ osparc.theme.Color.colors["link"] + '"');
return linkWithRightColor;
};
// eslint-disable-next-line object-curly-spacing
const html = marked(value, { renderer });

const safeHtml = osparc.wrapper.DOMPurify.getInstance().sanitize(html);
this.setHtml(safeHtml);
// for some reason the content is not immediately there
Expand Down
1 change: 1 addition & 0 deletions services/web/client/source/class/osparc/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/**
* @ignore(URL)
* @ignore(sessionStorage)
* @ignore(fetch)
*/

/**
Expand Down
17 changes: 17 additions & 0 deletions services/web/client/source/class/osparc/wrapper/DOMPurify.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/**
* @asset(DOMPurify/purify.min.js)
* @ignore(DOMPurify)
*/

/* global DOMPurify */
Expand Down Expand Up @@ -72,6 +73,22 @@ qx.Class.define("osparc.wrapper.DOMPurify", {
},

sanitize: function(html) {
// https://github.com/markedjs/marked/issues/655#issuecomment-383226346
// Add a hook to make all links open a new window
DOMPurify.addHook("afterSanitizeAttributes", function(node) {
// set all elements owning target to target=_blank
if ("target" in node) {
node.setAttribute("target", "_blank");
}
// set non-HTML/MathML links to xlink:show=new
if (
!node.hasAttribute("target") &&
(node.hasAttribute("xlink:href") || node.hasAttribute("href"))
) {
node.setAttribute("xlink:show", "new");
}
});

return DOMPurify.sanitize(html);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"project.create", # "studies.user.create",
"project.close",
"project.delete", # "study.node.create",
"project.template.create",
# "study.node.delete",
# "study.node.rename",
# "study.edge.create",
Expand All @@ -69,8 +68,11 @@
"inherits": [UserRole.GUEST, UserRole.ANONYMOUS],
},
UserRole.TESTER: {
"can": [],
"inherits": [UserRole.USER]},
"can": [
"project.template.create"
],
"inherits": [UserRole.USER]
},
}

#
Expand Down
2 changes: 1 addition & 1 deletion services/web/server/tests/unit/with_dbs/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ async def test_new_project_from_template_with_body(
[
(UserRole.ANONYMOUS, web.HTTPUnauthorized),
(UserRole.GUEST, web.HTTPForbidden),
(UserRole.USER, web.HTTPCreated),
(UserRole.USER, web.HTTPForbidden),
(UserRole.TESTER, web.HTTPCreated),
],
)
Expand Down