Files
archie/ui/src/dashboard/setup-preference.ts
T

33 lines
1.0 KiB
TypeScript

/** One setup step as the daemon reports it. */
interface SetupStep {
title: string;
detail?: string;
done: boolean;
/** The page that fixes an unfinished step, so the checklist is a set of
* links rather than a description of work with nowhere to go. */
path?: string;
}
export interface Setup {
steps: SetupStep[];
}
export interface SetupPanelState {
/** omit: nothing to show, either no setup data or setup fully done. */
kind: "omit" | "incomplete";
remaining: SetupStep[];
}
// setupPanelState distinguishes the only two states worth rendering: there is
// setup work left (the checklist), or there is not (nothing: a configured
// daemon is the absence of a problem, not a card announcing it).
export function setupPanelState(
setup: Setup | null | undefined,
): SetupPanelState {
const remaining = (setup?.steps ?? []).filter((step) => !step.done);
if (!setup?.steps?.length || !remaining.length) {
return { kind: "omit", remaining: [] };
}
return { kind: "incomplete", remaining };
}