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 (