From 6f214dec48c325fb5dfeff632efcdfb8f9db3be8 Mon Sep 17 00:00:00 2001 From: Sonia Appasamy Date: Wed, 25 Oct 2023 17:58:53 -0400 Subject: [PATCH] client/web: split out UI components This commit makes the following structural changes to the web client interface. No user-visible changes. 1. Splits login, legacy, readonly, and full management clients into their own components, and pulls them out into their own view files. 2. Renders the same Login component for all scenarios when the client is not logged in, regardless of legacy or debug mode. Styling comes from the existing legacy login, which is removed from legacy.tsx now that it is shared. 3. Adds a ui folder to hold non-Tailscale-specific components, starting with ProfilePic, previously housed in app.tsx. Updates tailscale/corp#14335 Signed-off-by: Sonia Appasamy --- client/web/src/components/app.tsx | 176 +++++------------- .../legacy-client-view.tsx} | 158 +++++----------- .../components/views/login-client-view.tsx | 65 +++++++ .../views/management-client-view.tsx | 35 ++++ .../components/views/readonly-client-view.tsx | 69 +++++++ client/web/src/ui/profile-pic.tsx | 19 ++ 6 files changed, 277 insertions(+), 245 deletions(-) rename client/web/src/components/{legacy.tsx => views/legacy-client-view.tsx} (76%) create mode 100644 client/web/src/components/views/login-client-view.tsx create mode 100644 client/web/src/components/views/management-client-view.tsx create mode 100644 client/web/src/components/views/readonly-client-view.tsx create mode 100644 client/web/src/ui/profile-pic.tsx diff --git a/client/web/src/components/app.tsx b/client/web/src/components/app.tsx index 004bc39c5..cf06ee724 100644 --- a/client/web/src/components/app.tsx +++ b/client/web/src/components/app.tsx @@ -1,35 +1,37 @@ +import cx from "classnames" import React from "react" -import { Footer, Header, IP, State } from "src/components/legacy" -import useAuth, { AuthResponse } from "src/hooks/auth" +import LegacyClientView from "src/components/views/legacy-client-view" +import LoginClientView from "src/components/views/login-client-view" +import ReadonlyClientView from "src/components/views/readonly-client-view" +import useAuth from "src/hooks/auth" import useNodeData, { NodeData } from "src/hooks/node-data" -import { ReactComponent as ConnectedDeviceIcon } from "src/icons/connected-device.svg" -import { ReactComponent as TailscaleIcon } from "src/icons/tailscale-icon.svg" -import { ReactComponent as TailscaleLogo } from "src/icons/tailscale-logo.svg" +import ManagementClientView from "./views/management-client-view" export default function App() { - // TODO(sonia): use isPosting value from useNodeData - // to fill loading states. const { data, refreshData, updateNode } = useNodeData() - if (!data) { - // TODO(sonia): add a loading view - return
Loading...
- } - - const needsLogin = data?.Status === "NeedsLogin" || data?.Status === "NoState" - - return !needsLogin && - (data.DebugMode === "login" || data.DebugMode === "full") ? ( - - ) : ( - // Legacy client UI -
-
-
- - -
-