The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 74 lines 2.13 KB
Raw
1 import type { ManagedPolicySummary } from "@t3tools/contracts";
2 import { T, Var } from "gt-react";
3 import { BuildingIcon } from "lucide-react";
4 import type { ReactNode } from "react";
5
6 import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
7
8 /**
9 * A control an administrator's policy turns off: shown inert, with the policy's reason on hover
10 * and focus. Without a reason it renders the control untouched.
11 */
12 export function ManagedControl({
13 reason,
14 children,
15 }: {
16 reason: string | undefined;
17 children: ReactNode;
18 }) {
19 if (reason === undefined) return children;
20 return (
21 <Tooltip>
22 <TooltipTrigger
23 render={
24 <span
25 tabIndex={0}
26 role="group"
27 aria-disabled="true"
28 aria-label={reason}
29 className="inline-flex rounded-md outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
30 />
31 }
32 >
33 <span inert className="inline-flex opacity-50">
34 {children}
35 </span>
36 </TooltipTrigger>
37 <TooltipPopup side="top">{reason}</TooltipPopup>
38 </Tooltip>
39 );
40 }
41
42 /** One line of policy text with the building mark, for places a whole feature is managed. */
43 export function ManagedNotice({ children }: { children: ReactNode }) {
44 return (
45 <p className="flex items-start gap-2 text-muted-foreground text-xs leading-relaxed">
46 <BuildingIcon aria-hidden="true" className="mt-0.5 size-3.5 shrink-0" />
47 <span>{children}</span>
48 </p>
49 );
50 }
51
52 /** "This environment is managed by <organization>", linking the support page when there is one. */
53 export function ManagedByOrganization({ policy }: { policy: ManagedPolicySummary }) {
54 return (
55 <ManagedNotice>
56 <T>
57 This environment is managed by <Var>{policy.organization}</Var>.
58 </T>
59 {policy.supportUrl ? (
60 <>
61 {" "}
62 <a
63 href={policy.supportUrl}
64 target="_blank"
65 rel="noreferrer"
66 className="text-foreground underline underline-offset-2"
67 >
68 <T>Get help</T>
69 </a>
70 </>
71 ) : null}
72 </ManagedNotice>
73 );
74 }