From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/3] ui: view selector: prepare filterfn to be more efficient
Date: Tue, 12 Nov 2024 12:45:05 +0100 [thread overview]
Message-ID: <20241112114506.1970103-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20241112114506.1970103-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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 `<span class="proxmox-tags-full">${tag}</span>`;
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
next prev parent reply other threads:[~2024-11-12 11:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 11:45 [pve-devel] [PATCH manager 1/3] ui: resource tree: fix order of types Dominik Csapak
2024-11-12 11:45 ` Dominik Csapak [this message]
2024-11-12 13:23 ` [pve-devel] applied: [PATCH manager 2/3] ui: view selector: prepare filterfn to be more efficient Thomas Lamprecht
2024-11-12 11:45 ` [pve-devel] [PATCH manager 3/3] ui: resource tree: show nodes/storages in pool/tag view by default Dominik Csapak
2024-11-12 13:38 ` Thomas Lamprecht
2024-11-12 15:04 ` Dominik Csapak
2024-11-12 13:23 ` [pve-devel] applied: [PATCH manager 1/3] ui: resource tree: fix order of types Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241112114506.1970103-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox