Skip to content

Commit

Permalink
permalink for templates (#4201)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored May 8, 2023
1 parent 386ef67 commit ad4d076
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ qx.Class.define("osparc.component.share.Collaborators", {
this._add(control);
// excluded by default
control.exclude();
break;
case "template-link":
control = this.__createTemplateLinkSection();
this._add(control);
// excluded by default
control.exclude();
break;
}
return control || this.base(arguments, id);
},
Expand All @@ -118,6 +125,7 @@ qx.Class.define("osparc.component.share.Collaborators", {
this._createChildControlImpl("open-organizations-btn");
this._createChildControlImpl("collaborators-list");
this._createChildControlImpl("study-link");
this._createChildControlImpl("template-link");
},

__createAddCollaboratorSection: function() {
Expand Down Expand Up @@ -214,7 +222,7 @@ qx.Class.define("osparc.component.share.Collaborators", {
const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));

const label = new qx.ui.basic.Label().set({
value: this.tr("Permanent Link for users that have access to the ") + osparc.product.Utils.getStudyAlias(),
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);
Expand Down Expand Up @@ -243,6 +251,47 @@ qx.Class.define("osparc.component.share.Collaborators", {
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 @@ -304,6 +304,8 @@ qx.Class.define("osparc.dashboard.ResourceMoreOptions", {
permissionsView = new osparc.component.share.CollaboratorsStudy(resourceData);
if (osparc.utils.Resources.isStudy(resourceData)) {
permissionsView.getChildControl("study-link").show();
} else if (osparc.utils.Resources.isTemplate(resourceData)) {
permissionsView.getChildControl("template-link").show();
}
permissionsView.addListener("updateAccessRights", e => {
const updatedData = e.getData();
Expand Down

0 comments on commit ad4d076

Please sign in to comment.