]> git.proxmox.com Git - pmg-gui.git/commitdiff
pbs remote: disallow editing fixed fields
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 14 May 2022 15:26:51 +0000 (17:26 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 14 May 2022 15:36:09 +0000 (17:36 +0200)
similar in spirit of PVE's storage entries for PBS, changing those
after create can make backups disappear and just shouldn't be done,
user should add a new remote instead.

Same for user name, changing it will make backup almost definitively
fail the owner check, so only keep the password field, for PW
rotations (we should disable it for tokens though).

For UX it's better to check if params are correct and the repo is
accessible on create and to add scan datastore and namespace
endpoints to allow a friendlier selection of those, avoiding typos.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
js/PBSRemoteEdit.js

index e521a187d8fe23c15e8e1a10984e8d14deab5d52..b5b22947f86bfa7791e5bb15f1de1ee97e0cb166 100644 (file)
@@ -8,11 +8,8 @@ Ext.define('PMG.PBSInputPanel', {
 
     cbindData: function(initialConfig) {
        let me = this;
-
        me.isCreate = initialConfig.isCreate || !initialConfig.remoteId;
-       return {
-           unsetValue: me.isCreate ? null : undefined,
-       };
+       return {};
     },
 
     items: [
@@ -29,29 +26,24 @@ Ext.define('PMG.PBSInputPanel', {
                    xtype: 'pmxDisplayEditField',
                    name: 'remote',
                    cbind: {
-                       value: '{unsetValue}',
                        editable: '{isCreate}',
                    },
                    fieldLabel: gettext('ID'),
                    allowBlank: false,
                },
                {
-                   xtype: 'proxmoxtextfield',
+                   xtype: 'pmxDisplayEditField',
                    name: 'server',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
                    vtype: 'DnsOrIp',
                    fieldLabel: gettext('Server'),
+                   cbind: { editable: '{isCreate}' },
                    allowBlank: false,
                },
                {
-                   xtype: 'proxmoxtextfield',
+                   xtype: 'pmxDisplayEditField',
                    name: 'datastore',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
                    fieldLabel: 'Datastore',
+                   cbind: { editable: '{isCreate}' },
                    allowBlank: false,
                },
                {
@@ -69,23 +61,21 @@ Ext.define('PMG.PBSInputPanel', {
            ],
            column2: [
                {
-                   xtype: 'proxmoxtextfield',
+                   xtype: 'pmxDisplayEditField',
                    name: 'username',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
-                   emptyText: gettext('Example') + ': admin@pbs',
                    fieldLabel: gettext('Username'),
+                   emptyText: gettext('Example') + ': admin@pbs',
+                   cbind: { editable: '{isCreate}' },
                    regex: /\S+@\w+/,
                    regexText: gettext('Example') + ': admin@pbs',
                    allowBlank: false,
                },
                {
-                   xtype: 'proxmoxtextfield',
+                   xtype: 'pmxDisplayEditField',
+                   editable: true, // FIXME: set to false if (!create && user == token)
                    inputType: 'password',
                    name: 'password',
                    cbind: {
-                       value: '{unsetValue}',
                        allowBlank: '{!isCreate}',
                        emptyText: (get) => get('isCreate') ? '' : gettext('Unchanged'),
                    },
@@ -110,9 +100,6 @@ Ext.define('PMG.PBSInputPanel', {
                {
                    xtype: 'proxmoxtextfield',
                    name: 'fingerprint',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
                    fieldLabel: gettext('Fingerprint'),
                    emptyText: gettext('Server certificate SHA-256 fingerprint, required for self-signed certificates'),
                    regex: /[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){31}/,