]> git.proxmox.com Git - pve-manager.git/commit
ui: migrate: fix disabled migrate button glitch
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 22 Jun 2023 12:15:12 +0000 (14:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 22 Jun 2023 12:50:30 +0000 (14:50 +0200)
commit6d727f81c8ca23b5cc6224389a5b2972891aecdf
tree2e178fb5eb49242ffdff32a91fbcc45ccfee8031
parentbbf3993334bfa9163a5b59be1eb0f4e58ac22cc1
ui: migrate: fix disabled migrate button glitch

under certain circumstances, the migrate button stays disabled, even
when a valid target node was selected:
* the first node that gets autoselected (most likely the second)
  is not a valid migration target
* the user changes to a migration target that is a valid one

if that happens, the migration button would stay disabled.
switching once to a non valid target and would enable the button.

To fix it, we have to do two things here:

'checkQemuPreconditions' is actually an async function that awaits an
api call and uses the result to set the 'migration.allowedNodes'
property

'checkMigratePreconditions' calls 'checkQemuPreconditions' and uses the
'migration.allowedNodes' property afterwards.

but since 'checkMigratePreconditions' is not async, that happens before
the api call can return the valid data and thus leaves it empty, making
all nodes valid in the selector. (thus the initial selected node is
valid)

instead make 'checkMigratePreconditions' also async and await the result
of 'checkQemuPreconditions'

this unearthed another issue, namely we access an object that is
possibly undefined (worked out before due to race conditions) so
fallback to an empty object.

and lastly, since we want the 'disallowedNodes' set before actually
checking the qemu preconditions, we move the setting of that on
the node selector above the qemu preconditions check
(this is the only place where we set it anyway, and the source does not
change, we probably could move that out of that function altogether)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/window/Migrate.js