* [PATCH datacenter-manager] ui: views: correctly set filter values on edit
@ 2026-04-21 11:59 Dominik Csapak
2026-04-27 8:03 ` applied: " Lukas Wagner
0 siblings, 1 reply; 2+ messages 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 related [flat|nested] 2+ messages in thread
* applied: [PATCH datacenter-manager] ui: views: correctly set filter values on edit
2026-04-21 11:59 [PATCH datacenter-manager] ui: views: correctly set filter values on edit Dominik Csapak
@ 2026-04-27 8:03 ` Lukas Wagner
0 siblings, 0 replies; 2+ messages in thread
From: Lukas Wagner @ 2026-04-27 8:03 UTC (permalink / raw)
To: pdm-devel, Dominik Csapak
On Tue, 21 Apr 2026 13:59:56 +0200, Dominik Csapak wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] ui: views: correctly set filter values on edit
commit: 2aa9f38a4d5cbacfb677a6980ff03a7bf7997d49
Best regards,
--
Lukas Wagner <l.wagner@proxmox.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-27 8:04 UTC | newest]
Thread overview: 2+ messages (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
2026-04-27 8:03 ` applied: " Lukas Wagner
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.