Commit 84ab7b8b authored by Dietmar Maurer's avatar Dietmar Maurer

correct handle history state for ceph sub-config

parent 98d00253
...@@ -882,6 +882,21 @@ Ext.define('PVE.node.Ceph', { ...@@ -882,6 +882,21 @@ Ext.define('PVE.node.Ceph', {
throw "no node name specified"; throw "no node name specified";
} }
if (!me.phstateid) {
throw "no parent history state specified";
}
var sp = Ext.state.Manager.getProvider();
var state = sp.get(me.phstateid);
var hsregex = /^ceph-(\S+)$/;
if (state && state.value) {
var res = hsregex.exec(state.value);
if (res && res[1]) {
me.activeTab = res[1];
}
}
Ext.apply(me, { Ext.apply(me, {
plain: true, plain: true,
tabPosition: 'bottom', tabPosition: 'bottom',
...@@ -938,11 +953,38 @@ Ext.define('PVE.node.Ceph', { ...@@ -938,11 +953,38 @@ Ext.define('PVE.node.Ceph', {
if (first) { if (first) {
first.fireEvent('show', first); first.fireEvent('show', first);
} }
},
tabchange: function(tp, newcard, oldcard) {
var first = tp.items.get(0);
var ntab;
// Note: '' is alias for first tab.
if (newcard.itemId === first.itemId) {
ntab = 'ceph';
} else {
ntab = 'ceph-' + newcard.itemId;
}
var state = { value: ntab };
sp.set(me.phstateid, state);
} }
} }
}); });
me.callParent(); me.callParent();
var statechange = function(sp, key, state) {
if ((key === me.phstateid) && state) {
var first = me.items.get(0);
var atab = me.getActiveTab().itemId;
var res = hsregex.exec(state.value);
var ntab = (res && res[1]) ? res[1] : first.itemId;
if (ntab && (atab != ntab)) {
me.setActiveTab(ntab);
}
}
};
me.mon(sp, 'statechange', statechange);
} }
}); });
\ No newline at end of file
...@@ -158,6 +158,7 @@ Ext.define('PVE.node.Config', { ...@@ -158,6 +158,7 @@ Ext.define('PVE.node.Config', {
title: 'Ceph', title: 'Ceph',
itemId: 'ceph', itemId: 'ceph',
xtype: 'pveNodeCeph', xtype: 'pveNodeCeph',
phstateid: me.hstateid,
nodename: nodename nodename: nodename
}]); }]);
} }
......
...@@ -11,10 +11,15 @@ Ext.define('PVE.panel.Config', { ...@@ -11,10 +11,15 @@ Ext.define('PVE.panel.Config', {
var activeTab; var activeTab;
var hsregex = /^([^\-\s]+)(-\S+)?$/;
if (stateid) { if (stateid) {
var state = sp.get(stateid); var state = sp.get(stateid);
if (state && state.value) { if (state && state.value) {
activeTab = state.value; var res = hsregex.exec(state.value);
if (res && res[1]) {
activeTab = res[1];
}
} }
} }
...@@ -70,13 +75,14 @@ Ext.define('PVE.panel.Config', { ...@@ -70,13 +75,14 @@ Ext.define('PVE.panel.Config', {
}, },
tabchange: function(tp, newcard, oldcard) { tabchange: function(tp, newcard, oldcard) {
var ntab = newcard.itemId; var ntab = newcard.itemId;
// Note: '' is alias for first tab. // Note: '' is alias for first tab.
// First tab can be 'search' or something else // First tab can be 'search' or something else
if (newcard.itemId === items[0].itemId) { if (newcard.itemId === items[0].itemId) {
ntab = ''; ntab = '';
} }
var state = { value: ntab }; var state = { value: ntab };
if (stateid) { if (stateid && !newcard.phstateid) {
sp.set(stateid, state); sp.set(stateid, state);
} }
} }
...@@ -91,10 +97,11 @@ Ext.define('PVE.panel.Config', { ...@@ -91,10 +97,11 @@ Ext.define('PVE.panel.Config', {
me.callParent(); me.callParent();
var statechange = function(sp, key, state) { var statechange = function(sp, key, state) {
if (stateid && key === stateid) { if (stateid && (key === stateid) && state) {
var atab = tab.getActiveTab().itemId; var atab = tab.getActiveTab().itemId;
var ntab = state.value || items[0].itemId; var res = hsregex.exec(state.value);
if (state && ntab && (atab != ntab)) { var ntab = (res && res[1]) ? res[1] : items[0].itemId;
if (ntab && (atab != ntab)) {
tab.setActiveTab(ntab); tab.setActiveTab(ntab);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment