From 021578e06ab95eb168d7c1c929f0e8e87c00a4ad Mon Sep 17 00:00:00 2001 From: Arthur Degonde <44548105+ArthurD1@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:27:46 +0100 Subject: [PATCH 1/2] fix: topoly page bug when updating status --- .../Topology/RemoteEndpointStatusDropDown.tsx | 17 +++--- .../System/Topology/TopologyRemoteTable.tsx | 5 +- .../Pages/System/Topology/TopologyTable.tsx | 8 +-- .../SystemTopologyTabPanel.test.tsx.snap | 58 ++++++++++--------- 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/harp_apps/dashboard/frontend/src/Pages/System/Topology/RemoteEndpointStatusDropDown.tsx b/harp_apps/dashboard/frontend/src/Pages/System/Topology/RemoteEndpointStatusDropDown.tsx index bc46390b..0f035aa3 100644 --- a/harp_apps/dashboard/frontend/src/Pages/System/Topology/RemoteEndpointStatusDropDown.tsx +++ b/harp_apps/dashboard/frontend/src/Pages/System/Topology/RemoteEndpointStatusDropDown.tsx @@ -1,5 +1,6 @@ import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react" import { ChevronDownIcon } from "@heroicons/react/20/solid" +import { useCallback, useMemo } from "react" import tw, { styled } from "twin.macro" import { useSystemProxyMutation } from "Domain/System/useSystemProxyQuery.ts" @@ -26,8 +27,13 @@ export default function RemoteEndpointStatusDropDown({ }) { const mutation = useSystemProxyMutation() const status = remoteEndpoint.status ?? 0 - const humanStatus = getHumanStatus(status) - + const humanStatus = useMemo(() => getHumanStatus(status), [status]) + const handleMutation = useCallback( + (status: string) => { + mutation.mutate({ endpoint: endpointName, url: remoteEndpoint.settings.url, action: status }) + }, + [mutation, endpointName, remoteEndpoint.settings.url], + ) return (
@@ -66,12 +72,7 @@ export default function RemoteEndpointStatusDropDown({ {["up", "checking", "down"].map((status) => humanStatus != status ? ( - - mutation.mutate({ endpoint: endpointName, url: remoteEndpoint.settings.url, action: status }) - } - > + handleMutation(status)}> Set {status} diff --git a/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyRemoteTable.tsx b/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyRemoteTable.tsx index 30525ca5..1a5e6913 100644 --- a/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyRemoteTable.tsx +++ b/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyRemoteTable.tsx @@ -42,7 +42,10 @@ export default function TopologyRemoteTable({ {remoteEndpoint.failure_reasons.join(",")} ) : null} {(remoteEndpoint.settings.pools || ["default"]).map((pool, k) => ( - + {pool} ))} diff --git a/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyTable.tsx b/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyTable.tsx index 9f73bd89..01da2002 100644 --- a/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyTable.tsx +++ b/harp_apps/dashboard/frontend/src/Pages/System/Topology/TopologyTable.tsx @@ -6,10 +6,10 @@ import TopologyRemoteTable from "./TopologyRemoteTable.tsx" export function TopologyTable({ endpoints }: { endpoints: Apps.Proxy.Endpoint[] }) { return ( - <> +
{endpoints.map((endpoint, i) => ( - - + + {endpoint.settings.name} @@ -25,6 +25,6 @@ export function TopologyTable({ endpoints }: { endpoints: Apps.Proxy.Endpoint[] ))} - +
) } diff --git a/harp_apps/dashboard/frontend/src/Pages/System/__snapshots__/SystemTopologyTabPanel.test.tsx.snap b/harp_apps/dashboard/frontend/src/Pages/System/__snapshots__/SystemTopologyTabPanel.test.tsx.snap index 1e1b1bd9..fd687235 100644 --- a/harp_apps/dashboard/frontend/src/Pages/System/__snapshots__/SystemTopologyTabPanel.test.tsx.snap +++ b/harp_apps/dashboard/frontend/src/Pages/System/__snapshots__/SystemTopologyTabPanel.test.tsx.snap @@ -25,41 +25,45 @@ exports[`renders the title and data when the query is successful 1`] = ` Topology
- - - endpoint1 + - 8080 + endpoint1 + + 8080 + - -
+
+
From 728299b610c06afaa89242e2c97c11f89e9745b4 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Fri, 8 Nov 2024 11:05:25 +0100 Subject: [PATCH 2/2] misc: update changelog --- docs/changelogs/unreleased.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelogs/unreleased.rst b/docs/changelogs/unreleased.rst index b49a0a26..a9ca46a3 100644 --- a/docs/changelogs/unreleased.rst +++ b/docs/changelogs/unreleased.rst @@ -2,6 +2,11 @@ Unreleased ========== Added -::::::: +::::: * Proxy: it is now possible to add not exposed endpoints in the proxy configuration. + +Fixed +::::: + +* UI: Fixed the topology UI where changing the state of a remote would cause the page to crash (#578, @ArthurD1).