mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-08-22 21:49:23 +03:00
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>
62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
Ext.define('PBS.form.NamespaceMaxDepth', {
|
|
extend: 'Proxmox.form.field.Integer',
|
|
alias: 'widget.pbsNamespaceMaxDepth',
|
|
|
|
allowBlank: true,
|
|
|
|
emptyText: gettext('Full'),
|
|
fieldLabel: gettext('Max. Depth'),
|
|
deleteEmpty: true,
|
|
|
|
minValue: 0,
|
|
maxValue: 7,
|
|
|
|
triggers: {
|
|
clear: {
|
|
cls: 'pmx-clear-trigger',
|
|
weight: -1,
|
|
hidden: true,
|
|
handler: function () {
|
|
this.triggers.clear.setVisible(false);
|
|
this.setValue('');
|
|
},
|
|
},
|
|
},
|
|
|
|
listeners: {
|
|
change: function (field, value) {
|
|
let canClear = value !== '';
|
|
field.triggers.clear.setVisible(canClear);
|
|
},
|
|
},
|
|
});
|
|
|
|
Ext.define('PBS.form.NamespaceMaxDepthReduced', {
|
|
extend: 'PBS.form.NamespaceMaxDepth',
|
|
alias: 'widget.pbsNamespaceMaxDepthReduced',
|
|
|
|
calcMaxPrefixLength: function (ns1, ns2) {
|
|
let maxPrefixLength = 0;
|
|
if (ns1 !== undefined && ns1 !== null && typeof ns1 === 'string') {
|
|
maxPrefixLength = (ns1.match(/[/]/g) || []).length + (ns1 === '' ? 0 : 1);
|
|
}
|
|
if (ns2 !== undefined && ns2 !== null && typeof ns2 === 'string') {
|
|
let ns2PrefixLength = (ns2.match(/[/]/g) || []).length + (ns2 === '' ? 0 : 1);
|
|
if (ns2PrefixLength > maxPrefixLength) {
|
|
maxPrefixLength = ns2PrefixLength;
|
|
}
|
|
}
|
|
return maxPrefixLength;
|
|
},
|
|
|
|
setLimit: function (ns1, ns2) {
|
|
let me = this;
|
|
let maxPrefixLength = me.calcMaxPrefixLength(ns1, ns2);
|
|
if (maxPrefixLength !== undefined) {
|
|
me.maxValue = 7 - maxPrefixLength;
|
|
} else {
|
|
me.maxValue = 7;
|
|
}
|
|
},
|
|
});
|