From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E294071067 for ; Fri, 1 Oct 2021 10:36:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D959D29056 for ; Fri, 1 Oct 2021 10:36:32 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3DBB729048 for ; Fri, 1 Oct 2021 10:36:32 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 101D4453D5; Fri, 1 Oct 2021 10:36:32 +0200 (CEST) Message-ID: <612dc6f0-8ab4-d463-99cf-87b6dee3e55d@proxmox.com> Date: Fri, 1 Oct 2021 10:36:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Thunderbird/93.0 Content-Language: en-US To: Proxmox Backup Server development discussion , Hannes Laimer References: <20210928100548.4873-1-h.laimer@proxmox.com> <20210928100548.4873-6-h.laimer@proxmox.com> From: Dominik Csapak In-Reply-To: <20210928100548.4873-6-h.laimer@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 2.074 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -3.499 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH proxmox-backup 5/5] ui: add maintenance to datastore options X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2021 08:36:32 -0000 On 9/28/21 12:05, Hannes Laimer wrote: > --- > www/Makefile | 1 + > www/datastore/OptionView.js | 10 +++++ > www/window/MaintenanceOptions.js | 63 ++++++++++++++++++++++++++++++++ > 3 files changed, 74 insertions(+) > create mode 100644 www/window/MaintenanceOptions.js > > diff --git a/www/Makefile b/www/Makefile > index 4aec6e2c..8f6b17ed 100644 > --- a/www/Makefile > +++ b/www/Makefile > @@ -63,6 +63,7 @@ JSSRC= \ > window/BackupGroupChangeOwner.js \ > window/CreateDirectory.js \ > window/DataStoreEdit.js \ > + window/MaintenanceOptions.js \ > window/NotesEdit.js \ > window/RemoteEdit.js \ > window/NotifyOptions.js \ > diff --git a/www/datastore/OptionView.js b/www/datastore/OptionView.js > index 5a5e85be..1e0c3357 100644 > --- a/www/datastore/OptionView.js > +++ b/www/datastore/OptionView.js > @@ -1,3 +1,4 @@ > + > Ext.define('PBS.Datastore.Options', { > extend: 'Proxmox.grid.ObjectGrid', > xtype: 'pbsDatastoreOptionView', > @@ -111,5 +112,14 @@ Ext.define('PBS.Datastore.Options', { > }, > }, > }, > + "maintenance-type": { > + required: true, > + header: gettext('Maintenance mode'), > + defaultValue: 'Off', the default should probably be empty, no? Off should be handled by the renderer anyway > + renderer: (value) => Ext.String.capitalize(value) || 'Off', i would use that, but refactor the gettexts into e.g. Utils and write a renderer that maps it. that way we show the localized values here too > + editor: { > + xtype: 'pbsMaintenanceOptionEdit', > + }, > + }, > }, > }); > diff --git a/www/window/MaintenanceOptions.js b/www/window/MaintenanceOptions.js > new file mode 100644 > index 00000000..8ff5ccf9 > --- /dev/null > +++ b/www/window/MaintenanceOptions.js > @@ -0,0 +1,63 @@ > +Ext.define('PBS.form.MaintenanceType', { > + extend: 'Proxmox.form.KVComboBox', > + alias: 'widget.pbsMaintenanceType', > + > + comboItems: [ > + ['__default__', gettext('Off')], i think having 'Off' as no maintenance mode while also having 'Offline' will be confusing to some users. instead i'd use something like 'no maintenance' (at least as rendered value) > + ['readonly', gettext('Read Only')], > + ['offline', gettext('Offline')], > + ], > +}); > + > +Ext.define('PBS.window.MaintenanceOptions', { > + extend: 'Proxmox.window.Edit', > + xtype: 'pbsMaintenanceOptionEdit', > + mixins: ['Proxmox.Mixin.CBind'], > + > + subject: gettext('Maintenance mode'), > + > + width: 450, > + fieldDefaults: { > + labelWidth: 120, > + }, > + > + items: { > + xtype: 'inputpanel', > + onGetValues: function(values) { > + PBS.Utils.delete_if_default(values, 'maintenance-type', ''); > + PBS.Utils.delete_if_default(values, 'maintenance-msg', ''); > + if (values.delete) { > + values.delete = values.delete.split(','); > + } this is unnecessary, since the 'delete_if_default' should already make this an array if necessary it even blocked me from submitting the form, since 'split' is not a function of an array... > + > + return values; > + }, > + items: [ > + { > + xtype: 'pbsMaintenanceType', > + name: 'maintenance-type', > + fieldLabel: gettext('Maintenance Type'), > + value: '__default__', > + deleteEmpty: true, > + }, > + { > + xtype: 'textfield', > + emptyText: 'none', i'd leave that out, since we don't do it with comments either > + name: 'maintenance-msg', > + fieldLabel: gettext('Description'), > + value: '__default__', that should be empty? then you also don't need the 'delete_if_default' for the message since you set deleteEmpty also i think we should disable that field for the 'Off' variant since it does not make sense to have a maintenance message for no maintenance mode... > + deleteEmpty: true > + }, > + ], > + }, > + setValues: function(values) { > + let me = this; > + > + const options = { > + 'maintenance-type': values['maintenance-type'] || '__default__', > + 'maintenance-msg': values['maintenance-msg'], > + }; > + > + me.callParent([options]); > + }, > +}); >