mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<IpNetwork> {
|
||||
match self {
|
||||
Resource::Dns(_) => vec![],
|
||||
|
||||
@@ -19,7 +19,12 @@ export default function Android() {
|
||||
return (
|
||||
<Entries downloadLinks={downloadLinks} title="Android">
|
||||
{/* 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. */}
|
||||
<Unreleased></Unreleased>
|
||||
<Unreleased>
|
||||
<ChangeItem pull="8286">
|
||||
Fixes a bug that prevented certain Resource fields from being updated
|
||||
when they were updated in the admin portal.
|
||||
</ChangeItem>
|
||||
</Unreleased>
|
||||
<Entry version="1.4.2" date={new Date("2025-02-16")}>
|
||||
<ChangeItem pull="8117">
|
||||
Fixes an upload speed performance regression.
|
||||
|
||||
@@ -19,7 +19,12 @@ export default function Apple() {
|
||||
return (
|
||||
<Entries downloadLinks={downloadLinks} title="macOS / iOS">
|
||||
{/* 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. */}
|
||||
<Unreleased></Unreleased>
|
||||
<Unreleased>
|
||||
<ChangeItem pull="8286">
|
||||
Fixes a bug that prevented certain Resource fields from being updated
|
||||
when they were updated in the admin portal.
|
||||
</ChangeItem>
|
||||
</Unreleased>
|
||||
<Entry version="1.4.5" date={new Date("2025-02-24")}>
|
||||
<ChangeItem pull="8251">
|
||||
Fixes an issue where the update checker would not properly notify the
|
||||
|
||||
@@ -8,7 +8,12 @@ export default function GUI({ os }: { os: OS }) {
|
||||
return (
|
||||
<Entries downloadLinks={downloadLinks(os)} title={title(os)}>
|
||||
{/* 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. */}
|
||||
<Unreleased></Unreleased>
|
||||
<Unreleased>
|
||||
<ChangeItem pull="8286">
|
||||
Fixes a bug that prevented certain Resource fields from being updated
|
||||
when they were updated in the admin portal.
|
||||
</ChangeItem>
|
||||
</Unreleased>
|
||||
<Entry version="1.4.7" date={new Date("2025-02-26")}>
|
||||
{os === OS.Linux && (
|
||||
<ChangeItem pull="8219">
|
||||
|
||||
Reference in New Issue
Block a user