* [pve-devel] [PATCH pve-manager] fix #4228: Display warning when user rollbacks a running container.
@ 2022-09-06 12:43 Stefan Hanreich
2022-09-07 7:59 ` Thomas Lamprecht
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hanreich @ 2022-09-06 12:43 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Stefan Hanreich <s.hanreich@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.
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
+ ? `<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',
},
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH pve-manager] fix #4228: Display warning when user rollbacks a running container.
2022-09-06 12:43 [pve-devel] [PATCH pve-manager] fix #4228: Display warning when user rollbacks a running container Stefan Hanreich
@ 2022-09-07 7:59 ` Thomas Lamprecht
2022-09-07 8:07 ` Thomas Lamprecht
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lamprecht @ 2022-09-07 7:59 UTC (permalink / raw)
To: Proxmox VE development discussion, Stefan Hanreich
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@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',
> },
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH pve-manager] fix #4228: Display warning when user rollbacks a running container.
2022-09-07 7:59 ` Thomas Lamprecht
@ 2022-09-07 8:07 ` Thomas Lamprecht
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2022-09-07 8:07 UTC (permalink / raw)
To: Proxmox VE development discussion, Stefan Hanreich
Am 07/09/2022 um 09:59 schrieb Thomas Lamprecht:
> 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.")
Send a bit to early, it would be naturally better to just add both
let warning = gettext("Current state will be lost!");
if (isRunning) {
warning += '<br>' + gettext("The guest is currently running and will be stopped!");
}
ps./nit: <br> tag only needs a / in xhtml documents, but not html5 and while we have
a bit of a mixed usage we prefer to use the shorter for new things.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-07 8:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 12:43 [pve-devel] [PATCH pve-manager] fix #4228: Display warning when user rollbacks a running container Stefan Hanreich
2022-09-07 7:59 ` Thomas Lamprecht
2022-09-07 8:07 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox