// Copyright (c) Tailscale Inc & AUTHORS // SPDX-License-Identifier: BSD-3-Clause import React, { useEffect } from "react" import { ReactComponent as TailscaleIcon } from "src/assets/icons/tailscale-icon.svg" import LoginToggle from "src/components/login-toggle" import DeviceDetailsView from "src/components/views/device-details-view" import HomeView from "src/components/views/home-view" import LoginView from "src/components/views/login-view" import SSHView from "src/components/views/ssh-view" import SubnetRouterView from "src/components/views/subnet-router-view" import { UpdatingView } from "src/components/views/updating-view" import useAuth, { AuthResponse } from "src/hooks/auth" import useNodeData, { Feature, featureDescription, NodeData, } from "src/hooks/node-data" import { Link, Route, Router, Switch, useLocation } from "wouter" export default function App() { const { data: auth, loading: loadingAuth, newSession } = useAuth() return (
{loadingAuth || !auth ? (
Loading...
// TODO(sonia): add a loading view ) : ( )}
) } function WebClient({ auth, newSession, }: { auth: AuthResponse newSession: () => Promise }) { const { data, refreshData, nodeUpdaters } = useNodeData() useEffect(() => { refreshData() }, [auth, refreshData]) return !data ? (
Loading...
) : data.Status === "NeedsLogin" || data.Status === "NoState" || data.Status === "Stopped" ? ( // Client not on a tailnet, render login. ) : ( // Otherwise render the new web client. <>
{/* TODO */}Share local content

Page not found

) } /** * FeatureRoute renders a Route component, * but only displays the child view if the specified feature is * available for use on this node's platform. If not available, * a not allowed view is rendered instead. */ function FeatureRoute({ path, node, feature, children, }: { path: string node: NodeData // TODO: once we have swr, just call useNodeData within FeatureView feature: Feature children: React.ReactNode }) { return ( {!node.Features[feature] ? (

{featureDescription(feature)} not available on this device.

) : ( children )}
) } function Header({ node, auth, newSession, }: { node: NodeData auth: AuthResponse newSession: () => Promise }) { const [loc, setLocation] = useLocation() return ( <>
setLocation("/")} />
{node.DomainName}
{loc !== "/" && loc !== "/update" && ( ← Back to {node.DeviceName} )} ) }