2023-01-27 13:37:20 -08:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2022-08-04 14:18:47 -07:00
|
|
|
|
|
|
|
export function Header({ state, ipn }: { state: IPNState; ipn?: IPN }) {
|
|
|
|
const stateText = STATE_LABELS[state]
|
|
|
|
|
|
|
|
let logoutButton
|
2022-08-23 18:05:23 -07:00
|
|
|
if (state === "Running") {
|
2022-08-04 14:18:47 -07:00
|
|
|
logoutButton = (
|
|
|
|
<button
|
|
|
|
class="button bg-gray-500 border-gray-500 text-white hover:bg-gray-600 hover:border-gray-600 ml-2 font-bold"
|
|
|
|
onClick={() => ipn?.logout()}
|
|
|
|
>
|
|
|
|
Logout
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div class="bg-gray-100 border-b border-gray-200 pt-4 pb-2">
|
|
|
|
<header class="container mx-auto px-4 flex flex-row items-center">
|
|
|
|
<h1 class="text-3xl font-bold grow">Tailscale Connect</h1>
|
|
|
|
<div class="text-gray-600">{stateText}</div>
|
|
|
|
{logoutButton}
|
|
|
|
</header>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const STATE_LABELS = {
|
2022-08-23 18:05:23 -07:00
|
|
|
NoState: "Initializing…",
|
|
|
|
InUseOtherUser: "In-use by another user",
|
|
|
|
NeedsLogin: "Needs login",
|
2023-03-01 14:20:15 -05:00
|
|
|
NeedsMachineAuth: "Needs approval",
|
2022-08-23 18:05:23 -07:00
|
|
|
Stopped: "Stopped",
|
|
|
|
Starting: "Starting…",
|
|
|
|
Running: "Running",
|
2022-08-04 14:18:47 -07:00
|
|
|
} as const
|