From 50b558de745582873dd89f39ecc14a0d19401c76 Mon Sep 17 00:00:00 2001 From: Sonia Appasamy Date: Tue, 22 Aug 2023 11:44:36 -0400 Subject: [PATCH] client/web: hook up remaining legacy POST requests Hooks up remaining legacy POST request from the React side in --dev. Updates tailscale/corp#13775 Signed-off-by: Sonia Appasamy --- client/web/src/components/app.tsx | 2 +- client/web/src/components/legacy.tsx | 115 ++++++++++++++++----------- client/web/src/hooks/node-data.ts | 1 + 3 files changed, 69 insertions(+), 49 deletions(-) diff --git a/client/web/src/components/app.tsx b/client/web/src/components/app.tsx index 8dd90c188..b684615fa 100644 --- a/client/web/src/components/app.tsx +++ b/client/web/src/components/app.tsx @@ -15,7 +15,7 @@ export default function App() { ) : ( <>
-
+
diff --git a/client/web/src/components/legacy.tsx b/client/web/src/components/legacy.tsx index 7c599d4a1..9d0ec5640 100644 --- a/client/web/src/components/legacy.tsx +++ b/client/web/src/components/legacy.tsx @@ -7,9 +7,13 @@ import { NodeData, NodeUpdate } from "src/hooks/node-data" // purely to ease migration to the new React-based web client, and will // eventually be completely removed. -export function Header(props: { data: NodeData }) { - const { data } = props - +export function Header({ + data, + updateNode, +}: { + data: NodeData + updateNode: (update: NodeUpdate) => void +}) { return (
- {data.Profile && ( - <> -
-

- {data.Profile.LoginName} -

-
- - Switch account - {" "} - |{" "} - - Reauthenticate - {" "} - |{" "} - - Logout - + {data.Profile && + data.Status !== "NoState" && + data.Status !== "NeedsLogin" && ( + <> +
+

+ {data.Profile.LoginName} +

+
+ {" "} + |{" "} + {" "} + |{" "} + +
-
-
- {data.Profile.ProfilePicURL ? ( -
- ) : ( -
- )} -
- - )} +
+ {data.Profile.ProfilePicURL ? ( +
+ ) : ( +
+ )} +
+ + )}
) @@ -129,9 +144,9 @@ export function IP(props: { data: NodeData }) { -
-

{data.DeviceName}

-
+

+ {data.DeviceName || "Your device"} +

{data.IP}
@@ -190,11 +205,12 @@ export function State({ .

- - - + ) } else { @@ -215,9 +231,12 @@ export function State({ .

- - - + ) } diff --git a/client/web/src/hooks/node-data.ts b/client/web/src/hooks/node-data.ts index 444c9190d..507971d2d 100644 --- a/client/web/src/hooks/node-data.ts +++ b/client/web/src/hooks/node-data.ts @@ -56,6 +56,7 @@ export default function useNodeData() { setIsPosting(true) update = { + ...update, // Default to current data value for any unset fields. AdvertiseRoutes: update.AdvertiseRoutes !== undefined