check if tabs exist before selecting them

when switching from a vm to a template, if you
have a tab selected which does not exists in a template
(for example console or task history) you break
the site

this patch checks if the wanted tab actually exists,
and leave it on default (the first) when it does not

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2016-06-01 16:17:07 +02:00 committed by Dietmar Maurer
parent ab5022deb4
commit e008e6e44f

View File

@ -23,7 +23,13 @@ Ext.define('PVE.panel.Config', {
var state = sp.get(stateid);
if (state && state.value) {
var res = hsregex.exec(state.value);
if (res && res[1]) {
if (res && res[1] && Ext.isArray(me.items)) {
me.items.forEach(function(item) {
if (item.itemId === res[1]) {
activeTab = res[1];
}
});
} else if (res && res[1] && me.items && me.items.itemId === res[1]) {
activeTab = res[1];
}
}