From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3253E62974 for ; Tue, 27 Oct 2020 16:20:47 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1B17318C3D for ; Tue, 27 Oct 2020 16:20:17 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4DBE918C1A for ; Tue, 27 Oct 2020 16:20:14 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 02E6145F5E for ; Tue, 27 Oct 2020 16:20:14 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 27 Oct 2020 16:20:10 +0100 Message-Id: <20201027152011.7373-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027152011.7373-1-d.csapak@proxmox.com> References: <20201027152011.7373-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.456 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 7/8] ui: MainView/NavigationTree: improve tree selection handling X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2020 15:20:47 -0000 this fixes some bugs related to selection handling in the treelist: * datastores were not selected after a reload * reloading when in a tabpanel on any tab but the first, would not select a treenode * changing between datastores on any tab but the first would not select the same tab on the new datastore fixed those by mostly rewriting the changePath handling for datastores and tabpanels in general Signed-off-by: Dominik Csapak --- www/MainView.js | 70 ++++++++++++++++++++++--------------------- www/NavigationTree.js | 22 ++++++++++++-- 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/www/MainView.js b/www/MainView.js index cfd19058..7998e535 100644 --- a/www/MainView.js +++ b/www/MainView.js @@ -67,46 +67,48 @@ Ext.define('PBS.MainView', { var contentpanel = me.lookupReference('contentpanel'); var lastpanel = contentpanel.getLayout().getActiveItem(); - var obj; - if (PBS.Utils.isDataStorePath(path)) { - let datastore = PBS.Utils.getDataStoreFromPath(path); - obj = contentpanel.add({ - xtype: 'pbsDataStorePanel', - nodename: 'localhost', - datastore, - }); - } else { - obj = contentpanel.add({ - xtype: path, - nodename: 'localhost', - border: false, - }); - } + let tabChangeListener = function(tp, newc, oldc) { + let newpath = path; - var treelist = me.lookupReference('navtree'); - - treelist.suspendEvents(); - if (subpath === undefined) { - treelist.select(path); - } else { - treelist.select(path + ':' + subpath); - } - treelist.resumeEvents(); + // only add the subpath part for the + // non-default tabs + if (tp.items.findIndex('id', newc.id) !== 0) { + newpath += `:${newc.getItemId()}`; + } - if (Ext.isFunction(obj.setActiveTab)) { - obj.setActiveTab(subpath || 0); - obj.addListener('tabchange', function(tabpanel, newc, oldc) { - var newpath = path; + me.redirectTo(newpath); + }; - // only add the subpath part for the - // non-default tabs - if (tabpanel.items.findIndex('id', newc.id) !== 0) { - newpath += ":" + newc.getItemId(); + let xtype = path; + var obj; + let datastore; + if (PBS.Utils.isDataStorePath(path)) { + datastore = PBS.Utils.getDataStoreFromPath(path); + if (lastpanel && lastpanel.xtype === 'pbsDataStorePanel' && !subpath) { + let activeTab = lastpanel.getActiveTab(); + let newpath = path; + if (lastpanel.items.indexOf(activeTab) !== 0) { + subpath = activeTab.getItemId(); + newpath += `:${subpath}`; } - me.redirectTo(newpath); - }); + } + xtype = 'pbsDataStorePanel'; } + obj = contentpanel.add({ + xtype, + datastore, + nodename: 'localhost', + border: false, + activeTab: subpath || 0, + listeners: { + tabchange: tabChangeListener, + }, + }); + + var treelist = me.lookupReference('navtree'); + + treelist.select(path, true); contentpanel.setActiveItem(obj); diff --git a/www/NavigationTree.js b/www/NavigationTree.js index 54e0adeb..6524a5c3 100644 --- a/www/NavigationTree.js +++ b/www/NavigationTree.js @@ -163,6 +163,12 @@ Ext.define('PBS.view.main.NavigationTree', { }); Ext.Array.forEach(erase_list, function(node) { list.removeChild(node, true); }); + + if (view.pathToSelect !== undefined) { + let path = view.pathToSelect; + delete view.pathToSelect; + view.select(path, true); + } }, }, @@ -186,10 +192,20 @@ Ext.define('PBS.view.main.NavigationTree', { }, }, - select: function(path) { + select: function(path, silent) { var me = this; - var item = me.getStore().findRecord('path', path, 0, false, true, true); - me.setSelection(item); + if (me.rstore.isLoaded()) { + if (silent) { + me.suspendEvents(false); + } + var item = me.getStore().findRecord('path', path, 0, false, true, true); + me.setSelection(item); + if (silent) { + me.resumeEvents(true); + } + } else { + me.pathToSelect = path; + } }, animation: false, -- 2.20.1