From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager] ui: views: correctly set filter values on edit
Date: Tue, 21 Apr 2026 13:59:56 +0200 [thread overview]
Message-ID: <20260421120002.2411373-1-d.csapak@proxmox.com> (raw)
There were two issues here:
* use of 'default' instead of 'value': this triggered an unnecessary
change and did not properly track the value for reset
* change of the filter even if the old type was the same. This lead
to a change from e.g. "remote:foo" to "remote:" which overwrote
the filter value with an empty string. This happens on reset, when the
type was changed, as we force the value to the original one which
triggers an on_change.
With these two fixed, the view edit window works properly now.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
ui/src/widget/view_filter_selector.rs | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/ui/src/widget/view_filter_selector.rs b/ui/src/widget/view_filter_selector.rs
index 9d3fb7c7..9db83b25 100644
--- a/ui/src/widget/view_filter_selector.rs
+++ b/ui/src/widget/view_filter_selector.rs
@@ -231,27 +231,35 @@ fn columns(
Combobox::new()
.placeholder(tr!("Select"))
.required(true)
- .default(filter_type.map(AttrValue::from))
+ .value(filter_type.map(AttrValue::from))
.on_change({
let link = link.clone();
move |value: String| {
- let filter = match FilterRuleType::from_str(value.as_str()) {
- Ok(FilterRuleType::ResourceType) => {
+ let Ok(new_filter_type) = FilterRuleType::from_str(value.as_str())
+ else {
+ return;
+ };
+ if Some(new_filter_type) == filter_type {
+ // this can happen on reset, since we force the value ourselves
+ return;
+ }
+
+ let filter = match new_filter_type {
+ FilterRuleType::ResourceType => {
FilterRule::ResourceType(EnumMatcher(ResourceType::Node))
}
- Ok(FilterRuleType::ResourcePool) => FilterRule::ResourcePool(
+ FilterRuleType::ResourcePool => FilterRule::ResourcePool(
StringMatcher::Exact(String::new()),
),
- Ok(FilterRuleType::ResourceId) => {
+ FilterRuleType::ResourceId => {
FilterRule::ResourceId(StringMatcher::Exact(String::new()))
}
- Ok(FilterRuleType::Tag) => {
+ FilterRuleType::Tag => {
FilterRule::Tag(StringMatcher::Exact(String::new()))
}
- Ok(FilterRuleType::Remote) => {
+ FilterRuleType::Remote => {
FilterRule::Remote(StringMatcher::Exact(String::new()))
}
- Err(_) => return,
};
link.send_message(Msg::ChangeFilter(filter, index));
--
2.47.3
next reply other threads:[~2026-04-21 12:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 11:59 Dominik Csapak [this message]
2026-04-27 8:03 ` applied: [PATCH datacenter-manager] ui: views: correctly set filter values on edit Lukas Wagner
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=20260421120002.2411373-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-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