[pbs-devel] [PATCH proxmox-backup v2 2/2] web: disallow datastore in root, add reuse-datastore flag
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Jul 22 08:45:47 CEST 2024
Am 12/06/2024 um 15:22 schrieb Gabriel Goller:
> Disallows creating a datastore in root on the frontend side, by
> filtering the '/' path. Add reuse-flag to permit us to open existing
> datastores.
>
> Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
> ---
> www/window/DataStoreEdit.js | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/www/window/DataStoreEdit.js b/www/window/DataStoreEdit.js
> index b6115460..2565688e 100644
> --- a/www/window/DataStoreEdit.js
> +++ b/www/window/DataStoreEdit.js
> @@ -61,6 +61,17 @@ Ext.define('PBS.DataStoreEdit', {
> allowBlank: false,
> fieldLabel: gettext('Backing Path'),
> emptyText: gettext('An absolute path'),
> + validator: function(val) {
> + if (val.trim() === '/') {
> + return false;
> + }
> + return true;
above could be reduced to:
validator: val => val?.trim() !== '/',
Note also the null check, not 100% sure from top of my head, but when
going from some value to deleting the field content (CTRL + A; DEL)
the validator might be called with a null/undefined value, or did you
check and ensure that it's then always an empty string?
Besides that, this seems quite unrelated to the "allow re-adding an
existing datastore" part and should be its own patch, which could
be applied up-front.
Oh, and does the backend disallow this already, or is this intended
as "unsafe" frontend only check for pure UX reason (can be fine, but
I would at least note that explicitly in the commit message).
> + },
> + },
> + {
> + xtype: 'checkbox',
> + name: 'reuse-datastore',
> + fieldLabel: gettext('Reuse existing datastore'),
hmm, not sure w.r.t. always showing a checkbox for some relatively niche
use case by default.
Maybe this is better split-off into either an advanced section or by
opening the dialogue through some new button (e.g. by adding a top bar
in the all-datastore summary page and add an "Add Datastore" split-
button there with the "Re-Add Existing Datastore" as menu button there
(like the shutdown + reboot/stop for guests in PVE).
> },
> ],
> column2: [
More information about the pbs-devel
mailing list