webhook edit: make items config not static

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 <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2024-11-12 15:41:53 +01:00 committed by Thomas Lamprecht
parent 20002254e6
commit 3052c4dfc8

View File

@ -318,7 +318,10 @@ Ext.define('Proxmox.form.WebhookKeyValueList', {
},
},
items: [
initComponent: function() {
let me = this;
let items = [
{
xtype: 'grid',
reference: 'grid',
@ -338,23 +341,7 @@ Ext.define('Proxmox.form.WebhookKeyValueList', {
},
},
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 = [
columns: [
{
header: me.fieldTtitle,
dataIndex: 'headerName',
@ -400,8 +387,24 @@ Ext.define('Proxmox.form.WebhookKeyValueList', {
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();
},