Skip to content

Commit bbcbd93

Browse files
committed
last
1 parent a71ba5f commit bbcbd93

File tree

1 file changed

+36
-40
lines changed

1 file changed

+36
-40
lines changed

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

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,42 @@ qx.Class.define("osparc.po.UsersPending", {
272272
approveBtn.addListener("execute", () => {
273273
if (osparc.data.Permissions.getInstance().canDo("user.invitation.generate", true)) {
274274
if (form.validate()) {
275-
this.__confirmApproveUser(email, form);
275+
const extraCreditsInUsd = form.getItems()["credits"].getValue();
276+
let trialAccountDays = 0;
277+
if (form.getItems()["withExpiration"].getValue()) {
278+
trialAccountDays = form.getItems()["trialDays"].getValue();
279+
}
280+
281+
let msg = `Are you sure you want to approve ${email}`;
282+
if (extraCreditsInUsd) {
283+
msg += ` with ${extraCreditsInUsd}$ worth credits`;
284+
}
285+
if (trialAccountDays > 0) {
286+
msg += ` and ${trialAccountDays} days of trial`;
287+
}
288+
msg += "?";
289+
const confWin = new osparc.ui.window.Confirmation(msg).set({
290+
caption: "Approve User",
291+
confirmText: "Approve",
292+
confirmAction: "create"
293+
});
294+
confWin.center();
295+
confWin.open();
296+
confWin.addListener("close", () => {
297+
if (confWin.getConfirmed()) {
298+
approveBtn.setFetching(true);
299+
this.__approveUser(email, form)
300+
.then(() => {
301+
osparc.FlashMessenger.logAs("User approved", "INFO");
302+
this.__reload();
303+
})
304+
.catch(err => osparc.FlashMessenger.logError(err))
305+
.finally(() => {
306+
approveBtn.setFetching(false);
307+
win.close();
308+
});
309+
}
310+
});
276311
}
277312
}
278313
});
@@ -307,45 +342,6 @@ qx.Class.define("osparc.po.UsersPending", {
307342
return button;
308343
},
309344

310-
__confirmApproveUser: function(email, form) {
311-
const extraCreditsInUsd = form.getItems()["credits"].getValue();
312-
let trialAccountDays = 0;
313-
if (form.getItems()["withExpiration"].getValue()) {
314-
trialAccountDays = form.getItems()["trialDays"].getValue();
315-
}
316-
317-
let msg = `Are you sure you want to approve ${email}`;
318-
if (extraCreditsInUsd) {
319-
msg += ` with ${extraCreditsInUsd}$ worth credits`;
320-
}
321-
if (trialAccountDays > 0) {
322-
msg += ` and ${trialAccountDays} days of trial`;
323-
}
324-
msg += "?";
325-
const win = new osparc.ui.window.Confirmation(msg).set({
326-
caption: "Approve User",
327-
confirmText: "Approve",
328-
confirmAction: "create"
329-
});
330-
win.center();
331-
win.open();
332-
win.addListener("close", () => {
333-
if (win.getConfirmed()) {
334-
approveBtn.setFetching(true);
335-
this.__approveUser(email, form)
336-
.then(() => {
337-
osparc.FlashMessenger.logAs("User approved", "INFO");
338-
this.__reload();
339-
})
340-
.catch(err => osparc.FlashMessenger.logError(err))
341-
.finally(() => {
342-
approveBtn.setFetching(false);
343-
win.close();
344-
});
345-
}
346-
});
347-
},
348-
349345
__approveUser: function(email, form) {
350346
const params = {
351347
data: {

0 commit comments

Comments
 (0)