/** * The account gates panes share. * * `SignInWall` is the one wall a pane shows when it cannot load anything until * the account is right: same headline grammar, same explanation slot, same two * actions, wherever it appears. A pane only supplies the phrase that finishes * "Sign in to ...", so the copy stays in one voice instead of drifting per pane. * `InlineAuthActions` is the other shape: a row of actions sitting inside a * surface that still works signed out, such as the chat composer. */ import { useId } from "react"; import { Box, Text } from "../../../ui"; import { Button, EmptyState, usePaneMenuItems } from "../../../components"; import { usePluginAppActions } from "../../runtime"; import { colors } from "../../../theme/colors"; import { t, tf } from "../../../i18n"; import { requestAuthDialog } from "./auth-dialog"; import type { AccountMode } from "./auth-model"; function openAuth( openCommandBar: (query?: string) => void, mode: AccountMode, ) { if (!requestAuthDialog({ mode })) { openCommandBar(mode === "login" ? "Log In" : "Sign Up"); } } export interface InlineAuthActionsProps { showSignup?: boolean; /** * `buttons` is the wall's pair of compact buttons, for a surface such as * the chat composer where the actions must read as controls. `plain` is * clickable text, for chrome that is itself a row of text (a status bar). */ variant?: "buttons" | "plain"; } export function InlineAuthActions({ showSignup = true, variant = "buttons" }: InlineAuthActionsProps) { const { openCommandBar } = usePluginAppActions(); const logIn = () => openAuth(openCommandBar, "login"); const signUp = () => openAuth(openCommandBar, "signup"); // Inside a pane (the chat composer) the pane menu lists them, so they need // no mouse; the status bar copy has the Log In command instead. usePaneMenuItems(`inline-auth:${useId()}`, () => [ { id: "log-in", label: t("Log in"), onSelect: logIn }, ...(showSignup ? [{ id: "sign-up", label: t("Sign up free"), onSelect: signUp }] : []), ], [openCommandBar, showSignup]); if (variant === "plain") { return (