From 4633a3be833b2f8305ad8a39a89b6eaca8fbfd19 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 16:09:22 +0200 Subject: [PATCH 1/6] refactoring --- .../osparc/component/share/Collaborators.js | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js b/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js index b6e79f06936..8217c2dbe95 100644 --- a/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js @@ -70,6 +70,80 @@ qx.Class.define("osparc.component.share.Collaborators", { } } return sorted; + }, + + createStudyLinkSection: function(serializedData) { + const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)); + + const label = new qx.ui.basic.Label().set({ + value: qx.locale.Manager.tr("Any logged-in user with access to the ") + osparc.product.Utils.getStudyAlias() + qx.locale.Manager.tr(" can open it"), + rich: true + }); + vBox.add(label); + + const hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ + alignY: "middle" + })); + vBox.add(hBox, { + flex: 1 + }); + + const link = window.location.href + "#/study/" + serializedData["uuid"]; + const linkField = new qx.ui.form.TextField(link); + hBox.add(linkField, { + flex: 1 + }); + + const copyLinkBtn = new qx.ui.form.Button(qx.locale.Manager.tr("Copy link")); + copyLinkBtn.addListener("execute", () => { + if (osparc.utils.Utils.copyTextToClipboard(link)) { + copyLinkBtn.setIcon("@FontAwesome5Solid/check/12"); + } + }); + hBox.add(copyLinkBtn); + + return vBox; + }, + + createTemplateLinkSection: function(serializedData) { + const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)); + + if ("permalink" in serializedData) { + const permalink = serializedData["permalink"]; + + const label = new qx.ui.basic.Label().set({ + rich: true + }); + if (permalink["is_public"]) { + label.setValue(qx.locale.Manager.tr("Anyone on the internet with the link can open this ") + osparc.product.Utils.getTemplateAlias()); + } else { + label.setValue(qx.locale.Manager.tr("Any logged-in user with the link can copy and open this ") + osparc.product.Utils.getTemplateAlias()); + } + vBox.add(label); + + const hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ + alignY: "middle" + })); + vBox.add(hBox, { + flex: 1 + }); + + const link = permalink["url"]; + const linkField = new qx.ui.form.TextField(link); + hBox.add(linkField, { + flex: 1 + }); + + const copyLinkBtn = new qx.ui.form.Button(qx.locale.Manager.tr("Copy link")); + copyLinkBtn.addListener("execute", () => { + if (osparc.utils.Utils.copyTextToClipboard(link)) { + copyLinkBtn.setIcon("@FontAwesome5Solid/check/12"); + } + }); + hBox.add(copyLinkBtn); + } + + return vBox; } }, @@ -105,13 +179,13 @@ qx.Class.define("osparc.component.share.Collaborators", { }); break; case "study-link": - control = this.__createStudyLinkSection(); + control = this.self().createStudyLinkSection(this._serializedData); this._add(control); // excluded by default control.exclude(); break; case "template-link": - control = this.__createTemplateLinkSection(); + control = this.self().createTemplateLinkSection(this._serializedData); this._add(control); // excluded by default control.exclude(); @@ -218,80 +292,6 @@ qx.Class.define("osparc.component.share.Collaborators", { return vBox; }, - __createStudyLinkSection: function() { - const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)); - - const label = new qx.ui.basic.Label().set({ - value: this.tr("Any logged-in user with access to the ") + osparc.product.Utils.getStudyAlias() + this.tr(" can open it"), - rich: true - }); - vBox.add(label); - - const hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ - alignY: "middle" - })); - vBox.add(hBox, { - flex: 1 - }); - - const link = window.location.href + "#/study/" + this._serializedData["uuid"]; - const linkField = new qx.ui.form.TextField(link); - hBox.add(linkField, { - flex: 1 - }); - - const copyLinkBtn = new qx.ui.form.Button(this.tr("Copy link")); - copyLinkBtn.addListener("execute", () => { - if (osparc.utils.Utils.copyTextToClipboard(link)) { - copyLinkBtn.setIcon("@FontAwesome5Solid/check/12"); - } - }, this); - hBox.add(copyLinkBtn); - - return vBox; - }, - - __createTemplateLinkSection: function() { - const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)); - - if ("permalink" in this._serializedData) { - const permalink = this._serializedData["permalink"]; - - const label = new qx.ui.basic.Label().set({ - rich: true - }); - if (permalink["is_public"]) { - label.setValue(this.tr("Anyone on the internet with the link can open this ") + osparc.product.Utils.getTemplateAlias()); - } else { - label.setValue(this.tr("Any logged-in user with the link can copy and open this ") + osparc.product.Utils.getTemplateAlias()); - } - vBox.add(label); - - const hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ - alignY: "middle" - })); - vBox.add(hBox, { - flex: 1 - }); - - const link = permalink["url"]; - const linkField = new qx.ui.form.TextField(link); - hBox.add(linkField, { - flex: 1 - }); - - const copyLinkBtn = new qx.ui.form.Button(this.tr("Copy link")); - copyLinkBtn.addListener("execute", () => { - if (osparc.utils.Utils.copyTextToClipboard(link)) { - copyLinkBtn.setIcon("@FontAwesome5Solid/check/12"); - } - }, this); - hBox.add(copyLinkBtn); - } - - return vBox; - }, - __getCollaborators: function() { osparc.store.Store.getInstance().getPotentialCollaborators() .then(potentialCollaborators => { From aa0ad3a3e814721c7029b76e2bfa34a0c4fe8a50 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 16:41:21 +0200 Subject: [PATCH 2/6] study and template permalink sections also on Info --- .../client/source/class/osparc/info/StudyLarge.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js index 4304ea5d686..aa986c82b2c 100644 --- a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js @@ -124,6 +124,19 @@ qx.Class.define("osparc.info.StudyLarge", { description.addAt(editInTitle, 0); this._add(description); } + + this._add(new qx.ui.core.Spacer(), { + flex: 1 + }); + + const resourceData = this.getStudy().serialize(); + if (osparc.utils.Resources.isStudy(resourceData)) { + const studyLinkSection = osparc.component.share.Collaborators.createStudyLinkSection(); + this._add(studyLinkSection); + } else if (osparc.utils.Resources.isTemplate(resourceData)) { + const templateLinkSection = osparc.component.share.Collaborators.createTemplateLinkSection(); + this._add(templateLinkSection); + } }, __createViewWithEdit: function(view, cb) { From d3816dddd4caa7e81374837fca082c5c1244e962 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 16:51:26 +0200 Subject: [PATCH 3/6] undo --- .../client/source/class/osparc/info/StudyLarge.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js index aa986c82b2c..4304ea5d686 100644 --- a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js @@ -124,19 +124,6 @@ qx.Class.define("osparc.info.StudyLarge", { description.addAt(editInTitle, 0); this._add(description); } - - this._add(new qx.ui.core.Spacer(), { - flex: 1 - }); - - const resourceData = this.getStudy().serialize(); - if (osparc.utils.Resources.isStudy(resourceData)) { - const studyLinkSection = osparc.component.share.Collaborators.createStudyLinkSection(); - this._add(studyLinkSection); - } else if (osparc.utils.Resources.isTemplate(resourceData)) { - const templateLinkSection = osparc.component.share.Collaborators.createTemplateLinkSection(); - this._add(templateLinkSection); - } }, __createViewWithEdit: function(view, cb) { From f07d59dee47a1c427ac96b8267720b39a8fa9cb6 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 16:51:30 +0200 Subject: [PATCH 4/6] minor --- .../source/class/osparc/component/share/Collaborators.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js b/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js index 8217c2dbe95..0b1b598ec0a 100644 --- a/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/component/share/Collaborators.js @@ -29,6 +29,10 @@ qx.Class.define("osparc.component.share.Collaborators", { this._setLayout(new qx.ui.layout.VBox(10)); + this.set({ + padding: 5 + }); + this.__buildLayout(); this.__collaborators = {}; From 1243d201bce437ceccbf70aeae2ce87e94282fa3 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 16:57:18 +0200 Subject: [PATCH 5/6] minors --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 4 ++-- tests/e2e/utils/auto.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 7323e4d4459..c7d94899e76 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -47,14 +47,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { title: "New TI Plan", description: "Start new TI plan", newStudyLabel: "TI Planning Tool", - idToWidget: "newPlanButton" + idToWidget: "newTIPlanButton" }, "mTI": { templateLabel: "mTI Planning Tool", title: "New mTI Plan", description: "Start multiple TI plan", newStudyLabel: "mTI Planning Tool", - idToWidget: "newMPlanButton" + idToWidget: "newMTIPlanButton" } }, EXPECTED_S4L_SERVICE_KEYS: { diff --git a/tests/e2e/utils/auto.js b/tests/e2e/utils/auto.js index 198cebaa55d..43038aef978 100644 --- a/tests/e2e/utils/auto.js +++ b/tests/e2e/utils/auto.js @@ -113,7 +113,7 @@ async function dashboardNewPlan(page) { console.log("Creating New Plan"); await dashboardStudiesBrowser(page); - await utils.waitAndClick(page, '[osparc-test-id="newPlanButton"]'); + await utils.waitAndClick(page, '[osparc-test-id="newTIPlanButton"]'); } async function dashboardStartSim4LifeLite(page) { From e9d2c5fccfdaee925392cad430b3d4aa9dad326b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 17 May 2023 17:09:49 +0200 Subject: [PATCH 6/6] fix bug --- .../source/class/osparc/dashboard/StudyBrowser.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index c7d94899e76..e94cab24101 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -667,11 +667,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __newPlanBtnClicked: function(button, templateData) { + // do not override cached template data + const templateCopyData = osparc.utils.Utils.deepCloneObject(templateData); button.setValue(false); - const title = osparc.utils.Utils.getUniqueStudyName(templateData.name, this._resourcesList); - templateData.name = title; - this._showLoadingPage(this.tr("Creating ") + (templateData.name || osparc.product.Utils.getStudyAlias())); - osparc.utils.Study.createStudyFromTemplate(templateData, this._loadingPage) + const title = osparc.utils.Utils.getUniqueStudyName(templateCopyData.name, this._resourcesList); + templateCopyData.name = title; + this._showLoadingPage(this.tr("Creating ") + (templateCopyData.name || osparc.product.Utils.getStudyAlias())); + osparc.utils.Study.createStudyFromTemplate(templateCopyData, this._loadingPage) .then(studyId => { this._hideLoadingPage(); this.__startStudyById(studyId);