]> git.proxmox.com Git - pve-manager.git/commitdiff
fix reselection on vm/ct migrate in gui
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 23 Jun 2017 09:00:58 +0000 (11:00 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 23 Jun 2017 11:01:12 +0000 (13:01 +0200)
there were a number of problems in how we reselected vms when they
migrated and selected:

we relied on the data in the configpanel to be static, but since
pveselnode is a reference, it actually changes when the resourcestore
changes
also, handling the reselection as a response to the statusstore failure
is very inconsistent, because we know exactly when a vm moves node in
the tree

this patch removes the whole configpanel vm migration code,
and lets the tree handle it
for this, we have to check if we have to reselect the entry,
deselect it manually and after the treeupdate reselect it

also in the right click selection check we have to check if it is
already selected, else the next selection will get canceled

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/Workspace.js
www/manager6/lxc/Config.js
www/manager6/qemu/Config.js
www/manager6/tree/ResourceTree.js

index a516319d990e63efbb59ff3c3235866fb7db1150..30a51b1bced45f8887e321f551c176e1ce8d0271 100644 (file)
@@ -140,12 +140,6 @@ Ext.define('PVE.StdWorkspace', {
        tree.selectById(nodeid);
     },
 
-    checkVmMigration: function(record) {
-       var me = this;
-       var tree = me.down('pveResourceTree');
-       tree.checkVmMigration(record);
-    },
-
     onLogin: function(loginData) {
        var me = this;
 
index bf8cf319fb086367a928cb3dfb50680fa236e108..245de8ed50c64e3f9d862165ce41857ebd9db05a 100644 (file)
@@ -273,7 +273,6 @@ Ext.define('PVE.lxc.Config', {
        me.mon(me.statusStore, 'load', function(s, records, success) {
            var status;
            if (!success) {
-               me.workspace.checkVmMigration(me.pveSelNode);
                status = 'unknown';
            } else {
                var rec = s.data.get('status');
index 879ea322da271ffc0a94effb06ea9a9ec4e3e92f..3b1ff018f295f9a33bb4d7a8823352b14bc9aa92 100644 (file)
@@ -307,7 +307,6 @@ Ext.define('PVE.qemu.Config', {
            var spice = false;
 
            if (!success) {
-               me.workspace.checkVmMigration(me.pveSelNode);
                status = qmpstatus = 'unknown';
            } else {
                var rec = s.data.get('status');
index 56e7fddd9f417c79610af99a4696ce1f8af97138..b928f95d3a95faf405148f25ca86a44129ddfb12 100644 (file)
@@ -244,6 +244,7 @@ Ext.define('PVE.tree.ResourceTree', {
            var sm = me.getSelectionModel();
 
            var lastsel = sm.getSelection()[0];
+           var reselect = false;
            var parents = [];
            var p = lastsel;
            while (p && !!(p = p.parentNode)) {
@@ -314,6 +315,16 @@ Ext.define('PVE.tree.ResourceTree', {
                        //console.log("REM UID: " + key + " ITEM " + olditem.data.id);
                        delete index[key];
                        var parentNode = olditem.parentNode;
+                       // when the selected item disappears,
+                       // we have to deselect it here, and reselect it
+                       // later
+                       if (lastsel && olditem.data.id === lastsel.data.id) {
+                           reselect = true;
+                           sm.deselect(olditem);
+                       }
+                       // since the store events are suspended, we
+                       // manually remove the item from the store also
+                       store.remove(olditem);
                        parentNode.removeChild(olditem, true);
                    }
                }
@@ -352,6 +363,8 @@ Ext.define('PVE.tree.ResourceTree', {
                    }
                }
                me.selectById(lastsel.data.id);
+           } else if (lastsel && reselect) {
+               me.selectById(lastsel.data.id);
            }
 
            // on first tree load set the selection from the stateful provider
@@ -389,8 +402,10 @@ Ext.define('PVE.tree.ResourceTree', {
                    rstore.un("load", updateTree);
                },
                beforecellmousedown: function (tree, td, cellIndex, record, tr, rowIndex, ev) {
+                   var sm = me.getSelectionModel();
                    // disable selection when right clicking
-                   me.allowSelection = (ev.button !== 2);
+                   // except the record is already selected
+                   me.allowSelection = (ev.button !== 2) || sm.isSelected(record);
                },
                beforeselect: function (tree, record, index, eopts) {
                    var allow = me.allowSelection;
@@ -439,20 +454,6 @@ Ext.define('PVE.tree.ResourceTree', {
                }
                return node;
            },
-           checkVmMigration: function(record) {
-               if (!(record.data.type === 'qemu' || record.data.type === 'lxc')) {
-                   throw "not a vm type";
-               }
-
-               var rootnode = me.store.getRootNode();
-               var node = rootnode.findChild('id', record.data.id, true);
-
-               if (node && node.data.type === record.data.type &&
-                   node.data.node !== record.data.node) {
-                   // defer select (else we get strange errors)
-                   Ext.defer(function() { me.selectExpand(node); }, 100, me);
-               }
-           },
            applyState : function(state) {
                var sm = me.getSelectionModel();
                if (state && state.value) {