[pve-devel] [PATCH manager] fix #1814: do not enable disk related buttons for audit user
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Apr 10 10:01:05 CEST 2019
On 4/9/19 1:56 PM, Dominik Csapak wrote:
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
applied, with followup to not disable the add button completely, disk cap
is not a guarantee that one cannot add resources in general (in the future
may be more here)...
Also, the commit subject is a bit confusing, audit user only correlate with
this cap, and thus you rightfully do not check for audit users but if the cap
is here...
> www/manager6/lxc/Resources.js | 8 +++++---
> www/manager6/qemu/HardwareView.js | 12 ++++++++----
> 2 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/www/manager6/lxc/Resources.js b/www/manager6/lxc/Resources.js
> index 65e4f641..f2c8d05d 100644
> --- a/www/manager6/lxc/Resources.js
> +++ b/www/manager6/lxc/Resources.js
> @@ -31,6 +31,7 @@ Ext.define('PVE.lxc.RessourceView', {
> }
>
> var caps = Ext.state.Manager.get('GuiCap');
> + var diskCap = caps.vms['VM.Config.Disk'];
>
> var mpeditor = caps.vms['VM.Config.Disk'] ? 'PVE.lxc.MountPointEdit' : undefined;
>
> @@ -238,9 +239,9 @@ Ext.define('PVE.lxc.RessourceView', {
> }
> edit_btn.setDisabled(noedit);
>
> - remove_btn.setDisabled(!isDisk || rec.data.key === 'rootfs');
> - resize_btn.setDisabled(!isDisk);
> - move_btn.setDisabled(!isDisk);
> + remove_btn.setDisabled(!isDisk || rec.data.key === 'rootfs' || !diskCap);
> + resize_btn.setDisabled(!isDisk || !diskCap);
> + move_btn.setDisabled(!isDisk || !diskCap);
>
> };
>
> @@ -277,6 +278,7 @@ Ext.define('PVE.lxc.RessourceView', {
> tbar: [
> {
> text: gettext('Add'),
> + disabled: !diskCap,
> menu: new Ext.menu.Menu({
> items: [
> {
> diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
> index ba588e37..f60ac7e3 100644
> --- a/www/manager6/qemu/HardwareView.js
> +++ b/www/manager6/qemu/HardwareView.js
> @@ -51,6 +51,7 @@ Ext.define('PVE.qemu.HardwareView', {
> }
>
> var caps = Ext.state.Manager.get('GuiCap');
> + var diskCap = caps.vms['VM.Config.Disk'];
>
> /*jslint confusion: true */
> var rows = {
> @@ -325,6 +326,9 @@ Ext.define('PVE.qemu.HardwareView', {
>
> var editor = rowdef.editor;
> if (rowdef.tdCls == 'pve-itype-icon-storage') {
> + if (!diskCap) {
> + return;
> + }
> var value = me.getObjectValue(rec.data.key, '', true);
> if (value.match(/vm-.*-cloudinit/)) {
> return;
> @@ -581,15 +585,15 @@ Ext.define('PVE.qemu.HardwareView', {
>
> var isEfi = (key === 'efidisk0');
>
> - remove_btn.setDisabled(rec.data['delete'] || (rowdef.never_delete === true));
> + remove_btn.setDisabled(rec.data['delete'] || (rowdef.never_delete === true) || (isUnusedDisk && !diskCap));
> remove_btn.setText((isUsedDisk && !isCloudInit) ? remove_btn.altText : remove_btn.defaultText);
> remove_btn.RESTMethod = isUnusedDisk ? 'POST':'PUT';
>
> - edit_btn.setDisabled(rec.data['delete'] || !rowdef.editor || isCloudInit);
> + edit_btn.setDisabled(rec.data['delete'] || !rowdef.editor || isCloudInit || !diskCap);
>
> - resize_btn.setDisabled(pending || !isUsedDisk);
> + resize_btn.setDisabled(pending || !isUsedDisk || !diskCap);
>
> - move_btn.setDisabled(pending || !isUsedDisk);
> + move_btn.setDisabled(pending || !isUsedDisk || !diskCap);
>
> revert_btn.setDisabled(!pending);
>
>
More information about the pve-devel
mailing list