]> git.proxmox.com Git - proxmox-backup.git/blame - www/datastore/Panel.js
ui: improve activeTab selection from fragment and state
[proxmox-backup.git] / www / datastore / Panel.js
CommitLineData
c0ac2074
DC
1Ext.define('PBS.DataStorePanel', {
2 extend: 'Ext.tab.Panel',
3 alias: 'widget.pbsDataStorePanel',
4 mixins: ['Proxmox.Mixin.CBind'],
5
6 cbindData: function(initalConfig) {
7 let me = this;
8 return {
9 aclPath: `/datastore/${me.datastore}`,
10 };
11 },
12
1dceaed1
DC
13 stateId: 'pbs-datastore-panel',
14 stateful: true,
15
16 stateEvents: ['tabchange'],
17
18 applyState: function(state) {
19 let me = this;
240b2ffb 20 if (state.tab !== undefined && me.rendered) {
1dceaed1 21 me.setActiveTab(state.tab);
240b2ffb
DC
22 } else if (state.tab) {
23 // if we are not rendered yet, defer setting the activetab
24 setTimeout(function() {
25 me.setActiveTab(state.tab);
26 }, 10);
1dceaed1
DC
27 }
28 },
29
30 getState: function() {
31 let me = this;
32 return {
33 tab: me.getActiveTab().getItemId(),
34 };
35 },
36
c0ac2074
DC
37 border: false,
38 defaults: {
39 border: false,
40 },
41
31112c79
DM
42 tools: [PBS.Utils.get_help_tool("datastore_intro")],
43
c0ac2074
DC
44 items: [
45 {
68931742
DC
46 xtype: 'pbsDataStoreSummary',
47 title: gettext('Summary'),
48 itemId: 'summary',
028d0a13 49 iconCls: 'fa fa-book',
3ea14859
DC
50 cbind: {
51 datastore: '{datastore}',
52 },
53 },
54 {
68931742
DC
55 xtype: 'pbsDataStoreContent',
56 itemId: 'content',
028d0a13 57 iconCls: 'fa fa-th',
c0ac2074
DC
58 cbind: {
59 datastore: '{datastore}',
60 },
61 },
1a0d3d11 62 {
cd828700 63 title: gettext('Prune & GC'),
68931742
DC
64 xtype: 'pbsDataStorePruneAndGC',
65 itemId: 'prunegc',
028d0a13
DC
66 iconCls: 'fa fa-trash-o',
67 cbind: {
68 datastore: '{datastore}',
69 },
70 },
71 {
72 iconCls: 'fa fa-refresh',
73 itemId: 'syncjobs',
74 xtype: 'pbsSyncJobView',
75 cbind: {
76 datastore: '{datastore}',
77 },
78 },
79 {
80 iconCls: 'fa fa-check-circle',
81 itemId: 'verifyjobs',
82 xtype: 'pbsVerifyJobView',
1a0d3d11
DM
83 cbind: {
84 datastore: '{datastore}',
85 },
86 },
b614b29b
TL
87 {
88 xtype: 'pbsDatastoreOptionView',
89 itemId: 'options',
90 title: gettext('Options'),
91 iconCls: 'fa fa-cog',
92 cbind: {
93 datastore: '{datastore}',
94 },
95 },
c0ac2074
DC
96 {
97 itemId: 'acl',
98 xtype: 'pbsACLView',
028d0a13 99 iconCls: 'fa fa-unlock',
c0ac2074
DC
100 cbind: {
101 aclPath: '{aclPath}',
102 },
103 },
104 ],
105
106 initComponent: function() {
107 let me = this;
58f950c5 108 me.title = `${gettext("Datastore")}: ${me.datastore}`;
240b2ffb
DC
109 // remove invalid activeTab settings
110 if (me.activeTab && !me.items.some((item) => item.itemId === me.activeTab)) {
111 delete me.activeTab;
112 }
c0ac2074
DC
113 me.callParent();
114 },
115});