import clsx from "clsx"; import type { ReactNode } from "react"; import { AlertTriangle, Copy, Folder, KeyRound, MoreHorizontal, Plus, Server, SlidersHorizontal, X, } from "lucide-react"; import { Reference, Sample } from "./labKit"; import { Badge } from "../components/ui/Badge"; import { Chip } from "../components/ui/Chip"; import { SURFACE } from "../components/ui/surfaces"; import { buttonClass, iconButtonClass } from "../components/ui/buttonStyles"; import { fieldClass } from "../components/ui/fieldStyles"; // API tokens, DECIDED (owner A/A/A): how a machine (the hub) gets a key to the Files library. Static // markup on purpose (the lab's rule); the sample tokens are the owner's own kind (the hub, a phone // script). const ICON = iconButtonClass({ variant: "ghost", size: "sm" }); const noop = () => {}; type Right = "list" | "read" | "write" | "delete"; const RIGHT_LABEL: Record = { list: "Lista", read: "Olvasás", write: "Írás", delete: "Törlés", }; type Token = { name: string; prefix: string; grants: { folder: string; hub?: boolean; rights: Right[] }[]; used: string; expires: string; soon?: boolean; }; const TOKENS: Token[] = [ { name: "Hub csere", prefix: "sfl_7Qm2xK9a", grants: [{ folder: "Hub", hub: true, rights: ["list", "read", "write", "delete"] }], used: "12 perce", expires: "2027. okt. 14.", }, { name: "Telefon – receptek", prefix: "sfl_Bw41LdZr", grants: [ { folder: "Receptek", rights: ["list", "read"] }, { folder: "Cimboráknak", rights: ["list", "read", "write"] }, ], used: "soha", expires: "6 nap múlva", soon: true, }, ]; /** The Settings page frame the tab lives in: the tab rail on the left, the tab on the right. */ function SettingsFrame({ children }: { children: ReactNode }) { return (
{["Megjelenés", "Értesítések", "Letöltések", "API-tokenek", "Fiók"].map((l) => ( {l} ))}

API-tokenek

Egy token egy gépnek ad kulcsot a Fájlok könyvtár kijelölt mappáihoz — semmi máshoz.

Új token
{children}
); } function RightsLine({ grants }: { grants: Token["grants"] }) { return ( {grants.map((g) => ( {g.hub ? : } {g.folder} · {g.rights.map((r) => RIGHT_LABEL[r].toLowerCase()).join(", ")} ))} ); } // ── T1 · the list ───────────────────────────────────────────────────────────────────────────── function ListRows() { return (
{TOKENS.map((tk) => (
{tk.name} {tk.prefix}… {tk.soon && Hamarosan lejár} Utoljára használva: {tk.used} · Lejár: {tk.expires}
))}
); } // ── T2 · the new-token dialog ─────────────────────────────────────────────────────────────────── function Dialog({ title, children, foot, }: { title: string; children: ReactNode; foot: ReactNode; }) { return (

{title}

{children}
{foot}
); } function Field({ label, children }: { label: string; children: ReactNode }) { return ( ); } function Expiry() { return ( {["30 nap", "90 nap", "1 év", "Soha"].map((l) => ( {l} ))} ); } const FOLDERS: { name: string; kind: "hub" | "own" | "source"; on: Right[] }[] = [ { name: "Hub", kind: "hub", on: [] }, { name: "Receptek", kind: "own", on: ["list", "read"] }, { name: "Cimboráknak", kind: "own", on: ["list", "read", "write"] }, { name: "YouTube", kind: "source", on: [] }, ]; function RightsMatrix() { return (
{FOLDERS.map((f) => (
{f.kind === "hub" ? : } {f.name} {(Object.keys(RIGHT_LABEL) as Right[]).map((r) => // A source folder fills itself: nothing can be uploaded into it, so no Write. f.kind === "source" && r === "write" ? null : ( {RIGHT_LABEL[r]} ), )}
))}
); } function PresetFirst({ custom }: { custom: boolean }) { return ( Mégse Létrehozás } >
{[ { on: !custom, icon: Server, title: "Hub csere", text: "Egy közös Hub mappa; a token mindent tehet benne.", }, { on: custom, icon: SlidersHorizontal, title: "Egyedi", text: "Te választod a mappákat és a jogokat.", }, ].map((c) => ( {c.title} {c.text} ))}
{custom ? "Telefon – receptek" : "Hub csere"} {custom && }
); } // ── T3 · the token, shown once ────────────────────────────────────────────────────────────────── const RAW = "sfl_7Qm2xK9aVt3pLc8RzN0eWq5uYb1HdJ6gFs4kMx2oTi9a3F7kQe"; function CopyRow({ children, mono = true }: { children: ReactNode; mono?: boolean }) { return ( {children} Másolás ); } function ShownInDialog() { return ( Kész} > Most látod utoljára: mi csak a lenyomatát őrizzük. Ha elveszik, csinálj újat. {RAW} curl -H "Authorization: Bearer {RAW.slice(0, 12)}…" https://siftlode.example/api/files/folders ); } // ── The round ─────────────────────────────────────────────────────────────────────────────────── export function TokensRound() { return (
); }