Commit c8e44125 authored by Dietmar Maurer's avatar Dietmar Maurer

enable buttons on capability changes

parent 1ade470d
...@@ -232,9 +232,9 @@ Ext.define('PVE.StdWorkspace', { ...@@ -232,9 +232,9 @@ Ext.define('PVE.StdWorkspace', {
var me = this; var me = this;
Ext.History.init(); Ext.History.init();
Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider'));
var caps = Ext.state.Manager.get('GuiCap'); var sprovider = Ext.create('PVE.StateProvider');
Ext.state.Manager.setProvider(sprovider);
var selview = new PVE.form.ViewSelector({}); var selview = new PVE.form.ViewSelector({});
...@@ -281,6 +281,40 @@ Ext.define('PVE.StdWorkspace', { ...@@ -281,6 +281,40 @@ Ext.define('PVE.StdWorkspace', {
} }
}); });
var caps = sprovider.get('GuiCap');
var createVM = Ext.createWidget('button', {
pack: 'end',
margins: '3 5 0 0',
baseCls: 'x-btn',
text: gettext("Create VM"),
disabled: !caps.vms['VM.Allocate'],
handler: function() {
var wiz = Ext.create('PVE.qemu.CreateWizard', {});
wiz.show();
}
});
var createCT = Ext.createWidget('button', {
pack: 'end',
margins: '3 5 0 0',
baseCls: 'x-btn',
text: gettext("Create CT"),
disabled: !caps.vms['VM.Allocate'],
handler: function() {
var wiz = Ext.create('PVE.openvz.CreateWizard', {});
wiz.show();
}
});
sprovider.on('statechange', function(sp, key, value) {
if (key === 'GuiCap' && value) {
caps = value;
createVM.setDisabled(!caps.vms['VM.Allocate']);
createCT.setDisabled(!caps.vms['VM.Allocate']);
}
});
Ext.apply(me, { Ext.apply(me, {
layout: { type: 'border' }, layout: { type: 'border' },
border: false, border: false,
...@@ -329,30 +363,8 @@ Ext.define('PVE.StdWorkspace', { ...@@ -329,30 +363,8 @@ Ext.define('PVE.StdWorkspace', {
rt.clearTree(); rt.clearTree();
} }
}, },
{ createVM,
pack: 'end', createCT
margins: '3 5 0 0',
xtype: 'button',
baseCls: 'x-btn',
text: gettext("Create VM"),
disabled: !caps.vms['VM.Allocate'],
handler: function() {
var wiz = Ext.create('PVE.qemu.CreateWizard', {});
wiz.show();
}
},
{
pack: 'end',
margins: '3 5 0 0',
xtype: 'button',
baseCls: 'x-btn',
text: gettext("Create CT"),
disabled: !caps.vms['VM.Allocate'],
handler: function() {
var wiz = Ext.create('PVE.openvz.CreateWizard', {});
wiz.show();
}
}
] ]
}, },
{ {
......
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