]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: content view: fix use of external static tbar declaration
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 8 Mar 2024 14:33:20 +0000 (15:33 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 14 Mar 2024 14:17:43 +0000 (15:17 +0100)
when using a declarative `tbar` when instantiating a ContentView,
it is a reference and gets pushed into every time.

instead, copy the given tbar into a local variable and use that

this fixes an issue that we push the same components (e.g. search) into
the toolbar whenever we open a view with a new ContentView
(when using declarative tbar)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/storage/ContentView.js

index bd83a32aa86c36e321463a58a11b19e634799cad..daefaf4f2e6eaf5dd9f9d8ffcb4c664c49ef5521 100644 (file)
@@ -58,11 +58,9 @@ Ext.define('PVE.storage.ContentView', {
 
        Proxmox.Utils.monStoreErrors(me, store);
 
-       if (!me.tbar) {
-           me.tbar = [];
-       }
+       let tbar = me.tbar ? [...me.tbar] : [];
        if (me.useUploadButton) {
-           me.tbar.unshift(
+           tbar.unshift(
                {
                    xtype: 'button',
                    text: gettext('Upload'),
@@ -95,7 +93,7 @@ Ext.define('PVE.storage.ContentView', {
            );
        }
        if (!me.useCustomRemoveButton) {
-           me.tbar.push({
+           tbar.push({
                xtype: 'proxmoxStdRemoveButton',
                selModel: sm,
                enableFn: rec => !rec?.data?.protected,
@@ -104,7 +102,7 @@ Ext.define('PVE.storage.ContentView', {
                baseurl: baseurl + '/',
            });
        }
-       me.tbar.push(
+       tbar.push(
            '->',
            gettext('Search') + ':',
            ' ',
@@ -205,7 +203,7 @@ Ext.define('PVE.storage.ContentView', {
        Ext.apply(me, {
            store,
            selModel: sm,
-           tbar: me.tbar,
+           tbar,
            columns,
            listeners: {
                activate: reload,