[pbs-devel] [PATCH proxmox-backup 10/23] ui: add removable datastore creation support

Hannes Laimer h.laimer at proxmox.com
Fri Sep 15 08:54:44 CEST 2023


Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
 www/window/DataStoreEdit.js | 47 +++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/www/window/DataStoreEdit.js b/www/window/DataStoreEdit.js
index aecf6b8d..d44cdf24 100644
--- a/www/window/DataStoreEdit.js
+++ b/www/window/DataStoreEdit.js
@@ -59,6 +59,31 @@ Ext.define('PBS.DataStoreEdit', {
 			fieldLabel: gettext('Backing Path'),
 			emptyText: gettext('An absolute path'),
 		    },
+		    {
+			xtype: 'pmxDisplayEditField',
+			fieldLabel: gettext('Device'),
+			name: 'backing-device',
+			hidden: true,
+			cbind: {
+			    editable: '{isCreate}',
+			}, editConfig: {
+			    xtype: 'pbsPartitionSelector',
+			    allowBlank: false,
+			},
+			emptyText: gettext('Device path'),
+			listeners: {
+			    change(field, newValue, oldValue) {
+				const form = field.up('form');
+				const pathField = form.down('[name=path]');
+
+				if (newValue) {
+				    pathField.setValue(`/mnt/removable_datastore/${newValue}`);
+				} else if (oldValue) {
+				    pathField.setValue('');
+				}
+			    },
+			},
+		    },
 		],
 		column2: [
 		    {
@@ -84,6 +109,28 @@ Ext.define('PBS.DataStoreEdit', {
 		    },
 		],
 		columnB: [
+		    {
+			xtype: 'checkbox',
+			boxLabel: gettext('Removable datastore'),
+			listeners: {
+			    change: function(checkbox, newValue) {
+				const inputPanel = checkbox.up('inputpanel');
+				const pathField = inputPanel.down('[name=path]');
+				const uuidField = inputPanel.down('[name=backing-device]');
+
+				pathField.setValue('');
+				uuidField.setValue('');
+
+				const [activeField, inactiveField] =
+				    newValue ? [uuidField, pathField] : [pathField, uuidField];
+
+				activeField.allowBlank = false;
+				inactiveField.allowBlank = true;
+				activeField.show();
+				inactiveField.hide();
+			    },
+			},
+		    },
 		    {
 			xtype: 'textfield',
 			name: 'comment',
-- 
2.39.2






More information about the pbs-devel mailing list