add upload button conditionally

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2020-11-13 14:16:23 +01:00 committed by Thomas Lamprecht
parent dbeddeb322
commit 8798c35bcd
2 changed files with 6 additions and 9 deletions

View File

@ -80,6 +80,7 @@ Ext.define('PVE.storage.Browser', {
content: 'iso', content: 'iso',
stateful: true, stateful: true,
stateId: 'grid-storage-content-iso', stateId: 'grid-storage-content-iso',
useUploadButton: true,
}); });
} }
if (contents.includes('rootdir')) { if (contents.includes('rootdir')) {
@ -113,6 +114,7 @@ Ext.define('PVE.storage.Browser', {
content: 'vztmpl', content: 'vztmpl',
stateful: true, stateful: true,
stateId: 'grid-storage-content-vztmpl', stateId: 'grid-storage-content-vztmpl',
useUploadButton: true,
}); });
} }
me.insertNodes(items); me.insertNodes(items);

View File

@ -440,24 +440,17 @@ Ext.define('PVE.storage.ContentView', {
} }
var uploadButton = Ext.create('Proxmox.button.Button', { var uploadButton = Ext.create('Proxmox.button.Button', {
contents : ['iso','vztmpl'],
text: gettext('Upload'), text: gettext('Upload'),
handler: function() { handler: function() {
var me = this;
var win = Ext.create('PVE.storage.Upload', { var win = Ext.create('PVE.storage.Upload', {
nodename: nodename, nodename: nodename,
storage: storage, storage: storage,
contents: me.contents contents: [content],
}); });
win.show(); win.show();
win.on('destroy', reload); win.on('destroy', reload);
} }
}); });
if (content === 'iso' || content === 'vztmpl') {
uploadButton.contents = [content];
} else {
uploadButton.setDisabled(true);
}
var imageRemoveButton; var imageRemoveButton;
var removeButton = Ext.create('Proxmox.button.StdRemoveButton',{ var removeButton = Ext.create('Proxmox.button.StdRemoveButton',{
@ -530,6 +523,9 @@ Ext.define('PVE.storage.ContentView', {
if (!me.tbar) { if (!me.tbar) {
me.tbar = []; me.tbar = [];
} }
if (me.useUploadButton) {
me.tbar.push(uploadButton);
}
me.tbar.push( me.tbar.push(
{ {
xtype: 'proxmoxButton', xtype: 'proxmoxButton',
@ -562,7 +558,6 @@ Ext.define('PVE.storage.ContentView', {
removeButton, removeButton,
imageRemoveButton, imageRemoveButton,
templateButton, templateButton,
uploadButton,
{ {
xtype: 'proxmoxButton', xtype: 'proxmoxButton',
text: gettext('Show Configuration'), text: gettext('Show Configuration'),