From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pmg-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id B9E401FF18E
	for <inbox@lore.proxmox.com>; Tue, 25 Feb 2025 16:12:39 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 95FC42830B;
	Tue, 25 Feb 2025 16:12:38 +0100 (CET)
Date: Tue, 25 Feb 2025 16:12:05 +0100
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>
Message-ID: <20250225161205.2e3df05d@rosa.proxmox.com>
In-Reply-To: <20250225141652.4166377-1-d.csapak@proxmox.com>
References: <20250225141652.4166377-1-d.csapak@proxmox.com>
X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu)
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.066 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
Subject: Re: [pmg-devel] [PATCH widget-toolkit] object grid: fix onlineHelp
 setting from editorConfig for row editors
X-BeenThere: pmg-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Mail Gateway development discussion
 <pmg-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pmg-devel>, 
 <mailto:pmg-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pmg-devel/>
List-Post: <mailto:pmg-devel@lists.proxmox.com>
List-Help: <mailto:pmg-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel>, 
 <mailto:pmg-devel-request@lists.proxmox.com?subject=subscribe>
Cc: pmg-devel@lists.proxmox.com
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pmg-devel-bounces@lists.proxmox.com
Sender: "pmg-devel" <pmg-devel-bounces@lists.proxmox.com>

Thanks for finding this so fast!

It fixes the vanished help-buttons throughout pmg-gui
(introduced in 573a6e8 ("add onlineHelp properties to all edit windows"))

did not check other users of the ObjectGrid - but from a look through
pmg-gui and the changes the patch looks good - so FWIW:
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>

On Tue, 25 Feb 2025 15:16:52 +0100
Dominik Csapak <d.csapak@proxmox.com> wrote:

> In our row editors helpers, we unconditionally set onlineHelp from
> 'opts.onlineHelp', even if it's undefined.
> 
> Later we use 'Ext.apply' to set first the editorConfig defaults, then
> the 'rowdef.editor' settings. In javascript, the objects
> 
> {} and
> { foo: undefined }
> 
> are not the same, so Ext.apply overwrites the default from editorConfig
> with that from the row definition, also for undefined.
> 
> This means if we have a default onlineHelp in editorConfig and none in
> the add_*_row options, we would not show it.
> 
> To fix it, check if 'opts.onlineHelp' is truthy before setting it in
> the row definition. This should not happen for other options used
> from the row helper options, since those are nested
> (Ext.apply does not work recursively)
> 
> This fixes a regression in pmg-gui, where we set a default onlineHelp
> for e.g. the Mail Proxy Options which would not show up anymore.
> 
> Note: PMG is the only product where we used this pattern, so this
> was not visible anywhere in PVE or PBS.
> 
> Fixes: 7d16f8b (object grid: allow to pass online help to row editors)
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/grid/ObjectGrid.js | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/src/grid/ObjectGrid.js b/src/grid/ObjectGrid.js
> index fa5fb92..2ed1dd2 100644
> --- a/src/grid/ObjectGrid.js
> +++ b/src/grid/ObjectGrid.js
> @@ -67,7 +67,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  	    editor: {
>  		xtype: 'proxmoxWindowEdit',
>  		subject: text,
> -		onlineHelp: opts.onlineHelp,
>  		fieldDefaults: {
>  		    labelWidth: opts.labelWidth || 100,
>  		},
> @@ -84,6 +83,9 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  		},
>  	    },
>  	};
> +	if (opts.onlineHelp) {
> +	    me.rows[name].editor.onlineHelp = opts.onlineHelp;
> +	}
>      },
>  
>      add_text_row: function(name, text, opts) {
> @@ -100,7 +102,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  	    editor: {
>  		xtype: 'proxmoxWindowEdit',
>  		subject: text,
> -		onlineHelp: opts.onlineHelp,
>  		fieldDefaults: {
>  		    labelWidth: opts.labelWidth || 100,
>  		},
> @@ -115,6 +116,9 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  		},
>  	    },
>  	};
> +	if (opts.onlineHelp) {
> +	    me.rows[name].editor.onlineHelp = opts.onlineHelp;
> +	}
>      },
>  
>      add_boolean_row: function(name, text, opts) {
> @@ -131,7 +135,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  	    editor: {
>  		xtype: 'proxmoxWindowEdit',
>  		subject: text,
> -		onlineHelp: opts.onlineHelp,
>  		fieldDefaults: {
>  		    labelWidth: opts.labelWidth || 100,
>  		},
> @@ -147,6 +150,9 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  		},
>  	    },
>  	};
> +	if (opts.onlineHelp) {
> +	    me.rows[name].editor.onlineHelp = opts.onlineHelp;
> +	}
>      },
>  
>      add_integer_row: function(name, text, opts) {
> @@ -163,7 +169,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  	    editor: {
>  		xtype: 'proxmoxWindowEdit',
>  		subject: text,
> -		onlineHelp: opts.onlineHelp,
>  		fieldDefaults: {
>  		    labelWidth: opts.labelWidth || 100,
>  		},
> @@ -180,6 +185,9 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  		},
>  	    },
>  	};
> +	if (opts.onlineHelp) {
> +	    me.rows[name].editor.onlineHelp = opts.onlineHelp;
> +	}
>      },
>  
>      // adds a row that allows editing in a full TextArea that transparently de/encodes as Base64
> @@ -198,7 +206,6 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  	    editor: {
>  		xtype: 'proxmoxWindowEdit',
>  		subject: text,
> -		onlineHelp: opts.onlineHelp,
>  		fieldDefaults: {
>  		    labelWidth: opts.labelWidth || 600,
>  		},
> @@ -209,6 +216,9 @@ Ext.define('Proxmox.grid.ObjectGrid', {
>  		},
>  	    },
>  	};
> +	if (opts.onlineHelp) {
> +	    me.rows[name].editor.onlineHelp = opts.onlineHelp;
> +	}
>      },
>  
>      editorConfig: {}, // default config passed to editor



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel