ba39b08e09
apple / swift (push) Successful in 1m6s
ci / rust (push) Successful in 5m51s
android / android (push) Successful in 6m21s
ci / web (push) Successful in 49s
ci / docs-site (push) Successful in 58s
windows-host / package (push) Successful in 8m6s
release / apple (push) Successful in 8m17s
deb / build-publish (push) Successful in 3m26s
decky / build-publish (push) Successful in 25s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 5s
ci / bench (push) Successful in 4m42s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 30s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 2m36s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 2m17s
rpm / build-publish (fedora-44, punktfunk-fedora44-rpm) (push) Failing after 19s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 51s
apple / screenshots (push) Successful in 5m45s
docker / deploy-docs (push) Successful in 22s
rpm / build-publish (bazzite, punktfunk-fedora-rpm) (push) Failing after 22s
Web console - Pairing/Library/Stats refactored into self-contained subsections that each own their own queries + mutations; a shared slot-based layout (view.tsx) is filled by the live page (containers) and Storybook (pure cards + fixtures) so the layout can't drift. - All paired devices in one list on Pairing with a protocol column (punktfunk/1 + Moonlight), routing each unpair to the right endpoint; the redundant Clients page is removed. - Library: overview grid split from the add/edit form into separate files. - Login screen links out to the docs. Docs - "Console login password" section on every host page (apt/RPM/Bazzite/SteamOS/Windows) plus a new "Forgot your Password?" troubleshooting page, linked from the login screen. - Console served as HTTP/1.1 over TLS (drop the unusable HTTP/3 advertising) across the Bun entry, launchers, systemd units, and packaging. Tooling - Biome now respects .gitignore (stops linting generated code), config migrated to 2.5.1; all lint issues fixed cleanly. Also includes this branch's in-progress host, Apple client, packaging, and CI changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
132 lines
4.3 KiB
TypeScript
132 lines
4.3 KiB
TypeScript
import { useQueryClient } from "@tanstack/react-query";
|
|
import { Button } from "@unom/ui/button";
|
|
import { UserPlus, X } from "lucide-react";
|
|
import type { FC } from "react";
|
|
import type { PendingDevice } from "@/api/gen/model";
|
|
import {
|
|
getListNativeClientsQueryKey,
|
|
getListPendingDevicesQueryKey,
|
|
useApprovePendingDevice,
|
|
useDenyPendingDevice,
|
|
useListPendingDevices,
|
|
} from "@/api/gen/native/native";
|
|
import { QueryState } from "@/components/query-state";
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table";
|
|
import type { Loadable } from "@/lib/query";
|
|
import { fmtAge } from "@/lib/utils";
|
|
import { m } from "@/paraglide/messages";
|
|
|
|
/**
|
|
* Container: devices awaiting delegated approval. Polls so a knock appears while
|
|
* looking; approving pairs the device, so it also refreshes the paired-clients
|
|
* list (owned by the PairedDevices subsection — invalidated here by query key).
|
|
*/
|
|
export const PendingDevicesSection: FC = () => {
|
|
const qc = useQueryClient();
|
|
const pending = useListPendingDevices({ query: { refetchInterval: 3_000 } });
|
|
const approve = useApprovePendingDevice();
|
|
const deny = useDenyPendingDevice();
|
|
|
|
const refresh = () => {
|
|
qc.invalidateQueries({ queryKey: getListPendingDevicesQueryKey() });
|
|
qc.invalidateQueries({ queryKey: getListNativeClientsQueryKey() });
|
|
};
|
|
const onApprove = (id: number, currentName: string) => {
|
|
const name = prompt(m.pairing_pending_name_prompt(), currentName);
|
|
if (name == null) return; // operator cancelled
|
|
approve.mutate(
|
|
{ id, data: { name: name.trim() ? name.trim() : null } },
|
|
{ onSuccess: refresh },
|
|
);
|
|
};
|
|
const onDeny = (id: number) => deny.mutate({ id }, { onSuccess: refresh });
|
|
|
|
return (
|
|
<PendingDevices
|
|
pending={pending}
|
|
onApprove={onApprove}
|
|
onDeny={onDeny}
|
|
busy={approve.isPending || deny.isPending}
|
|
/>
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Devices awaiting delegated approval: an unpaired device that tried to connect
|
|
* shows up here, and Approve pairs it on the spot. Renders nothing while empty
|
|
* (the common case) unless there's an error to surface.
|
|
*/
|
|
export const PendingDevices: FC<{
|
|
pending: Loadable<PendingDevice[]>;
|
|
onApprove: (id: number, currentName: string) => void;
|
|
onDeny: (id: number) => void;
|
|
busy: boolean;
|
|
}> = ({ pending, onApprove, onDeny, busy }) => {
|
|
const rows = pending.data ?? [];
|
|
// Stay out of the way when there's nothing pending and the fetch is healthy — but DON'T swallow
|
|
// a real error (a 500 etc.); fall through to QueryState below so it surfaces like every other
|
|
// section. (A 401 is handled globally by the fetcher's redirect-to-login.)
|
|
if (rows.length === 0 && !pending.error) return null;
|
|
|
|
return (
|
|
<Card>
|
|
<CardContent className="p-0">
|
|
<CardHeader>
|
|
<CardTitle>
|
|
<h2 className="flex items-center gap-2 text-lg font-medium">
|
|
<UserPlus className="size-4" />
|
|
{m.pairing_pending_title()}
|
|
</h2>
|
|
<p className="text-sm text-muted-foreground">
|
|
{m.pairing_pending_desc()}
|
|
</p>
|
|
</CardTitle>
|
|
</CardHeader>
|
|
|
|
<QueryState
|
|
isLoading={pending.isLoading}
|
|
error={pending.error}
|
|
refetch={pending.refetch}
|
|
>
|
|
<Table>
|
|
<TableBody>
|
|
{rows.map((p) => (
|
|
<TableRow className="h-18" key={p.id}>
|
|
<TableCell className="font-medium">{p.name}</TableCell>
|
|
<TableCell className="font-mono text-xs text-muted-foreground">
|
|
{p.fingerprint.slice(0, 16)}…
|
|
</TableCell>
|
|
<TableCell className="text-xs text-muted-foreground">
|
|
{fmtAge(p.age_secs)}
|
|
</TableCell>
|
|
<TableCell className="text-right">
|
|
<div className="flex justify-end gap-2">
|
|
<Button
|
|
size="sm"
|
|
disabled={busy}
|
|
onClick={() => onApprove(p.id, p.name)}
|
|
>
|
|
{m.pairing_pending_approve()}
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
variant="ghost"
|
|
aria-label={m.pairing_pending_deny()}
|
|
disabled={busy}
|
|
onClick={() => onDeny(p.id)}
|
|
>
|
|
<X className="size-4" />
|
|
</Button>
|
|
</div>
|
|
</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</QueryState>
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
};
|