// WF-P8 S00 "Boards-Startseite" — rebuilt against Davids Subframe export of // 2026-07-28 (page 1778cf5e-777b-439c-81b6-c51f85283cc4) plus the local // wireframe doc, which is the authoritative copy for this nachzug. // // Pure/presentational: renders the server-built BoardsStartData; search and the // three facet filters are client-side (the board list is small). Usable boards // navigate via links; locked boards (deny-based PipelineAccess rule) stay // visible per the design — greyed out, no links, with a "request access" action // that the route wires to a POST. No useLoaderData/useFetcher, no server // imports, plain document flow (the app shell's
scrolls). // // Deltas against the export that are deliberate, not oversights: // * The Status facet offers Aktiv/Gesperrt only. "Entwurf"/"Archiviert" have // no board state behind them (archived boards are not listed at all), and a // filter option that can never match is worse than an absent one. // * The Zugriff facet offers Freigegeben/Freigabe nötig. The export's third // option "Nur ich" needs an owner concept that PipelineAccess does not have. // * Board icons are derived from the board type. Pipeline carries no icon // column, and inventing one per board would be data we do not have. import { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherActivity, FeatherCheckCircle, FeatherChevronRight, FeatherFilter, FeatherKanbanSquare, FeatherLock, FeatherPlus, FeatherSettings, FeatherUnlockKeyhole, FeatherXCircle, } from "@subframe/core"; import { BOARD_TYP_ICON, BOARD_TYP_TONE } from "./boardTypeVisuals"; import type { BoardsStartData, BoardsStartRowVM, BoardsStartTypHint } from "@hivegrid/view-models"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { AppLink } from "~/components/app/AppLink"; import { EmptyState } from "~/ui/components/EmptyState"; import { IconButton } from "~/ui/components/IconButton"; import { Table } from "~/ui/components/Table"; import { Tag_Label } from "~/ui/components/Tag_Label"; import { useLocaleFormatters } from "~/locale/format"; import { FacetFilterBar, type ClientFacet } from "../shared/FacetFilterBar"; import { PAGE_HEADER_ICON_CLASS, PageHeader, PageShell } from "../shared/PageShell"; export type BoardsStartPageProps = { data: BoardsStartData; /** Route-injected action callbacks (M014 shape) — the screen never posts itself. */ actions: { onRequestAccess: (pipelineId: string) => void; }; /** Disables the request-access buttons while a submission is in flight. */ submitting?: boolean; }; export type BoardsStartTypFilter = BoardsStartTypHint; export type BoardsStartAccessFilter = "granted" | "requestable"; export type BoardsStartStatusFilter = "active" | "locked"; const TYP_VALUES: readonly BoardsStartTypFilter[] = ["sales", "auftrag", "custom"]; const ACCESS_VALUES: readonly BoardsStartAccessFilter[] = ["granted", "requestable"]; const STATUS_VALUES: readonly BoardsStartStatusFilter[] = ["active", "locked"]; /** Muted styling for locked (greyed-out) board rows. */ const LOCKED_CELL_CLASS = "opacity-60"; // Board type → icon tile / tag tone. Shared with the S07 board table; Pipeline // has no icon column, the type is what we know. const TYP_ICON = BOARD_TYP_ICON; const TYP_TONE = BOARD_TYP_TONE; export type BoardsStartFilters = { readonly search: string; /** Empty set = facet not filtered. Several values in one facet are OR-ed. */ readonly typ: ReadonlySet; readonly access: ReadonlySet; readonly status: ReadonlySet; }; /** * Client-side facet filter, exported so it can be tested as a plain function. * The facet menus are Radix widgets that jsdom cannot drive, so asserting the * behaviour through the rendered dropdown would test the widget, not the rule. */ export function filterBoardRows( rows: readonly BoardsStartRowVM[], filters: BoardsStartFilters ): readonly BoardsStartRowVM[] { const q = filters.search.trim().toLowerCase(); return rows.filter((row) => { if (filters.typ.size > 0 && !filters.typ.has(row.typHint)) return false; if (filters.access.size > 0 && !filters.access.has(row.locked ? "requestable" : "granted")) return false; if (filters.status.size > 0 && !filters.status.has(row.locked ? "locked" : "active")) return false; if (q && !row.name.toLowerCase().includes(q)) return false; return true; }); } const EMPTY_SELECTION: ReadonlySet = new Set(); /** Adds or removes one value of a facet. */ function toggleValue(current: ReadonlySet, value: string): ReadonlySet { const next = new Set(current); if (!next.delete(value)) next.add(value); return next; } export function BoardsStartPage(props: BoardsStartPageProps) { const { t } = useTranslation(); const { number } = useLocaleFormatters(); const { data, actions, submitting = false } = props; const [search, setSearch] = useState(""); const [typ, setTyp] = useState>(EMPTY_SELECTION); const [access, setAccess] = useState>(EMPTY_SELECTION); const [status, setStatus] = useState>(EMPTY_SELECTION); const rows = useMemo( () => filterBoardRows(data.rows, { search, typ, access, status }), [data.rows, search, typ, access, status] ); const facets: ClientFacet[] = [ { key: "typ", label: t("projects.boards.columns.typ"), icon: , selected: typ, options: TYP_VALUES.map((value) => ({ value, label: t(`projects.typHint.${value}`), tone: TYP_TONE[value] })), }, { key: "access", label: t("projects.boards.columns.access"), icon: , tone: "blue-subtle", selected: access, options: ACCESS_VALUES.map((value) => ({ value, label: t(`projects.boards.access.${value}`) })), }, { key: "status", label: t("projects.boards.columns.status"), icon: , tone: "sky-subtle", selected: status, options: STATUS_VALUES.map((value) => ({ value, label: value === "active" ? t("projects.boards.status.usable") : t("projects.boards.status.locked"), })), }, ]; const FACET_SETTERS: Record void> = { typ: (value) => setTyp((current) => toggleValue(current, value)), access: (value) => setAccess((current) => toggleValue(current, value)), status: (value) => setStatus((current) => toggleValue(current, value)), }; function resetFilters() { setSearch(""); setTyp(EMPTY_SELECTION); setAccess(EMPTY_SELECTION); setStatus(EMPTY_SELECTION); } function renderAccessCell(row: BoardsStartRowVM) { if (!row.locked) { return (
{t("projects.boards.access.granted")}
); } return (
{row.requestPending ? t("projects.boards.access.pending") : t("projects.boards.locked.noPermission")}
); } function renderActionCell(row: BoardsStartRowVM) { // The row gear opens this board's settings (S04). It stays available on // locked boards for admins — configuring a board is an admin capability, // not a "can I work on it" capability. const gear = row.settingsHref ? ( } /> ) : null; if (!row.locked) { return (
{row.openHref ? ( ) : null} {gear}
); } return (
{row.requestPending ? ( // No dead button: a pending request renders as a plain status badge. {t("projects.boards.locked.requestPending")} ) : ( )} {gear}
); } return ( } title={t("projects.boards.title")} subtitle={t("projects.boards.subtitle")} actions={ data.canAdmin ? ( <> {data.adminHref ? ( ) : null} {data.lostReasonsHref ? ( ) : null} {data.newBoardHref ? ( ) : null} ) : undefined } /> {data.rows.length === 0 ? (
) : undefined } />
) : ( <> {/* --- Filter bar (S00: Typ / Zugriff / Status) --- */} FACET_SETTERS[facetKey]?.(value)} search={search} onSearchChange={setSearch} searchPlaceholder={t("projects.boards.searchPlaceholder")} onReset={resetFilters} labels={{ reset: t("projects.board.filter.reset"), removeChip: t("projects.board.filter.removeChip") }} trailing={ {data.lockedCount > 0 ? t("projects.boards.countLineWithLocked", { total: number(data.totalCount), usable: number(data.usableCount), locked: number(data.lockedCount) }) : t("projects.boards.countLine", { total: number(data.totalCount), usable: number(data.usableCount) })} } /> {/* --- Boards table (the ~/ui Table ignores its emptyText prop, so the no-matches state is rendered explicitly below) --- */} {rows.length === 0 ? (
{t("projects.boards.noMatches")}
) : (
{t("projects.boards.columns.board")}{t("projects.boards.columns.typ")}{t("projects.boards.columns.stages")}{t("projects.boards.columns.projects")}{t("projects.boards.columns.access")}{t("projects.boards.columns.status")}{t("projects.boards.columns.action")} } > {rows.map((row) => (
{TYP_ICON[row.typHint]}
{row.locked ? ( <> {row.name} ) : ( {row.name} )} {row.isDefault ? ( {t("projects.boards.defaultBadge")} ) : null}
{t(row.typLabelKey)} {t("projects.boards.stagesValue", { count: row.stageCount, formatted: number(row.stageCount) })} {number(row.projectCount)} {renderAccessCell(row)} {row.locked ? t("projects.boards.status.locked") : t("projects.boards.status.usable")} {/* Export pins the action column to the right edge. */} {renderActionCell(row)}
))}
{/* Footer line from the export: makes the locked rows self-explaining. */}
{data.lockedCount > 0 ? t("projects.boards.footerLineWithLocked", { count: data.totalCount, formatted: number(data.totalCount) }) : t("projects.boards.footerLine", { count: data.totalCount, formatted: number(data.totalCount) })}
)} )}
); } export default BoardsStartPage;