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

🐛 Bugfix: TIP plus buttons #4252

Merged
merged 6 commits into from
May 17, 2023
Merged
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 @@ -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 = {};
Expand Down Expand Up @@ -70,6 +74,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;
}
},

Expand Down Expand Up @@ -105,13 +183,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();
Expand Down Expand Up @@ -218,80 +296,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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down