From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] ui: improve activeTab selection from fragment and state
Date: Tue, 10 Nov 2020 14:16:16 +0100 [thread overview]
Message-ID: <20201110131616.3802-1-d.csapak@proxmox.com> (raw)
handle invalid fragments for tabs, as well as not rendered tabpanels
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/datastore/DataStoreList.js | 16 +++++++++++++++-
www/datastore/Panel.js | 11 ++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/www/datastore/DataStoreList.js b/www/datastore/DataStoreList.js
index 12d311a6..284a6340 100644
--- a/www/datastore/DataStoreList.js
+++ b/www/datastore/DataStoreList.js
@@ -186,8 +186,13 @@ Ext.define('PBS.datastore.DataStores', {
applyState: function(state) {
let me = this;
- if (state.tab !== undefined) {
+ if (state.tab !== undefined && me.rendered) {
me.setActiveTab(state.tab);
+ } else if (state.tab) {
+ // if we are not rendered yet, defer setting the activetab
+ setTimeout(function() {
+ me.setActiveTab(state.tab);
+ }, 10);
}
},
@@ -228,4 +233,13 @@ Ext.define('PBS.datastore.DataStores', {
aclPath: '/datastore',
},
],
+
+ initComponent: function() {
+ let me = this;
+ // remove invalid activeTab settings
+ if (me.activeTab && !me.items.some((item) => item.itemId === me.activeTab)) {
+ delete me.activeTab;
+ }
+ me.callParent();
+ },
});
diff --git a/www/datastore/Panel.js b/www/datastore/Panel.js
index f0d1317c..d767656e 100644
--- a/www/datastore/Panel.js
+++ b/www/datastore/Panel.js
@@ -17,8 +17,13 @@ Ext.define('PBS.DataStorePanel', {
applyState: function(state) {
let me = this;
- if (state.tab !== undefined) {
+ if (state.tab !== undefined && me.rendered) {
me.setActiveTab(state.tab);
+ } else if (state.tab) {
+ // if we are not rendered yet, defer setting the activetab
+ setTimeout(function() {
+ me.setActiveTab(state.tab);
+ }, 10);
}
},
@@ -101,6 +106,10 @@ Ext.define('PBS.DataStorePanel', {
initComponent: function() {
let me = this;
me.title = `${gettext("Datastore")}: ${me.datastore}`;
+ // remove invalid activeTab settings
+ if (me.activeTab && !me.items.some((item) => item.itemId === me.activeTab)) {
+ delete me.activeTab;
+ }
me.callParent();
},
});
--
2.20.1
reply other threads:[~2020-11-10 13:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201110131616.3802-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox