]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/lxc/MPEdit.js
fix #2810: reset state of mounts array in initComponent
[pve-manager.git] / www / manager6 / lxc / MPEdit.js
index 7689340dc41bb886240c2b65911333283f5fc734..f0a9233b5359111fd010d0fe2b9029071af4a365 100644 (file)
@@ -1,4 +1,3 @@
-/*jslint confusion: true*/
 /* hidden: boolean and string
  * bind: function and object
  * disabled: boolean and string
@@ -28,15 +27,12 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        var me = this;
 
        var confid = me.confid || "mp"+values.mpid;
-       values.file = me.down('field[name=file]').getValue();
-       if (values.mountoptions) {
-           values.mountoptions = values.mountoptions.join(';');
-       }
+       me.mp.file = me.down('field[name=file]').getValue();
 
        if (me.unused) {
            confid = "mp"+values.mpid;
        } else if (me.isCreate) {
-           values.file = values.hdstorage + ':' + values.disksize;
+           me.mp.file = values.hdstorage + ':' + values.disksize;
        }
 
        // delete unnecessary fields
@@ -45,8 +41,17 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        delete values.disksize;
        delete values.diskformat;
 
+       let mountopts = (values.mountoptions || []).join(';');
+       PVE.Utils.propertyStringSet(me.mp, values.mp, 'mp');
+       PVE.Utils.propertyStringSet(me.mp, values.mountoptions, 'mountoptions', mountopts);
+       PVE.Utils.propertyStringSet(me.mp, values.backup, 'backup');
+       PVE.Utils.propertyStringSet(me.mp, values.quota, 'quota');
+       PVE.Utils.propertyStringSet(me.mp, values.ro, 'ro');
+       PVE.Utils.propertyStringSet(me.mp, values.acl, 'acl');
+       PVE.Utils.propertyStringSet(me.mp, values.replicate, 'replicate');
+
        var res = {};
-       res[confid] = PVE.Parser.printLxcMountPoint(values);
+       res[confid] = PVE.Parser.printLxcMountPoint(me.mp);
        return res;
     },
 
@@ -58,6 +63,15 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        if (mp.mountoptions) {
            mp.mountoptions = mp.mountoptions.split(';');
        }
+       me.mp = mp;
+
+       if (this.confid === 'rootfs') {
+           var field = me.down('field[name=mountoptions]');
+           var forbidden = ['nodev', 'noexec'];
+           var filtered = field.comboItems.filter(e => !forbidden.includes(e[0]));
+           field.setComboItems(filtered);
+       }
+
        me.setValues(mp);
     },
 
@@ -66,7 +80,6 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        var vm = me.getViewModel();
        me.vmconfig = vmconfig;
        vm.set('unpriv', vmconfig.unprivileged);
-       vm.notify();
 
        PVE.Utils.forEachMP(function(bus, i) {
            var name = "mp" + i.toString();
@@ -81,7 +94,6 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        var me = this;
        var vm = me.getViewModel();
        vm.set('node', nodename);
-       vm.notify();
        me.down('#diskstorage').setNodename(nodename);
     },
 
@@ -108,7 +120,6 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
 
                    var vm = me.getViewModel();
                    vm.set('type', rec.data.type);
-                   vm.notify();
                }
            }
        },
@@ -116,12 +127,17 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        init: function(view) {
            var me = this;
            var vm = this.getViewModel();
+           view.mp = {};
            vm.set('confid', view.confid);
            vm.set('unused', view.unused);
            vm.set('node', view.nodename);
            vm.set('unpriv', view.unprivileged);
            vm.set('hideStorSelector', view.unused || !view.isCreate);
-           vm.notify();
+
+           // can be array if created from unused disk
+           if (view.isCreate) {
+               vm.set('isIncludedInBackup', true);
+           }
        }
     },
 
@@ -180,7 +196,6 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
                if (Ext.isDefined(me.vmconfig["mp"+value])) {
                    return "Mount point is already in use.";
                }
-               /*jslint confusion: true*/
                /* returns a string above */
                return true;
            }
@@ -229,9 +244,14 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
            xtype: 'proxmoxcheckbox',
            name: 'backup',
            fieldLabel: gettext('Backup'),
+           autoEl: {
+               tag: 'div',
+               'data-qtip': gettext('Include volume in backup job'),
+           },
            bind: {
                hidden: '{isRoot}',
-               disabled: '{isBindOrRoot}'
+               disabled: '{isBindOrRoot}',
+               value: '{isIncludedInBackup}'
            }
        }
     ],
@@ -350,10 +370,8 @@ Ext.define('PVE.lxc.MountPointEdit', {
            success: function(response, options) {
                ipanel.setVMConfig(response.result.data);
                if (me.confid) {
-                   /*jslint confusion: true*/
                    /*data is defined as array above*/
                    var value = response.result.data[me.confid];
-                   /*jslint confusion: false*/
                    var mp = PVE.Parser.parseLxcMountPoint(value);
 
                    if (!mp) {