From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 3D5611FF168 for ; Tue, 12 Nov 2024 15:42:19 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A614F2C9AC; Tue, 12 Nov 2024 15:42:01 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 12 Nov 2024 15:41:53 +0100 Message-Id: <20241112144156.3192720-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241112144156.3192720-1-d.csapak@proxmox.com> References: <20241112144156.3192720-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.014 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH widget-toolkit 2/5] webhook edit: make items config not static X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" modifying static elements from the class, like done here with e.g. me.items[0][key] = value; is dangerous, since it directly modifies the class definition of those arrays/objects. Instead move the definition in initComponent, which uses a fresh declaration each time the component is initialized. Signed-off-by: Dominik Csapak --- src/panel/WebhookEditPanel.js | 143 +++++++++++++++++----------------- 1 file changed, 73 insertions(+), 70 deletions(-) diff --git a/src/panel/WebhookEditPanel.js b/src/panel/WebhookEditPanel.js index b440d7f..fcc5b06 100644 --- a/src/panel/WebhookEditPanel.js +++ b/src/panel/WebhookEditPanel.js @@ -318,90 +318,93 @@ Ext.define('Proxmox.form.WebhookKeyValueList', { }, }, - items: [ - { - xtype: 'grid', - reference: 'grid', - minHeight: 100, - maxHeight: 100, - scrollable: 'vertical', - - viewConfig: { - deferEmptyText: false, - }, - - store: { - listeners: { - update: function() { - this.commitChanges(); - }, - }, - }, - margin: '5 0 5 0', - }, - { - xtype: 'button', - text: gettext('Add'), - iconCls: 'fa fa-plus-circle', - handler: 'addLine', - }, - ], - initComponent: function() { let me = this; - for (const [key, value] of Object.entries(me.gridConfig ?? {})) { - me.items[0][key] = value; - } - - me.items[0].columns = [ + let items = [ { - header: me.fieldTtitle, - dataIndex: 'headerName', - xtype: 'widgetcolumn', - widget: { - xtype: 'textfield', - isFormField: false, - maskRe: me.maskRe, - allowBlank: false, - queryMode: 'local', + xtype: 'grid', + reference: 'grid', + minHeight: 100, + maxHeight: 100, + scrollable: 'vertical', + + viewConfig: { + deferEmptyText: false, + }, + + store: { listeners: { - change: 'itemChange', + update: function() { + this.commitChanges(); + }, }, }, - flex: 1, - }, - { - header: me.fieldTtitle, - dataIndex: 'headerValue', - xtype: 'widgetcolumn', - widget: { - xtype: 'proxmoxtextfield', - inputType: me.maskValues ? 'password' : 'text', - isFormField: false, - maskRe: me.maskRe, - queryMode: 'local', - listeners: { - change: 'itemChange', + margin: '5 0 5 0', + columns: [ + { + header: me.fieldTtitle, + dataIndex: 'headerName', + xtype: 'widgetcolumn', + widget: { + xtype: 'textfield', + isFormField: false, + maskRe: me.maskRe, + allowBlank: false, + queryMode: 'local', + listeners: { + change: 'itemChange', + }, + }, + flex: 1, }, - allowBlank: !me.isCreate && me.maskValues, - - bind: { - emptyText: '{record.emptyText}', + { + header: me.fieldTtitle, + dataIndex: 'headerValue', + xtype: 'widgetcolumn', + widget: { + xtype: 'proxmoxtextfield', + inputType: me.maskValues ? 'password' : 'text', + isFormField: false, + maskRe: me.maskRe, + queryMode: 'local', + listeners: { + change: 'itemChange', + }, + allowBlank: !me.isCreate && me.maskValues, + + bind: { + emptyText: '{record.emptyText}', + }, + }, + flex: 1, }, - }, - flex: 1, + { + xtype: 'widgetcolumn', + width: 40, + widget: { + xtype: 'button', + iconCls: 'fa fa-trash-o', + }, + }, + ], }, { - xtype: 'widgetcolumn', - width: 40, - widget: { - xtype: 'button', - iconCls: 'fa fa-trash-o', - }, + xtype: 'button', + text: gettext('Add'), + iconCls: 'fa fa-plus-circle', + handler: 'addLine', }, ]; + for (const [key, value] of Object.entries(me.gridConfig ?? {})) { + items[0][key] = value; + } + + Ext.apply(me, { + items, + }); + me.callParent(); me.initField(); }, -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel