From 1bd8051aaecbd6ac960807423e40370f8c6fe4ba Mon Sep 17 00:00:00 2001 From: Jamil Date: Fri, 28 Feb 2025 04:32:10 +0000 Subject: [PATCH] fix(connlib): Emit resources updated when display fields change (#8286) Whenever a Resource's name, address_description, or assigned sites change, it is not currently reflected in clients. For that to happen the address is changed. This PR updates that behavior so that if any display fields are changed, the `on_update_resources` callback is called which properly updates the resource list views in clients. Fixes #8284 --- rust/connlib/tunnel/src/client.rs | 12 ++++++++++-- rust/connlib/tunnel/src/client/resource.rs | 14 ++++++++++++++ website/src/components/Changelog/Android.tsx | 7 ++++++- website/src/components/Changelog/Apple.tsx | 7 ++++++- website/src/components/Changelog/GUI.tsx | 7 ++++++- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/rust/connlib/tunnel/src/client.rs b/rust/connlib/tunnel/src/client.rs index 15446e012..a070e8c4b 100644 --- a/rust/connlib/tunnel/src/client.rs +++ b/rust/connlib/tunnel/src/client.rs @@ -1438,8 +1438,16 @@ impl ClientState { }; if let Some(resource) = self.resources_by_id.get(&new_resource.id()) { - if resource.has_different_address(&new_resource) { - self.remove_resource(resource.id()); + let resource_id = resource.id(); + let display_fields_changed = resource.display_fields_changed(&new_resource); + let address_changed = resource.has_different_address(&new_resource); + + if display_fields_changed { + self.emit_resources_changed(); + } + + if address_changed { + self.remove_resource(resource_id); } } diff --git a/rust/connlib/tunnel/src/client/resource.rs b/rust/connlib/tunnel/src/client/resource.rs index ccdf3a60e..140b50cad 100644 --- a/rust/connlib/tunnel/src/client/resource.rs +++ b/rust/connlib/tunnel/src/client/resource.rs @@ -150,6 +150,14 @@ impl Resource { } } + pub fn address_description(&self) -> Option<&str> { + match self { + Resource::Dns(r) => r.address_description.as_deref(), + Resource::Cidr(r) => r.address_description.as_deref(), + Resource::Internet(_) => None, + } + } + pub fn has_different_address(&self, other: &Resource) -> bool { match (self, other) { (Resource::Dns(dns_a), Resource::Dns(dns_b)) => dns_a.address != dns_b.address, @@ -159,6 +167,12 @@ impl Resource { } } + pub fn display_fields_changed(&self, other: &Resource) -> bool { + self.name() != other.name() + || self.address_description() != other.address_description() + || self.sites() != other.sites() + } + pub fn addresses(&self) -> Vec { match self { Resource::Dns(_) => vec![], diff --git a/website/src/components/Changelog/Android.tsx b/website/src/components/Changelog/Android.tsx index 1ae5b1391..48129a4ce 100644 --- a/website/src/components/Changelog/Android.tsx +++ b/website/src/components/Changelog/Android.tsx @@ -19,7 +19,12 @@ export default function Android() { return ( {/* When you cut a release, remove any solved issues from the "known issues" lists over in `client-apps`. This must not be done when the issue's PR merges. */} - + + + Fixes a bug that prevented certain Resource fields from being updated + when they were updated in the admin portal. + + Fixes an upload speed performance regression. diff --git a/website/src/components/Changelog/Apple.tsx b/website/src/components/Changelog/Apple.tsx index 494fd5b1f..4453313fd 100644 --- a/website/src/components/Changelog/Apple.tsx +++ b/website/src/components/Changelog/Apple.tsx @@ -19,7 +19,12 @@ export default function Apple() { return ( {/* When you cut a release, remove any solved issues from the "known issues" lists over in `client-apps`. This must not be done when the issue's PR merges. */} - + + + Fixes a bug that prevented certain Resource fields from being updated + when they were updated in the admin portal. + + Fixes an issue where the update checker would not properly notify the diff --git a/website/src/components/Changelog/GUI.tsx b/website/src/components/Changelog/GUI.tsx index 959c8707c..f1da6183a 100644 --- a/website/src/components/Changelog/GUI.tsx +++ b/website/src/components/Changelog/GUI.tsx @@ -8,7 +8,12 @@ export default function GUI({ os }: { os: OS }) { return ( {/* When you cut a release, remove any solved issues from the "known issues" lists over in `client-apps`. This must not be done when the issue's PR merges. */} - + + + Fixes a bug that prevented certain Resource fields from being updated + when they were updated in the admin portal. + + {os === OS.Linux && (