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: Ask for confirmation before demoting an Organization to Viewer #3961

Merged
merged 10 commits into from
Mar 13, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ qx.Class.define("osparc.component.share.Collaborators", {
});
item.addListener("demoteToCollaborator", e => {
const orgMember = e.getData();
this._demoteToCollaborator(orgMember);
this._demoteToCollaborator(orgMember, item);
});
item.addListener("removeMember", e => {
const orgMember = e.getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,32 @@ qx.Class.define("osparc.component.share.CollaboratorsStudy", {
},

_demoteToViewer: function(collaborator, item) {
this.__make(
collaborator["gid"],
this.self().getViewerAccessRight(),
this.tr("Collaborator successfully made Viewer"),
this.tr("Something went wrong making Collaborator Viewer"),
item
);
const demoteToViewer = (collab, itm) => {
this.__make(
collab["gid"],
this.self().getViewerAccessRight(),
this.tr("Collaborator successfully made Viewer"),
this.tr("Something went wrong making Collaborator Viewer"),
itm
);
};
const preferencesSettings = osparc.desktop.preferences.Preferences.getInstance();
if (preferencesSettings.getConfirmDemoteOrgnaization()) {
const msg = this.tr("Demoting an Organization to Viewer, will make all its members Viewers");
const win = new osparc.ui.window.Confirmation(msg).set({
confirmAction: "delete",
confirmText: this.tr("Demote")
});
win.center();
win.open();
win.addListener("close", () => {
if (win.getConfirmed()) {
demoteToViewer(collaborator, item);
}
}, this);
} else {
demoteToViewer(collaborator, item);
}
},

_demoteToCollaborator: function(collaborator, item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ qx.Class.define("osparc.desktop.preferences.Preferences", {
event: "changeConfirmDeleteStudy"
},

confirmDemoteOrgnaization: {
nullable: false,
init: true,
check: "Boolean",
event: "changeConfirmDemoteOrgnaization"
},

confirmDeleteNode: {
nullable: false,
init: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ qx.Class.define("osparc.desktop.preferences.pages.ConfirmationsPage", {
}, this);
box.add(cbConfirmDeleteStudy);

const cbConfirmDemoteOrgnaization = new qx.ui.form.CheckBox(this.tr("Demote Organization collaboration"));
preferencesSettings.bind("confirmDemoteOrgnaization", cbConfirmDemoteOrgnaization, "value");
cbConfirmDemoteOrgnaization.bind("value", preferencesSettings, "confirmDemoteOrgnaization");
box.add(cbConfirmDemoteOrgnaization);

if (!(osparc.product.Utils.isProduct("tis") || osparc.product.Utils.isProduct("s4llite"))) {
const cbConfirmDeleteNode = new qx.ui.form.CheckBox(this.tr("Delete a Node"));
preferencesSettings.bind("confirmDeleteNode", cbConfirmDeleteNode, "value");
Expand Down