Skip to content

Commit 501de9d

Browse files
committed
__confirmApproveUser
1 parent c05c37f commit 501de9d

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

services/static-webserver/client/source/class/osparc/po/UsersPending.js

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -264,32 +264,10 @@ qx.Class.define("osparc.po.UsersPending", {
264264
});
265265
win.open();
266266
approveBtn.addListener("execute", () => {
267-
if (!osparc.data.Permissions.getInstance().canDo("user.invitation.generate", true)) {
268-
return;
269-
}
270-
if (form.validate()) {
271-
const msg = this.tr("This user has no access to the project. Do you want to share it?");
272-
const win = new osparc.ui.window.Confirmation(msg).set({
273-
caption: this.tr("Share"),
274-
confirmText: this.tr("Share"),
275-
confirmAction: "create"
276-
});
277-
win.center();
278-
win.open();
279-
win.addListener("close", () => {
280-
if (win.getConfirmed()) {
281-
approveBtn.setFetching(true);
282-
this.__approveUser(email, form)
283-
.then(() => {
284-
osparc.FlashMessenger.logAs(qx.locale.Manager.tr("User approved"), "INFO");
285-
})
286-
.catch(err => osparc.FlashMessenger.logError(err))
287-
.finally(() => {
288-
approveBtn.setFetching(false);
289-
win.close();
290-
});
291-
}
292-
});
267+
if (osparc.data.Permissions.getInstance().canDo("user.invitation.generate", true)) {
268+
if (form.validate()) {
269+
this.__confirmApproveUser(email, form);
270+
}
293271
}
294272
});
295273
});
@@ -301,7 +279,7 @@ qx.Class.define("osparc.po.UsersPending", {
301279
button.addListener("execute", () => {
302280
const msg = `Are you sure you want to reject ${email}.<br>The operation cannot be reverted"`;
303281
const win = new osparc.ui.window.Confirmation(msg).set({
304-
caption: "Reject",
282+
caption: "Reject User",
305283
confirmText: "Reject",
306284
confirmAction: "delete",
307285
});
@@ -320,6 +298,44 @@ qx.Class.define("osparc.po.UsersPending", {
320298
return button;
321299
},
322300

301+
__confirmApproveUser: function(email, form) {
302+
const extraCreditsInUsd = form.getItems()["credits"].getValue();
303+
let trialAccountDays = 0;
304+
if (form.getItems()["withExpiration"].getValue()) {
305+
trialAccountDays = form.getItems()["trialDays"].getValue();
306+
}
307+
308+
let msg = `Are you sure you want to approve ${email}`;
309+
if (extraCreditsInUsd) {
310+
msg += ` with ${extraCreditsInUsd}$ credits`;
311+
}
312+
if (trialAccountDays > 0) {
313+
msg += ` and ${trialAccountDays} days of trial`;
314+
}
315+
msg += "?";
316+
const win = new osparc.ui.window.Confirmation(msg).set({
317+
caption: "Approve User",
318+
confirmText: "Approve",
319+
confirmAction: "create"
320+
});
321+
win.center();
322+
win.open();
323+
win.addListener("close", () => {
324+
if (win.getConfirmed()) {
325+
approveBtn.setFetching(true);
326+
this.__approveUser(email, form)
327+
.then(() => {
328+
osparc.FlashMessenger.logAs("User approved", "INFO");
329+
})
330+
.catch(err => osparc.FlashMessenger.logError(err))
331+
.finally(() => {
332+
approveBtn.setFetching(false);
333+
win.close();
334+
});
335+
}
336+
});
337+
},
338+
323339
__approveUser: function(email, form) {
324340
const params = {
325341
data: {

0 commit comments

Comments
 (0)