forked from proxmox-mirrors/proxmox-backup
Use `proxmox-biome format --write`, which is a small wrapper around [Biome] that sets the desired config options for matching the Proxmox style guide as close as possible. Note that the space between function key word and parameter parenthesis for anonymous functions or function names and parameter parenthesis for named functions is rather odd and not per our style guide, but this is not configurable and while it would be relatively simple to change in the formatter code of biome, we would like to avoid doing so for both maintenance reason and as this is seemingly the default in the "web" industry, as prettier–one of the most popular formatters for web projects–uses this and Biome copied the style mostly from there. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> [TL: add commit message with some background] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
103 lines
3.3 KiB
JavaScript
103 lines
3.3 KiB
JavaScript
Ext.define('PBS.form.maintenanceType', {
|
|
extend: 'Proxmox.form.KVComboBox',
|
|
alias: 'widget.pbsMaintenanceType',
|
|
|
|
comboItems: [
|
|
['__default__', gettext('None')],
|
|
['read-only', gettext('Read only')],
|
|
['offline', gettext('Offline')],
|
|
],
|
|
});
|
|
|
|
Ext.define('PBS.window.MaintenanceOptions', {
|
|
extend: 'Proxmox.window.Edit',
|
|
xtype: 'pbsMaintenanceOptionEdit',
|
|
mixins: ['Proxmox.Mixin.CBind'],
|
|
|
|
onlineHelp: 'maintenance-mode',
|
|
|
|
subject: gettext('Maintenance mode'),
|
|
|
|
width: 450,
|
|
fieldDefaults: {
|
|
labelWidth: 120,
|
|
},
|
|
|
|
apiCallDone: function (success, response, options) {
|
|
if (success) {
|
|
let datastoreStore = Ext.data.StoreManager.lookup('pbs-datastore-list');
|
|
if (datastoreStore) {
|
|
// delay a bit to allow the window to close and maintenance mode to take effect
|
|
setTimeout(() => datastoreStore.load(), 10);
|
|
}
|
|
}
|
|
},
|
|
|
|
items: {
|
|
xtype: 'inputpanel',
|
|
onGetValues: function (values) {
|
|
if (values.delete === 'maintenance-type') {
|
|
values.delete = 'maintenance-mode';
|
|
} else if (values['maintenance-type']) {
|
|
const message = (values['maintenance-msg'] ?? '')
|
|
.replaceAll('\\', '')
|
|
.replaceAll('"', '\\"');
|
|
const maybe_message = values['maintenance-msg'] ? `,message="${message}"` : '';
|
|
values['maintenance-mode'] = `type=${values['maintenance-type']}${maybe_message}`;
|
|
}
|
|
delete values['maintenance-type'];
|
|
delete values['maintenance-msg'];
|
|
return values;
|
|
},
|
|
items: [
|
|
{
|
|
xtype: 'pbsMaintenanceType',
|
|
reference: 'type-field',
|
|
name: 'maintenance-type',
|
|
fieldLabel: gettext('Maintenance Type'),
|
|
value: '__default__',
|
|
deleteEmpty: true,
|
|
listeners: {
|
|
change: (field, newValue) => {
|
|
field
|
|
.up('form')
|
|
.down('[name=maintenance-msg]')
|
|
.setDisabled(newValue === '__default__');
|
|
},
|
|
},
|
|
},
|
|
{
|
|
xtype: 'proxmoxtextfield',
|
|
reference: 'message-field',
|
|
name: 'maintenance-msg',
|
|
fieldLabel: gettext('Description'),
|
|
},
|
|
],
|
|
},
|
|
setValues: function (values) {
|
|
let me = this;
|
|
|
|
let options = {
|
|
'maintenance-type': '__default__',
|
|
'maintenance-msg': '',
|
|
};
|
|
if (values['maintenance-mode']) {
|
|
const [type, message] = PBS.Utils.parseMaintenanceMode(values['maintenance-mode']);
|
|
options = {
|
|
'maintenance-type': type,
|
|
'maintenance-msg': message ?? '',
|
|
};
|
|
}
|
|
|
|
let unmounting = options['maintenance-type'] === 'unmount';
|
|
let defaultType = options['maintenance-type'] === '__default__';
|
|
if (unmounting) {
|
|
options['maintenance-type'] = gettext('Unmounting');
|
|
}
|
|
|
|
me.callParent([options]);
|
|
|
|
me.lookupReference('message-field').setDisabled(unmounting || defaultType);
|
|
},
|
|
});
|