[pve-devel] [PATCH pve-manager] fix #4228: Display warning when user rollbacks a running container.

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Sep 7 09:59:03 CEST 2022


The respective bug report isn't only talking about adding a warning, so please
either add some rational for why the other idea wasn't indeed not good or note
somewhere that this is indeed a partial fix (which is often totally fine to do).

Am 06/09/2022 um 14:43 schrieb Stefan Hanreich:
> Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
> ---
> I would love to put parentheses around the ternary expression at line
> 265, but eslint complains about unnecessary parentheses. Disabling an
> eslint rule is probably not so exciting for my first contribution, even
> if it would be for only one line.

no need for parenthesis here, but you could just avoid using the ternary if
it irks you and do a normal

let foo = 'default';
if (condition) {
    foo = 'something else';
}

making it less code golfy.

> 
>  www/manager6/tree/SnapshotTree.js | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/www/manager6/tree/SnapshotTree.js b/www/manager6/tree/SnapshotTree.js
> index 97268072..d2fd50d7 100644
> --- a/www/manager6/tree/SnapshotTree.js
> +++ b/www/manager6/tree/SnapshotTree.js
> @@ -259,8 +259,16 @@ Ext.define('PVE.guest.SnapshotTree', {
>  		let view = this.up('treepanel');
>  		let rec = view.getSelection()[0];
>  		let vmid = view.getViewModel().get('vmid');
> -		return Proxmox.Utils.format_task_description('qmrollback', vmid) +
> -		    ` '${rec.data.name}'? ${gettext("Current state will be lost.")}`;
> +
> +		let type = view.getViewModel().get('type');
> +		let isRunning = view.getViewModel().get('running');
> +		let containerWarning = type === 'lxc' && isRunning

would name it extraWarning, also what about VMs, they also loose their current state
on rollback and effectively will be stopped/reset to load the new state (which isn't
much difference in state/availabillity outcome compared to CTs).

Why not differ just between running and not, ignoring the type, e.g. something like

let warning = isRunning
    ? gettext("The guest is currently running and will be stopped!")
    : gettext("Current state will be lost.")

> +		    ? `<br/>${gettext("The container is currently running and will be stopped!")}`
> +		    : ``;
> +
> +		return Proxmox.Utils.format_task_description('qmrollback', vmid)
> +		    + ` '${rec.data.name}'? ${gettext("Current state will be lost.")}`
> +		    + containerWarning
>  	    },
>  	    handler: 'rollback',
>  	},






More information about the pve-devel mailing list