system: replace confirm() use for consistency (#7801)

This commit is contained in:
Franco Fichtner 2024-08-22 09:46:18 +02:00 committed by GitHub
parent cb09c6671b
commit f5ed3cf3d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,7 +134,7 @@ class WidgetManager {
this.persistedOptions = configuration.options;
} catch (error) {
// persisted config likely out of date, reset to defaults
this._restoreDefaults(false);
this.__restoreDefaults();
}
const promises = data.modules.map(async (item) => {
@ -564,18 +564,37 @@ class WidgetManager {
return $panel;
}
_restoreDefaults(confirmDialog = true) {
if (confirmDialog) {
if (!confirm(this.gettext.restoreconfirm)) {
return;
}
}
__restoreDefaults(dialog) {
$.ajax({type: "POST", url: "/api/core/dashboard/restoreDefaults"}).done((response) => {
if (response['result'] == 'failed') {
console.error('Failed to restore default widgets');
if (dialog !== undefined) {
dialog.close();
}
} else {
window.location.reload();
}
})
}
_restoreDefaults() {
BootstrapDialog.show({
title: this.gettext.restore,
draggable: true,
animate: false,
message: this.gettext.restoreconfirm,
buttons: [{
label: this.gettext.ok,
hotkey: 13,
action: (dialog) => {
this.__restoreDefaults(dialog);
}
}, {
label: this.gettext.cancel,
action: (dialog) => {
dialog.close();
}
}]
});
}