]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: guest stop: show overrule checkbox also if no task is active
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 20 Apr 2024 18:15:03 +0000 (20:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 20 Apr 2024 18:32:32 +0000 (20:32 +0200)
The UI state about running tasks can be out of sync, especially for
situations where one quickly follows up with a stop, e.g. after
triggering a shutdown by mistake.

So, show the checkbox always for users that got Sys.Modify on (some)
node, but pre-check it still only if there where task detected on
component creation (we could watch the state though and show a hint,
but that's a bit over the top IMO).

Show it also when HA is enabled but explicitly disable it there,
hopefully this increases the chance that the users can understand that
this is done by design, and isn't a bug – ideally we would also show
an extra hint.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/window/GuestStop.js

index 82aed1a38c0fa164e3f47cd0c14fe630d03ed309..fbd45c7a59e1d40bf3767bac99a9a2d2343967e1 100644 (file)
@@ -24,14 +24,13 @@ Ext.define('PVE.GuestStop', {
 
        // offer to overrule if there is at least one matching shutdown task and the guest is not
        // HA-enabled. Also allow users to abort tasks started by one of their API tokens.
-       let shutdownTaskIdx = Ext.getStore('pve-cluster-tasks')?.findBy(task =>
+       let activeShutdownTask = Ext.getStore('pve-cluster-tasks')?.findBy(task =>
            (hasSysModify || task.data.user === Proxmox.UserName) &&
            task.data.id === me.vm.vmid.toString() &&
            task.data.status === undefined &&
            task.data.type === overruleTaskType,
-       );
+       ) !== -1;
        let haEnabled = me.vm.hastate && me.vm.hastate !== 'unmanaged';
-       me.askOverrule = !haEnabled && shutdownTaskIdx >= 0;
 
        me.callParent();
 
@@ -39,18 +38,21 @@ Ext.define('PVE.GuestStop', {
        me.promptContainer.add({
            xtype: 'proxmoxcheckbox',
            name: 'overrule-shutdown',
-           checked: true,
+           checked: !haEnabled && activeShutdownTask,
            boxLabel: gettext('Overrule active shutdown tasks'),
-           hidden: !me.askOverrule,
+           hidden: !(hasSysModify || activeShutdownTask),
+           disabled: !(hasSysModify || activeShutdownTask) || haEnabled,
+           padding: '3 0 0 0',
        });
     },
 
     handler: function(btn) {
        let me = this;
        if (btn === 'yes') {
-           let checkbox = me.promptContainer.down('proxmoxcheckbox[name=overrule-shutdown]');
-           let overruleShutdown = me.askOverrule && checkbox.getSubmitValue();
-           let params = overruleShutdown ? { 'overrule-shutdown': 1 } : undefined;
+           let overruleField = me.promptContainer.down('proxmoxcheckbox[name=overrule-shutdown]');
+           let params = !overruleField.isDisabled() && overruleField.getSubmitValue()
+               ? { 'overrule-shutdown': 1 }
+               : undefined;
            Proxmox.Utils.API2Request({
                url: me.url,
                waitMsgTarget: me,