// WF-P8 S07 "Boards-Übersicht" — rebuilt against Davids Subframe export of // 2026-07-28 (page 5190e285-e92f-4ad2-9f3d-2a2f511fe695), including the create // dialog variants S07-D (50219cd7-…) and S07a (a0139eb6-…). // // The screen used to be a stack of accordion cards that configured every board // inline. David split that: this page lists the boards and each row links to // S04 (BoardSettingsPage) for the configuration. Pure/presentational — renders // the server-built PipelineAdminData and turns create/duplicate/archive into a // typed onSubmit(intent, fields) the route POSTs. No useLoaderData/useFetcher. // // Deliberate deltas against the export: // * The "Zugriff" column reports the shape of the restriction, not a team // name. PipelineAccess stores a role/group/user id, and resolving those to // display names is a lookup this table does not do. // * The export's header "Board-Einstellungen" button names no board. Settings // are per board, so it opens the default one (the board the footer line // names) and hides itself when the tenant has no board at all. // * S07-D and S07a are the same dialog in two states, so they are one // component here: the error state is what it renders once a create attempt // came back with field errors. import { useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { AppLink } from "~/components/app/AppLink"; import type { PipelineAdminData, PipelineAdminItem, PipelineTypHint } from "@hivegrid/view-models"; import { FeatherActivity, FeatherChevronRight, FeatherFilter, FeatherColumns, FeatherCopy, FeatherFolderKanban, FeatherGlobe, FeatherKanbanSquare, FeatherLayers, FeatherLock, FeatherMoreHorizontal, FeatherPlus, FeatherSettings, FeatherShield, FeatherTag, FeatherThumbsDown, FeatherTrash, FeatherUsers, FeatherX, } from "@subframe/core"; import * as SubframeCore from "@subframe/core"; import { FacetFilterBar } from "../shared/FacetFilterBar"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell"; import { BOARD_TYP_ICON, BOARD_TYP_TONE } from "./boardTypeVisuals"; import { Alert } from "~/ui/components/Alert"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Dialog } from "~/ui/components/Dialog"; import { DropdownMenu } from "~/ui/components/DropdownMenu"; import { EmptyState } from "~/ui/components/EmptyState"; import { IconButton } from "~/ui/components/IconButton"; import { IconWithBackground } from "~/ui/components/IconWithBackground"; import { Select } from "~/ui/components/Select"; import { Table } from "~/ui/components/Table"; import { Tag_Label } from "~/ui/components/Tag_Label"; import { TextInput } from "~/ui/components/TextInput"; import { useLocaleFormatters } from "~/locale/format"; export type PipelineAdminSubmit = (intent: string, fields: Record) => void; export type PipelineAdminPageProps = { data: PipelineAdminData; submitting: boolean; errorKey?: string | null; lostReasonsHref: string; /** S04 board settings of one board. */ settingsHref: (pipelineId: string) => string; actions: { onSubmit: PipelineAdminSubmit }; }; const DEFAULT_STAGES = JSON.stringify([ { name: "Neu", stageKind: "offen" }, { name: "Gewonnen", stageKind: "gewonnen" }, { name: "Verloren", stageKind: "verloren" }, ]); const TYP_OPTIONS = ["sales", "auftrag", "custom"] as const; export type BoardTypFilter = PipelineTypHint; export type BoardStatusFilter = "active" | "draft"; export type BoardAccessFilter = "everyone" | "restricted"; export type BoardRulesFilter = "withRules" | "withoutRules"; export type BoardFilters = { readonly search: string; /** Empty set = facet not filtered. Several values in one facet are OR-ed. */ readonly typ: ReadonlySet; readonly status: ReadonlySet; readonly access: ReadonlySet; readonly rules: ReadonlySet; }; const STATUS_OPTIONS: readonly BoardStatusFilter[] = ["active", "draft"]; const ACCESS_OPTIONS: readonly BoardAccessFilter[] = ["everyone", "restricted"]; const RULES_OPTIONS: readonly BoardRulesFilter[] = ["withRules", "withoutRules"]; 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; } /** * Client-side board filter, exported so the rule can be tested without driving * the Radix menus. The list is a handful of rows, so filtering here rather * than round-tripping to the server is the cheaper answer. */ export function filterBoards(boards: readonly PipelineAdminItem[], filters: BoardFilters): readonly PipelineAdminItem[] { const query = filters.search.trim().toLowerCase(); return boards.filter((board) => { if (filters.typ.size > 0 && !filters.typ.has(board.typHint)) return false; if (filters.status.size > 0 && !filters.status.has(board.statusKey)) return false; if (filters.access.size > 0 && !filters.access.has(board.access.scope)) return false; // "Regeln" is not the same question as "Zugriff": the access scope counts // denying rules only, so a board configured purely with granting rules // reads as "everyone" while still carrying rules. if (filters.rules.size > 0 && !filters.rules.has(board.accessRules.length > 0 ? "withRules" : "withoutRules")) return false; if (query && !board.name.toLowerCase().includes(query)) return false; return true; }); } /** Field errors of the create dialog hold i18n keys so the render stays dumb. */ type NewBoardErrors = { nameKey?: string; typKey?: string }; export function PipelineAdminPage(props: PipelineAdminPageProps) { const { t } = useTranslation(); const submit = props.actions.onSubmit; const boards = props.data.pipelines; const [filters, setFilters] = useState({ search: "", typ: EMPTY_SELECTION, status: EMPTY_SELECTION, access: EMPTY_SELECTION, rules: EMPTY_SELECTION, }); const visible = useMemo(() => filterBoards(boards, filters), [boards, filters]); const defaultBoard = boards.find((board) => board.isDefault) ?? null; const headerSettingsBoard = defaultBoard ?? boards[0] ?? null; const [newBoard, setNewBoard] = useState({ name: "", typHint: "" }); const [dialogOpen, setDialogOpen] = useState(false); const [createErrors, setCreateErrors] = useState({}); const [createFailed, setCreateFailed] = useState(false); // "waiting" = submit fired, POST not started yet; "inflight" = POST running. const [createPhase, setCreatePhase] = useState<"idle" | "waiting" | "inflight">("idle"); function resetDialog() { setNewBoard({ name: "", typHint: "" }); setCreateErrors({}); setCreateFailed(false); setCreatePhase("idle"); } // S07a error state: keep the dialog open until the create round-trip // succeeded. A server error re-shows the alert and maps the duplicate-name // key onto the name field; success closes and resets the dialog. useEffect(() => { if (createPhase === "waiting" && props.submitting) { setCreatePhase("inflight"); return; } if (createPhase === "inflight" && !props.submitting) { setCreatePhase("idle"); if (props.errorKey) { setCreateFailed(true); if (props.errorKey === "projects.error.pipelineNameDuplicate") { setCreateErrors({ nameKey: "projects.admin.createDialog.nameDuplicate" }); } } else { setDialogOpen(false); resetDialog(); } } }, [createPhase, props.submitting, props.errorKey]); function handleCreate() { const name = newBoard.name.trim(); const nextErrors: NewBoardErrors = {}; if (boards.some((board) => board.name.trim().toLowerCase() === name.toLowerCase())) { nextErrors.nameKey = "projects.admin.createDialog.nameDuplicate"; } if (!newBoard.typHint) { nextErrors.typKey = "projects.admin.createDialog.typRequired"; } if (nextErrors.nameKey || nextErrors.typKey) { setCreateErrors(nextErrors); setCreateFailed(true); return; } setCreateErrors({}); setCreateFailed(false); setCreatePhase("waiting"); submit("createPipeline", { name, typHint: newBoard.typHint, stages: DEFAULT_STAGES }); } return ( } title={t("projects.admin.title")} subtitle={t("projects.admin.subtitle")} actions={ <> {/* The export draws this button without saying which board it configures. It opens the default board — the one the footer line names — and falls back to the first board when none is marked. With no boards at all there is nothing to configure. */} {headerSettingsBoard ? ( ) : null} } /> , selected: filters.typ, options: TYP_OPTIONS.map((typ) => ({ value: typ, label: t(`projects.typHint.${typ}`), tone: BOARD_TYP_TONE[typ] })), }, { key: "status", label: t("projects.admin.filter.status"), icon: , tone: "sky-subtle", selected: filters.status, options: STATUS_OPTIONS.map((status) => ({ value: status, label: t(`projects.boardSettings.status.${status}`) })), }, { key: "access", label: t("projects.admin.filter.access"), icon: , tone: "blue-subtle", selected: filters.access, options: ACCESS_OPTIONS.map((scope) => ({ value: scope, label: t(`projects.admin.accessScope.${scope}`) })), }, { key: "rules", label: t("projects.admin.filter.rules"), icon: , tone: "sand-subtle", selected: filters.rules, options: RULES_OPTIONS.map((rules) => ({ value: rules, label: t(`projects.admin.rulesScope.${rules}`) })), }, ]} onToggle={(facetKey, value) => setFilters((current) => ({ ...current, [facetKey]: toggleValue(current[facetKey as "typ" | "status" | "access" | "rules"], value), })) } search={filters.search} onSearchChange={(value) => setFilters((current) => ({ ...current, search: value }))} searchPlaceholder={t("projects.fields.search")} onReset={() => setFilters({ search: "", typ: EMPTY_SELECTION, status: EMPTY_SELECTION, access: EMPTY_SELECTION, rules: EMPTY_SELECTION }) } labels={{ reset: t("projects.board.filter.reset"), removeChip: t("projects.board.filter.removeChip") }} trailing={ {t("projects.admin.boardCount", { count: visible.length })} } /> {props.errorKey ? ( ) : null} {visible.length === 0 ? ( ) : ( <>
}>{t("projects.admin.columns.board")}}>{t("projects.admin.columns.typ")}}>{t("projects.admin.columns.stages")}}>{t("projects.admin.columns.projects")}}>{t("projects.admin.columns.access")}}>{t("projects.admin.columns.status")} {/* "Aktionen" carries no icon in the export. */} {t("projects.admin.columns.actions")} } emptyText={t("projects.admin.empty")} > {visible.map((board) => ( ))}
{defaultBoard ? t("projects.admin.footerLine", { shown: visible.length, total: boards.length, name: defaultBoard.name }) : t("projects.admin.footerLineNoDefault", { shown: visible.length, total: boards.length })} )}
{ setDialogOpen(open); if (!open) resetDialog(); }} > {/* One flat card, as in the export: no tinted header or footer band — the dialog is short enough that the tints only cut it into stripes. */}
} />
{/* The trigger says "Neues Board", the dialog names the act. */} {t("projects.admin.createDialog.title")} {t("projects.admin.createDialog.subtitle")}
} aria-label={t("projects.actions.cancel")} onClick={() => { setDialogOpen(false); resetDialog(); }} />
{createFailed ? ( ) : null} { setNewBoard((s) => ({ ...s, name: e.target.value })); setCreateErrors((s) => ({ ...s, nameKey: undefined })); }} data-ui-id="ui.projects.admin.newPipeline.name" />
); } function BoardRow({ board, settingsHref, submit }: { board: PipelineAdminItem; settingsHref: string; submit: PipelineAdminSubmit }) { const { t } = useTranslation(); const formatters = useLocaleFormatters(); const idBase = `ui.projects.admin.row.${board.id}`; return (
{BOARD_TYP_ICON[board.typHint]}
{/* The board name is the one link in the row, so it is drawn as one. No badge next to it — which board is the default is what the footer line under the table says. */} {board.name}
{t(board.typHintLabelKey)} {t("projects.boards.stagesValue", { formatted: formatters.number(board.stageCount) })} {board.projectCount}
{board.access.scope === "everyone" ? ( ) : ( )} {t(board.access.labelKey)}
{t(`projects.boardSettings.status.${board.statusKey}`)} {/* Export pins the action column to the right edge. */}
} aria-label={t("projects.fields.actions")} data-ui-id={`${idBase}.menu`} /> } onSelect={() => submit("duplicatePipeline", { pipelineId: board.id, name: t("projects.admin.copyName", { name: board.name }) })} data-ui-id={`${idBase}.duplicate`} > {t("projects.actions.duplicatePipeline")} } onSelect={() => submit("archivePipeline", { pipelineId: board.id })} data-ui-id={`${idBase}.archive`} > {t("projects.actions.archivePipeline")}
); } export default PipelineAdminPage;