[pbs-devel] [PATCH proxmox-backup v6 6/6] ui: add support for optional Remote in SyncJob

Lukas Wagner l.wagner at proxmox.com
Fri Nov 24 11:36:06 CET 2023



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





More information about the pbs-devel mailing list