From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <l.wagner@proxmox.com>
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 83E449D7E8
 for <pbs-devel@lists.proxmox.com>; Fri, 24 Nov 2023 11:36:09 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 65108C749
 for <pbs-devel@lists.proxmox.com>; Fri, 24 Nov 2023 11:36:09 +0100 (CET)
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) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pbs-devel@lists.proxmox.com>; Fri, 24 Nov 2023 11:36:07 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0D5FD43A99
 for <pbs-devel@lists.proxmox.com>; Fri, 24 Nov 2023 11:36:07 +0100 (CET)
Message-ID: <4219ee34-147e-4112-bcd2-3aaa5d6fcfd9@proxmox.com>
Date: Fri, 24 Nov 2023 11:36:06 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: Lukas Wagner <l.wagner@proxmox.com>
To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>, Hannes Laimer <h.laimer@proxmox.com>
References: <20231121143155.370916-1-h.laimer@proxmox.com>
 <20231121143155.370916-7-h.laimer@proxmox.com>
Content-Language: de-AT, en-US
In-Reply-To: <20231121143155.370916-7-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 -0.008 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [proxmox.com, values.id, sencha.com]
Subject: Re: [pbs-devel] [PATCH proxmox-backup v6 6/6] ui: add support for
 optional Remote in SyncJob
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 24 Nov 2023 10:36:09 -0000



On 11/21/23 15:31, Hannes Laimer wrote:
> diff --git a/www/Utils.js b/www/Utils.js
> index 2eca600e..d7f11cb6 100644
> --- a/www/Utils.js
> +++ b/www/Utils.js
> @@ -711,6 +711,11 @@ Ext.define('PBS.Utils', {
>   	return Ext.String.htmlEncode(value);
>       },
>   
> +    render_optional_remote: function(value, metadata, record) {
Nit: New functions/variables should use camelCase, see
https://pve.proxmox.com/wiki/Javascript_Style_Guide#Casing

> +	if (!value) return `- (${gettext('Local')})`;
Nit: Don't use single-line if statements for new code, see
https://pve.proxmox.com/wiki/Javascript_Style_Guide#Single-Line_If-Statement

> +	return Ext.String.htmlEncode(value);
> +    },
> + >       tuningOptions: {
>   	'chunk-order': {
>   	    '__default__': Proxmox.Utils.defaultText + ` (${gettext('Inode')})`,
> diff --git a/www/config/SyncView.js b/www/config/SyncView.js
> index bf9072cb..c6458a9e 100644
> --- a/www/config/SyncView.js
> +++ b/www/config/SyncView.js
> @@ -208,6 +208,7 @@ Ext.define('PBS.config.SyncJobView', {
>   	    dataIndex: 'remote',
>   	    width: 120,
>   	    sortable: true,
> +	    renderer: PBS.Utils.render_optional_remote,
>   	},
>   	{
>   	    header: gettext('Remote Store'),

(...)

>   
> +    setValues: function(values) {
> +	let me = this;
> +	if (values.id && !values.remote) {
> +	    values.location = 'local';
> +	} else {
> +	    values.location = 'remote';
> +	}
> +	me.callParent([values]);
> +    },
>   
>       items: {
>   	xtype: 'tabpanel',
> @@ -134,16 +143,76 @@ Ext.define('PBS.window.SyncJobEdit', {
>   		],
>   
>   		column2: [
> +		    {
> +			xtype: 'radiogroup',
> +			fieldLabel: gettext('Location'),
> +			defaultType: 'radiofield',
> +			items: [
> +			    {
> +				boxLabel: 'Local',
> +				name: 'location',
> +				inputValue: 'local',
> +				submitValue: false,
> +			    },
> +			    {
> +				boxLabel: 'Remote',
> +				name: 'location',
> +				inputValue: 'remote',
> +				submitValue: false,
> +				checked: true,
> +			    },
> +			],
> +			listeners: {
> +			    change: function(_group, radio) {

Nit: This component already has a controller, including a 'control'
section for event routing - I guess it would be cleaner
if this function was part of the controller, triggered
by an entry for 'control'?

See:
https://docs-devel.sencha.com/extjs/7.0.0/classic/Ext.app.ViewController.html#cfg-control

However, it seems like other form elements here already use the same 
approach as you, so I guess it's fine.

> +				let me = this;
> +				let form = me.up('pbsSyncJobEdit');
> +				let nsField = form.down('field[name=remote-ns]');
> +				let rateLimitField = form.down('field[name=rate-in]');
> +				let remoteField = form.down('field[name=remote]');
> +				let storeField = form.down('field[name=remote-store]');
> +

(...)

-- 
- Lukas