]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: guest import: use view-model for unique-mac-addr state
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 27 Mar 2024 09:33:41 +0000 (10:33 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 27 Mar 2024 09:36:03 +0000 (10:36 +0100)
Avoid some global widget config to store internal state, rather use
the existing viewModel for that.

Also avoid unnecessary references and switch to a boxLabel, drop also
the tooltip, as that doesn't add much here where the effect can be
seen in the grid.

Avoid reconfiguring all grids if only the network one can have changed
due to a change of this check box value.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/window/GuestImport.js

index aee54706050739a46745432e66dc3d641dadb3bb..29eb1c0665256fc053121dbcdfbb77fe266b34fe 100644 (file)
@@ -15,8 +15,6 @@ Ext.define('PVE.window.GuestImport', {
     showTaskViewer: true,
     method: 'POST',
 
-    uniqueMac: false,
-
     loadUrl: function(_url, { storage, nodename, volumeName }) {
        let args = Ext.Object.toQueryString({ volume: volumeName });
        return `/nodes/${nodename}/storage/${storage}/import-metadata?${args}`;
@@ -229,19 +227,19 @@ Ext.define('PVE.window.GuestImport', {
            me.getView().vmConfig.scsihw = value;
        },
 
-       onUniqueMacChange: function(_cb, value) {
+       onUniqueMACChange: function(_cb, value) {
            let me = this;
-           me.getView().uniqueMac = value;
 
-           me.refreshGrids();
+           me.getViewModel().set('uniqueMACAdresses', value);
+
+           me.lookup('netGrid').reconfigure();
        },
 
        renderMacAddress: function(value, metaData, record, rowIndex, colIndex, store, view) {
            let me = this;
-           if (me.getView().uniqueMac) {
-               return 'auto';
-           }
-           return value ? value : 'auto';
+           let vm = me.getViewModel();
+
+           return !vm.get('uniqueMACAdresses') && value ? value : 'auto';
        },
 
        control: {
@@ -274,8 +272,8 @@ Ext.define('PVE.window.GuestImport', {
            'pveScsiHwSelector': {
                change: 'onScsiHwChange',
            },
-           'proxmoxcheckbox[reference=uniqueMac]': {
-               change: 'onUniqueMacChange',
+           'proxmoxcheckbox[name=uniqueMACs]': {
+               change: 'onUniqueMACChange',
            },
        },
     },
@@ -287,6 +285,7 @@ Ext.define('PVE.window.GuestImport', {
            liveImport: false,
            os: 'l26',
            maxCdDrives: false,
+           uniqueMACAdresses: false,
            warnings: [],
        },
 
@@ -318,6 +317,7 @@ Ext.define('PVE.window.GuestImport', {
                    onGetValues: function(values) {
                        let me = this;
                        let grid = me.up('pveGuestImportWindow');
+                       let vm = grid.getViewModel();
 
                        // from pveDiskStorageSelector
                        let defaultStorage = values.hdstorage;
@@ -385,7 +385,7 @@ Ext.define('PVE.window.GuestImport', {
                            if (!data.bridge) {
                                data.bridge = defaultBridge;
                            }
-                           if (grid.uniqueMac) {
+                           if (vm.get('uniqueMACAdresses')) {
                                data.macaddr = undefined;
                            }
                            config[id] = PVE.Parser.printQemuNetwork(data);
@@ -836,15 +836,9 @@ Ext.define('PVE.window.GuestImport', {
                        {
                            xtype: 'proxmoxcheckbox',
                            name: 'uniqueMACs',
-                           reference: 'uniqueMac',
-                           labelWidth: 200,
-                           fieldLabel: gettext('Unique MAC addresses'),
+                           boxLabel: gettext('Unique MAC addresses'),
                            uncheckedValue: false,
-                           checked: false,
-                           autoEl: {
-                               tag: 'div',
-                               'data-qtip': gettext('Generate new unique MAC addresses.'),
-                           },
+                           value: false,
                        },
                    ],
                },