[pbs-devel] [PATCH proxmox-backup] ui: check tabpanel subitems before setting activeTab

Dominik Csapak d.csapak at proxmox.com
Fri Jul 9 16:49:19 CEST 2021


instead of blindy using the subpath of the routing for the activeTab,
check the prototype of the wanted class if that even exists, otherwise
delete subpath, and the first tab will be selected

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/MainView.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/www/MainView.js b/www/MainView.js
index d8f89979..4b0c40a2 100644
--- a/www/MainView.js
+++ b/www/MainView.js
@@ -97,6 +97,15 @@ Ext.define('PBS.MainView', {
 
 	    let [xtype, config] = me.parseRouterPath(path);
 	    var obj;
+
+	    let cls = Ext.ClassManager.getByAlias(`widget.${xtype}`); // must exist
+	    if (subpath && cls.prototype.getActiveTab) { // assume a tabpanel
+		let has_tab = cls.prototype.items.some((item) => item.itemId === subpath);
+		if (!has_tab) {
+		    subpath = undefined;
+		}
+	    }
+
 	    if (PBS.Utils.isDataStorePath(path)) {
 		if (lastpanel && lastpanel.xtype === xtype && !subpath) {
 		    let activeTab = lastpanel.getActiveTab();
-- 
2.30.2






More information about the pbs-devel mailing list