public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Aaron Lauterer <a.lauterer@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH v2 manager 1/3] ui: lxc/qemu: add disk reassign
Date: Fri, 4 Mar 2022 14:29:03 +0100	[thread overview]
Message-ID: <01a4001b-4f8e-1678-d460-b1846373085d@proxmox.com> (raw)
In-Reply-To: <ccf1d4db-f022-0a45-e8d3-3f8e8a9e8c7a@proxmox.com>



On 2/21/22 16:44, Dominik Csapak wrote:
> sorry for the late review
> 
> some comments inline
> 
> On 11/15/21 16:02, Aaron Lauterer wrote:
[...]
>> diff --git a/www/manager6/lxc/Resources.js
>> b/www/manager6/lxc/Resources.js index 15ee3c67..bec7cf14 100644 ---
>> a/www/manager6/lxc/Resources.js +++
>> b/www/manager6/lxc/Resources.js @@ -156,6 +156,11 @@
>> Ext.define('PVE.lxc.RessourceView', { return; } +        if
>> (rec.data.key.match(/^unused/)) { +        Ext.Msg.alert('Error',
>> gettext('Not yet supported for unused volumes')); +        return; 
>> +        } +
> 
> since we already hide/disable that button accordingly, why have that 
> error message at all? if the user somehow shows the button via the 
> browser console, the api will return an error anyway..
> 
> that way, we'd save a gettext

good point

> 

[..]

>> @@ -227,12 +250,40 @@ Ext.define('PVE.lxc.RessourceView', { }, }); 
>> -    var move_btn = new Proxmox.button.Button({ +    let
>> reassign_menuitem = new Ext.menu.Item({ +        text:
>> gettext('Reassign volume'), +        tooltip: gettext('Reassign
>> volume to another VM'), +        handler: run_reassign, +
>> iconCls: 'fa fa-mail-forward', +        reference:
>> 'reassing_item', +    }); + +    let move_btn = new
>> PVE.button.Split({ text: gettext('Move Volume'), selModel:
>> me.selModel, disabled: true, dangerous: true, handler: run_move, +
>> menu: { +        items: [reassign_menuitem], +        }, +    }); 
>> + +    // needed until we can move unused volumes to other
>> storages +    let reassign_btn = new Proxmox.button.Button({ +
>> text: gettext('Reassign volume'), +        tooltip:
>> gettext('Reassign volume to another VM'), +        handler:
>> run_reassign, +        selModel: me.selModel, +        hidden:
>> true, +        listeners: { +        render: function(btn) { +
>> // hack: avoid layout-flickering due to size change, use max width
>> for both +            let maxWidth = Math.max(btn.getSize().width,
>> move_btn.getSize().width); +            move_btn.setSize({ width:
>> maxWidth }); +            btn.setSize({ width: maxWidth });
> 
> mhmm... while for remove/detach disks this seems to work ok, for this
> the gettext are so different, the reassign button look very weird..
> 
> maybe putting both in a menu (where the top button itself has no
> action) and disable accordingly would make more sense here?
> 
> i.e. Volume/Disk Actions - Resize - Move - relocate
> 
> ?

Sounds like a good plan and as quickly discussed off list, will also make it easier to look consistent in different transla
tions.

> [...]
>> diff --git a/www/manager6/qemu/HDReassign.js
>> b/www/manager6/qemu/HDReassign.js new file mode 100644 index
>> 00000000..e6b59cb4
[..]

>> + +    reassign_disk: function(values) {
> 
> this should probably be 'reassignDisk' according to our usual naming
> scheme

thx for catching that

> 
>> +        let me = this; +        let view = me.getView(); +
>> let qemu = view.qemu; +        let params = { +        vmid:
>> view.vmid, +        'target-vmid': values.targetVmid, +        }; 
>> + +        params[qemu ? 'disk' : 'volume'] = view.disk; + +
>> if (view.qemu) { +        params['target-disk'] =
>> `${values.controller}${values.deviceid}`; +        } else { +
>> params['target-volume'] = `${values.mpType}${values.mpId}`; +
>> } + +        let url =
>> `/nodes/${view.nodename}/${view.type}/${view.vmid}/`; +        url
>> += qemu ? 'move_disk' : 'move_volume'; + +
>> Proxmox.Utils.API2Request({ +        params: params, +        url:
>> url, +        waitMsgTarget: me.getView(), +        method:
>> 'POST', +        failure: response => Ext.Msg.alert('Error',
>> response.htmlStatus), +        success: function(response, options)
>> { +            let upid = response.result.data; +
>> view.hide(); +            Ext.create('Proxmox.window.TaskProgress',
>> { +            upid, +            autoShow: true, +
>> taskDone: success => success ? view.close() : view.show(),
> 
> so if the task is not successful, we show ourselves again (over the
> error of the progress window)? what about the task log window (if
> opened)?

As discussed off list, closing the window always is what we want. In case of errors, we do see the error window or have the task log opened.

> 
>> +            }); +        }, +        }); +    }, + +
>> validateForm: function(fp, isValid) { +
>> this.getView().lookup('submitButton').setDisabled(!isValid); +
>> }, + +    onReassignClick: function() { +        let me = this; +
>> let view = me.getView(); +        let form =
>> view.lookup('moveFormPanel').getForm(); +        if
>> (form.isValid()) { +
>> me.reassign_disk(form.getValues()); +        } +    }, + +
>> onMpTypeChange: function(value) { +
>> this.getView().getViewModel().set('mpType', value.getValue()); +
>> this.getView().lookup('mpIdSelector').validate(); +    },
> 
> these functions make me question if it wouldn't have been easier to
> use an 'edit window' instead? any reason for that?

It has been a while since I sent these patches, but I think there were a few reasons to go with a regular window. One of them IIRC was that, similar to the resize and move windows, we also want to show a custom labeled button "Reassign {Volume|Disk}"  instead of "OK" or one of the options we have with the edit window.

> 
>> + +    onTargetVMChange: function(f, vmid) { +        let me =
>> this; +        let view = me.getView(); +        let diskSelector =
>> view.lookup('diskSelector'); +        if (!vmid) { +
>> diskSelector.setVMConfig(null); +        me.VMConfig = null; +
>> return; +        } + +        let type = view.type === 'qemu' ?
>> 'qemu' : 'lxc';
> 
> here you use 'view.type' but above you use 'view.qemu' ? i'd prefer
> to have a consistent way of checking the type

True, I also found another instance and aligned them.

[...]
>> listeners: { +        validitychange: 'validateForm', +        }, +
>> items: [ +        { +            xtype: 'displayfield', +
>> name: 'sourceDisk', +            cbind: { +            name: get =>
>> get('isQemu') ? 'disk' : 'volume', +            fieldLabel: get =>
>> get('isQemu') +                ? gettext('Source Disk') +
>> : gettext('Source Mount Point'),
> 
> wouldn't 'Source' suffice for both? IMHO the context is enough that
> the user knows that it's a disk/mp

Good point





  reply	other threads:[~2022-03-04 13:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 15:02 [pve-devel] [PATCH v2 manager 0/3] ui: lxc/qemu: add reassign for disks and volumes Aaron Lauterer
2021-11-15 15:02 ` [pve-devel] [PATCH v2 manager 1/3] ui: lxc/qemu: add disk reassign Aaron Lauterer
2022-02-21 15:44   ` Dominik Csapak
2022-03-04 13:29     ` Aaron Lauterer [this message]
2022-03-04 13:32       ` Dominik Csapak
2021-11-15 15:02 ` [pve-devel] [PATCH v2 manager 2/3] ui: BusTypeSelector: change noVirtIO to withVirtIO Aaron Lauterer
2021-11-15 15:02 ` [pve-devel] [PATCH v2 manager] ui: hdmove: modernize/refactor Aaron Lauterer
2022-02-22  9:46   ` Dominik Csapak
2022-01-17 10:20 ` [pve-devel] [PATCH v2 manager 0/3] ui: lxc/qemu: add reassign for disks and volumes Aaron Lauterer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01a4001b-4f8e-1678-d460-b1846373085d@proxmox.com \
    --to=a.lauterer@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal