From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id DA47F1FF168 for ; Tue, 12 Nov 2024 12:45:11 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 33D091E706; Tue, 12 Nov 2024 12:45:09 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 12 Nov 2024 12:45:05 +0100 Message-Id: <20241112114506.1970103-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241112114506.1970103-1-d.csapak@proxmox.com> References: <20241112114506.1970103-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 manager 2/3] ui: view selector: prepare filterfn to be more efficient 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" instead of just using the filterfn directly, return a function from `getFilterFn`. This way, when we want to filter different things depending on e.g. local storage values, we don't have to do that for every element, but only once and return the finished filterFn. while at it, rename 'filterfn' to camel case 'filterFn'. Signed-off-by: Dominik Csapak --- www/manager6/form/ViewSelector.js | 4 ++-- www/manager6/tree/ResourceTree.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/www/manager6/form/ViewSelector.js b/www/manager6/form/ViewSelector.js index ee16c227..f5de5c8e 100644 --- a/www/manager6/form/ViewSelector.js +++ b/www/manager6/form/ViewSelector.js @@ -30,12 +30,12 @@ Ext.define('PVE.form.ViewSelector', { text: gettext('Pool View'), groups: ['pool'], // Pool View only lists VMs and Containers - filterfn: ({ data }) => data.type === 'qemu' || data.type === 'lxc' || data.type === 'pool', + getFilterFn: () => ({ data }) => data.type === 'qemu' || data.type === 'lxc' || data.type === 'pool', }, tags: { text: gettext('Tag View'), groups: ['tag'], - filterfn: ({ data }) => data.type === 'qemu' || data.type === 'lxc', + getFilterFn: () => ({ data }) => data.type === 'qemu' || data.type === 'lxc', groupRenderer: function(info) { let tag = PVE.Utils.renderTags(info.tag, PVE.UIOptions.tagOverrides); return `${tag}`; diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js index 640ebbf9..312f958f 100644 --- a/www/manager6/tree/ResourceTree.js +++ b/www/manager6/tree/ResourceTree.js @@ -327,7 +327,7 @@ Ext.define('PVE.tree.ResourceTree', { // also check for name for when the tree is sorted by name let moveCheckAttrs = groups.concat(['node', 'template', 'name']); - let filterfn = me.viewFilter.filterfn; + let filterFn = me.viewFilter.getFilterFn ? me.viewFilter.getFilterFn() : Ext.identityFn; let reselect = false; // for disappeared nodes let index = pdata.dataIndex; @@ -399,7 +399,7 @@ Ext.define('PVE.tree.ResourceTree', { if (olditem) { return; } - if (filterfn && !filterfn(item)) { + if (filterFn && !filterFn(item)) { return; } let info = Ext.apply({ leaf: true }, item.data); -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel