* [PATCH datacenter-manager] ui: views: correctly set filter values on edit
@ 2026-04-21 11:59 Dominik Csapak
0 siblings, 0 replies; only message in thread
From: Dominik Csapak @ 2026-04-21 11:59 UTC (permalink / raw)
To: pdm-devel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-21 12:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-21 11:59 [PATCH datacenter-manager] ui: views: correctly set filter values on edit Dominik Csapak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.