* [pve-devel] [PATCH manager] storage: base edit: Use the GUI keep-all default value
@ 2020-11-25 11:36 Dominic Jäger
2020-11-25 12:25 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dominic Jäger @ 2020-11-25 11:36 UTC (permalink / raw)
To: pve-devel
... if the user hasn't seen the prune panel yet.
The GUI has as default value a ticked keep-all checkbox => keep-all=1.
Previously we sent nothing in this case which led to the no-keeps default of
keep-last=1.
Furthermore, refactor so that "The always delete old 'maxfiles' on edit" is now
clearly visible even without comment.
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
www/manager6/storage/Base.js | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 80bc8002..0ad54817 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -66,19 +66,33 @@ Ext.define('PVE.panel.StoragePruneInputPanel', {
onGetValues: function(formValues) {
delete formValues.delete;
- let retention = PVE.Parser.printPropertyString(formValues)
+ let retention = PVE.Parser.printPropertyString(formValues);
+ let isEdit = !this.isCreate;
+ let options = { };
if (retention === '') {
- if (this.isCreate) {
- return {};
+ if (isEdit) {
+ options.delete = 'prune-backups';
+ } else {
+ let checkbox = this.down('proxmoxcheckbox[name=keep-all]');
+ // Checkbox gets its default value true after being rendered (listener)
+ // Rendered => User saw (& potentially changed) the value => use it
+ // Otherwise use default (hardcoded, because default is not yet
+ // assigned to the checkbox)
+ let value = checkbox.rendered ? checkbox.getValue() : 'keep-all=1';
+ console.assert(value);
+ options['prune-backups'] = value;
}
- // always delete old 'maxfiles' on edit, we map it to keep-last on window load
- return {
- delete: ['prune-backups','maxfiles'],
- };
+ } else {
+ options['prune-backups'] = retention;
}
- let options = { 'prune-backups': retention };
- if (!this.isCreate) {
- options.delete = 'maxfiles';
+ // always delete old 'maxfiles' on edit, we map it to keep-last on window load
+ if (isEdit) {
+ if (options.delete) {
+ // here isEdit = true
+ options.delete = [options.delete].concat('maxfiles');
+ } else {
+ options.delete = 'maxfiles';
+ }
}
return options;
},
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pve-devel] [PATCH manager] storage: base edit: Use the GUI keep-all default value
2020-11-25 11:36 [pve-devel] [PATCH manager] storage: base edit: Use the GUI keep-all default value Dominic Jäger
@ 2020-11-25 12:25 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2020-11-25 12:25 UTC (permalink / raw)
To: Proxmox VE development discussion, Dominic Jäger
On 25.11.20 12:36, Dominic Jäger wrote:
> ... if the user hasn't seen the prune panel yet.
> The GUI has as default value a ticked keep-all checkbox => keep-all=1.
> Previously we sent nothing in this case which led to the no-keeps default of
> keep-last=1.
>
> Furthermore, refactor so that "The always delete old 'maxfiles' on edit" is now
> clearly visible even without comment.
I applied a fix for another issue when editing storages which do not
support this settings at all, maybe we could just add a else-if to that
with a `this.isCreate && this.rendered` check and returning:
return { 'prune-backups': 'keep-all=1' };
(on create deletion is not supported anyway, so should be fine)
>
> Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
> ---
> www/manager6/storage/Base.js | 34 ++++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
> index 80bc8002..0ad54817 100644
> --- a/www/manager6/storage/Base.js
> +++ b/www/manager6/storage/Base.js
> @@ -66,19 +66,33 @@ Ext.define('PVE.panel.StoragePruneInputPanel', {
>
> onGetValues: function(formValues) {
> delete formValues.delete;
> - let retention = PVE.Parser.printPropertyString(formValues)
> + let retention = PVE.Parser.printPropertyString(formValues);
> + let isEdit = !this.isCreate;
> + let options = { };
> if (retention === '') {
> - if (this.isCreate) {
> - return {};
> + if (isEdit) {
> + options.delete = 'prune-backups';
> + } else {
> + let checkbox = this.down('proxmoxcheckbox[name=keep-all]');
> + // Checkbox gets its default value true after being rendered (listener)
> + // Rendered => User saw (& potentially changed) the value => use it
> + // Otherwise use default (hardcoded, because default is not yet
> + // assigned to the checkbox)
> + let value = checkbox.rendered ? checkbox.getValue() : 'keep-all=1';
> + console.assert(value);
> + options['prune-backups'] = value;
> }
> - // always delete old 'maxfiles' on edit, we map it to keep-last on window load
> - return {
> - delete: ['prune-backups','maxfiles'],
> - };
> + } else {
> + options['prune-backups'] = retention;
> }
> - let options = { 'prune-backups': retention };
> - if (!this.isCreate) {
> - options.delete = 'maxfiles';
> + // always delete old 'maxfiles' on edit, we map it to keep-last on window load
> + if (isEdit) {
> + if (options.delete) {
> + // here isEdit = true
> + options.delete = [options.delete].concat('maxfiles');
> + } else {
> + options.delete = 'maxfiles';
> + }
> }
> return options;
> },
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-25 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 11:36 [pve-devel] [PATCH manager] storage: base edit: Use the GUI keep-all default value Dominic Jäger
2020-11-25 12:25 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox