Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -8,17 +8,28 @@ export type DateFieldProps = {
label: string;
name: string;
defaultValue?: string;
value?: string;
onChange?: (value: string) => void;
required?: boolean;
/** Width override; the field fills its column by default. */
className?: string;
};
export function DateField({ label, name, defaultValue }: DateFieldProps) {
export function DateField({ label, name, defaultValue, value, onChange, required, className }: DateFieldProps) {
return (
<label className="flex flex-col gap-1">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{label}</span>
<label className={`flex w-full flex-col gap-1 ${className ?? ""}`}>
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">
{label}
{required ? " *" : ""}
</span>
<input
type="date"
name={name}
defaultValue={defaultValue}
className="h-9 rounded-[4px] border border-solid border-border-default bg-transparent px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary outline-none"
value={value}
onChange={onChange ? (event) => onChange(event.target.value) : undefined}
required={required}
className="h-9 w-full rounded-[4px] border border-solid border-border-default bg-transparent px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary outline-none"
/>
</label>
);
@@ -78,6 +78,59 @@ describe("TaskDetailPage (interim-UI)", () => {
expect(container.querySelector('[data-ui-id="ui.tasks.detail.delete"]')).toBeInTheDocument();
});
it("saves the whole form from the single header button, in the agreed order", () => {
const { container } = render(
<Router>
<TaskDetailPage data={data()} />
</Router>,
);
const editForm = container.querySelector('[data-ui-id="ui.tasks.detail.edit"]') as HTMLFormElement;
const save = container.querySelector('[data-ui-id="ui.tasks.detail.save"]') as HTMLButtonElement;
// The save button sits in the header, outside the form it submits, and is
// wired to it by id — so assignment and watcher pick save together with the
// master data.
expect(save.getAttribute("type")).toBe("submit");
expect(save.getAttribute("form")).toBe(editForm.getAttribute("id"));
expect(editForm.querySelector('[name="assigneeId"]')).toBeInTheDocument();
expect(editForm.querySelector('[name="watcherUserId"]')).toBeInTheDocument();
// No second save/assign submit left at the bottom of the form. The only
// submits inside it are the watcher-remove buttons, which are explicitly
// re-associated to their own form.
const ownSubmits = [...editForm.querySelectorAll('button[type="submit"]')].filter((button) => !button.getAttribute("form"));
expect(ownSubmits).toHaveLength(0);
const order = [...container.querySelectorAll("[data-ui-id^='ui.tasks.detail.']")]
.map((element) => element.getAttribute("data-ui-id"))
.filter((id) => ["ui.tasks.detail.complete", "ui.tasks.detail.archive", "ui.tasks.detail.delete", "ui.tasks.detail.save"].includes(id ?? ""));
expect(order).toEqual(["ui.tasks.detail.complete", "ui.tasks.detail.archive", "ui.tasks.detail.delete", "ui.tasks.detail.save"]);
});
it("keeps the remove-watcher submit out of the edit form (no nested forms)", () => {
const { container } = render(
<Router>
<TaskDetailPage data={data()} />
</Router>,
);
const editForm = container.querySelector('[data-ui-id="ui.tasks.detail.edit"]') as HTMLFormElement;
expect(editForm.querySelector("form")).toBeNull();
const removeButton = container.querySelector('[data-watcher-id="u2"] button[type="submit"]') as HTMLButtonElement;
const removeFormId = removeButton.getAttribute("form");
expect(removeFormId).toBeTruthy();
const removeForm = container.querySelector(`#${removeFormId}`) as HTMLFormElement;
expect(removeForm).toBeInTheDocument();
expect(editForm.contains(removeForm)).toBe(false);
expect(removeForm.querySelector('[name="userId"]')).toHaveValue("u2");
});
it("has no back link — the shell already provides navigation", () => {
const { container } = render(
<Router>
<TaskDetailPage data={data()} />
</Router>,
);
expect(container.querySelector('[data-ui-id="ui.tasks.detail.back"]')).not.toBeInTheDocument();
});
it("hides the edit form + action buttons for a read-only viewer", () => {
const { container } = render(
<Router>
@@ -6,28 +6,53 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherArchive, FeatherCheck, FeatherTrash2 } from "@subframe/core";
import type { TaskDetailData, TaskPriority, TaskStatus } from "@hivegrid/view-models";
import { FeatherArchive, FeatherCheck, FeatherClipboard, FeatherSave, FeatherTrash2 } from "@subframe/core";
import type { TaskDetailData, TaskPriority, TaskStatus, TaskWatcherView } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Dialog } from "~/ui/components/Dialog";
import { IconButton } from "~/ui/components/IconButton";
import { Select } from "~/ui/components/Select";
import { Tag_Label } from "~/ui/components/Tag_Label";
import { TextArea } from "~/ui/components/TextArea";
import { TextInput } from "~/ui/components/TextInput";
import { DateField } from "./DateField";
import { APP_TIME_ZONE } from "~/locale/format";
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
const STATUSES: readonly TaskStatus[] = ["open", "in_progress", "blocked", "done", "cancelled"];
const PRIORITIES: readonly TaskPriority[] = ["low", "normal", "high", "urgent"];
/** The one edit form; the header's save button targets it via `form=`. */
const TASK_EDIT_FORM_ID = "task-edit-form";
/** Sentinel for "do not add a watcher" — an empty Select value is not allowed. */
export const NO_WATCHER = "__none__";
function watcherRemoveFormId(userId: string): string {
return `task-watcher-remove-${userId}`;
}
const sectionHeading = "text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary";
export type TaskDetailPageProps = {
data: TaskDetailData;
};
type BadgeFarbe = "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-neutral";
type BadgeFarbe = "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-neutral" | "subtle-information";
function priorityFarbe(priority: TaskPriority): BadgeFarbe {
switch (priority) {
case "urgent":
return "subtle-negative";
case "high":
return "subtle-warning";
case "normal":
return "subtle-information";
case "low":
default:
return "subtle-neutral";
}
}
function statusFarbe(status: TaskStatus): BadgeFarbe {
switch (status) {
@@ -53,58 +78,107 @@ function MetaRow({ label, value }: { label: string; value: string }) {
);
}
function WatcherList({
watchers,
canWrite,
removeLabel,
emptyLabel,
}: {
watchers: readonly TaskWatcherView[];
canWrite: boolean;
removeLabel: string;
emptyLabel: string;
}) {
if (watchers.length === 0) {
return <span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{emptyLabel}</span>;
}
return (
<ul className="flex w-full flex-col gap-2">
{watchers.map((watcher) => (
<li
key={watcher.userId}
className="flex items-center justify-between gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-3 py-2"
data-watcher-id={watcher.userId}
>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{watcher.label}</span>
{canWrite ? (
<IconButton
type="submit"
form={watcherRemoveFormId(watcher.userId)}
variant="ghost"
size="small"
icon={<FeatherTrash2 />}
aria-label={removeLabel}
/>
) : null}
</li>
))}
</ul>
);
}
export function TaskDetailPage({ data }: TaskDetailPageProps) {
const { t, i18n } = useTranslation();
const [deleteOpen, setDeleteOpen] = useState(false);
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium" });
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium" });
const deadlineLabel = data.deadlineIso ? dateFormatter.format(new Date(data.deadlineIso)) : "—";
return (
<div className="flex w-full max-w-[960px] flex-col gap-6 p-6" data-ui-id="ui.tasks.detail">
<Breadcrumbs>
<a href={data.listHref} className="no-underline">
<Breadcrumbs.Item>{t("tasks.nav.title")}</Breadcrumbs.Item>
</a>
<Breadcrumbs.Divider />
<Breadcrumbs.Item active>{data.title}</Breadcrumbs.Item>
</Breadcrumbs>
{/* Header + action bar */}
<div className="flex flex-wrap items-start justify-between gap-4">
<div className="flex flex-col gap-2">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{data.title}</span>
<div className="flex flex-wrap items-center gap-2">
// Same page chrome as the lead detail: full-bleed header bar carrying icon,
// title, status/priority badges and the action buttons, content below in
// PageBody. Before this the screen started with a bare heading in a padded
// div, which made it the only detail view without the app's header bar.
<PageShell uiId="ui.tasks.detail" className="bg-surface-neutral-primary">
<PageHeader
icon={<FeatherClipboard className={PAGE_HEADER_ICON_CLASS} />}
title={
<span className="inline-flex flex-wrap items-center gap-2">
{data.title}
<BadgeFeedback farbe={statusFarbe(data.status)} size="small">
{t(data.statusKey)}
</BadgeFeedback>
<Tag_Label tone="neutral-subtle" size="small" noAction>
<BadgeFeedback farbe={priorityFarbe(data.priority)} size="small">
{t(data.priorityKey)}
</Tag_Label>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t(data.sourceKey)}</span>
</div>
</div>
<div className="flex flex-wrap items-center gap-2" data-ui-id="ui.tasks.detail.actions">
{data.canWrite && data.status !== "done" ? (
<form method="post">
<Button type="submit" name="intent" value="complete" variant="tertiary" icon={<FeatherCheck />} data-ui-id="ui.tasks.detail.complete">
{t("tasks.detail.actions.complete")}
</BadgeFeedback>
</span>
}
subtitle={t(data.sourceKey)}
actions={
// Order: complete, archive, delete, save. "Erledigen" is the positive
// outcome and gets the green variant; archive and save are ordinary
// primary actions; delete keeps the destructive red. Save lives here
// rather than at the bottom of the form: it is the single write for
// every field below, reached via the `form` attribute.
<span className="flex flex-wrap items-center gap-2" data-ui-id="ui.tasks.detail.actions">
{data.canWrite && data.status !== "done" ? (
<form method="post">
<Button type="submit" name="intent" value="complete" variant="success" icon={<FeatherCheck />} data-ui-id="ui.tasks.detail.complete">
{t("tasks.detail.actions.complete")}
</Button>
</form>
) : null}
{data.canWrite ? (
<form method="post">
<Button type="submit" name="intent" value="archive" icon={<FeatherArchive />} data-ui-id="ui.tasks.detail.archive">
{t("tasks.detail.actions.archive")}
</Button>
</form>
) : null}
{data.canDelete ? (
<Button type="button" variant="destructive" icon={<FeatherTrash2 />} onClick={() => setDeleteOpen(true)} data-ui-id="ui.tasks.detail.delete">
{t("tasks.detail.actions.delete")}
</Button>
</form>
) : null}
{data.canWrite ? (
<form method="post">
<Button type="submit" name="intent" value="archive" variant="tertiary" icon={<FeatherArchive />} data-ui-id="ui.tasks.detail.archive">
{t("tasks.detail.actions.archive")}
) : null}
{data.canWrite ? (
<Button type="submit" form={TASK_EDIT_FORM_ID} icon={<FeatherSave />} data-ui-id="ui.tasks.detail.save">
{t("tasks.detail.actions.save")}
</Button>
</form>
) : null}
{data.canDelete ? (
<Button type="button" variant="destructive" icon={<FeatherTrash2 />} onClick={() => setDeleteOpen(true)} data-ui-id="ui.tasks.detail.delete">
{t("tasks.detail.actions.delete")}
</Button>
) : null}
</div>
</div>
) : null}
</span>
}
/>
<PageBody>
{/* Metadata */}
<Card>
@@ -129,27 +203,29 @@ export function TaskDetailPage({ data }: TaskDetailPageProps) {
) : null}
</Card>
{/* Edit form (writers only) */}
{/* Edit card (writers only): master data, assignment and watchers all in
one tile, all written by the single save button in the header. Every
control spans its grid cell so the tile's width is actually used. */}
{data.canWrite ? (
<Card>
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("tasks.detail.section.edit")}</span>
<form method="post" className="flex w-full flex-col gap-4" data-ui-id="ui.tasks.detail.edit">
<span className={sectionHeading}>{t("tasks.detail.section.edit")}</span>
<form id={TASK_EDIT_FORM_ID} method="post" className="flex w-full flex-col gap-4" data-ui-id="ui.tasks.detail.edit">
<input type="hidden" name="intent" value="update" />
<TextInput label={t("tasks.detail.field.title")} showLabel>
<TextInput className="max-w-none" label={t("tasks.detail.field.title")} showLabel>
<TextInput.Input name="title" defaultValue={data.title} required />
</TextInput>
<TextArea label={t("tasks.detail.field.description")} showLabel>
<TextArea className="max-w-none" label={t("tasks.detail.field.description")} showLabel>
<TextArea.Input name="description" defaultValue={data.description ?? ""} />
</TextArea>
<div className="flex flex-wrap items-end gap-4">
<Select className="max-w-[200px]" name="status" label={t("tasks.detail.field.status")} showLabel defaultValue={data.status}>
<div className="grid w-full gap-4 sm:grid-cols-3">
<Select className="max-w-none" name="status" label={t("tasks.detail.field.status")} showLabel defaultValue={data.status}>
{STATUSES.map((status) => (
<Select.Item key={status} value={status}>
{t(`tasks.status.${status}`)}
</Select.Item>
))}
</Select>
<Select className="max-w-[200px]" name="priority" label={t("tasks.detail.field.priority")} showLabel defaultValue={data.priority}>
<Select className="max-w-none" name="priority" label={t("tasks.detail.field.priority")} showLabel defaultValue={data.priority}>
{PRIORITIES.map((priority) => (
<Select.Item key={priority} value={priority}>
{t(`tasks.priority.${priority}`)}
@@ -158,83 +234,70 @@ export function TaskDetailPage({ data }: TaskDetailPageProps) {
</Select>
<DateField label={t("tasks.detail.field.deadline")} name="deadline" defaultValue={data.deadlineIso ? data.deadlineIso.slice(0, 10) : ""} />
</div>
<Button type="submit" className="w-fit">
{t("tasks.detail.actions.save")}
</Button>
</form>
<form method="post" className="flex w-full flex-wrap items-end gap-4" data-ui-id="ui.tasks.detail.reassign">
<input type="hidden" name="intent" value="reassign" />
<Select className="max-w-[200px]" name="assigneeType" label={t("tasks.detail.field.assigneeType")} showLabel defaultValue="user">
<Select.Item value="user">{t("tasks.detail.assignee.user")}</Select.Item>
<Select.Item value="group">{t("tasks.detail.assignee.group")}</Select.Item>
</Select>
<Select
className="max-w-[240px]"
name="assigneeId"
label={t("tasks.detail.field.assignee")}
showLabel
defaultValue={data.assignableUsers[0]?.id ?? data.assignableGroups[0]?.id}
>
{data.assignableUsers.map((user) => (
<Select.Item key={`u-${user.id}`} value={user.id}>
{user.label}
</Select.Item>
))}
{data.assignableGroups.map((group) => (
<Select.Item key={`g-${group.id}`} value={group.id}>
{group.label}
</Select.Item>
))}
</Select>
<Button type="submit" variant="secondary">
{t("tasks.detail.actions.reassign")}
</Button>
</form>
</Card>
) : null}
{/* Watchers */}
<div className="flex flex-col gap-3" data-ui-id="ui.tasks.detail.watchers">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("tasks.detail.section.watchers")}</span>
{data.watchers.length > 0 ? (
<ul className="flex flex-col gap-2">
{data.watchers.map((watcher) => (
<li
key={watcher.userId}
className="flex items-center justify-between gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-3 py-2"
data-watcher-id={watcher.userId}
{/* --- Assignment --- */}
<span className={sectionHeading}>{t("tasks.detail.section.assign")}</span>
<div className="grid w-full gap-4 sm:grid-cols-2" data-ui-id="ui.tasks.detail.reassign">
<Select className="max-w-none" name="assigneeType" label={t("tasks.detail.field.assigneeType")} showLabel defaultValue="user">
<Select.Item value="user">{t("tasks.detail.assignee.user")}</Select.Item>
<Select.Item value="group">{t("tasks.detail.assignee.group")}</Select.Item>
</Select>
<Select
className="max-w-none"
name="assigneeId"
label={t("tasks.detail.field.assignee")}
showLabel
defaultValue={data.assignableUsers[0]?.id ?? data.assignableGroups[0]?.id}
>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{watcher.label}</span>
{data.canWrite ? (
<form method="post">
<input type="hidden" name="intent" value="removeWatcher" />
<input type="hidden" name="userId" value={watcher.userId} />
<IconButton type="submit" variant="ghost" size="small" icon={<FeatherTrash2 />} aria-label={t("tasks.detail.actions.removeWatcher")} />
</form>
) : null}
</li>
))}
</ul>
) : (
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("tasks.detail.watchers.empty")}</span>
)}
{data.canWrite && data.assignableUsers.length > 0 ? (
<form method="post" className="flex flex-wrap items-end gap-2">
<input type="hidden" name="intent" value="addWatcher" />
<Select className="max-w-[240px]" name="userId" label={t("tasks.detail.field.watcher")} showLabel defaultValue={data.assignableUsers[0]?.id}>
{data.assignableUsers.map((user) => (
<Select.Item key={`w-${user.id}`} value={user.id}>
{user.label}
</Select.Item>
))}
</Select>
<Button type="submit" variant="secondary">
{t("tasks.detail.actions.addWatcher")}
</Button>
{data.assignableUsers.map((user) => (
<Select.Item key={`u-${user.id}`} value={user.id}>
{user.label}
</Select.Item>
))}
{data.assignableGroups.map((group) => (
<Select.Item key={`g-${group.id}`} value={group.id}>
{group.label}
</Select.Item>
))}
</Select>
</div>
{/* --- Watchers: adding one is part of the same save; removing is
not (it is a delete), so each remove button submits its own tiny
form declared after this one via the `form` attribute. --- */}
<span className={sectionHeading}>{t("tasks.detail.section.watchers")}</span>
<div className="flex w-full flex-col gap-3" data-ui-id="ui.tasks.detail.watchers">
<WatcherList watchers={data.watchers} canWrite removeLabel={t("tasks.detail.actions.removeWatcher")} emptyLabel={t("tasks.detail.watchers.empty")} />
{data.assignableUsers.length > 0 ? (
<Select className="max-w-none" name="watcherUserId" label={t("tasks.detail.field.watcher")} showLabel defaultValue={NO_WATCHER}>
<Select.Item value={NO_WATCHER}>{t("tasks.detail.watchers.none")}</Select.Item>
{data.assignableUsers.map((user) => (
<Select.Item key={`w-${user.id}`} value={user.id}>
{user.label}
</Select.Item>
))}
</Select>
) : null}
</div>
</form>
) : null}
</div>
{/* Remove-watcher forms live outside the edit form — nesting forms is
invalid HTML, so the buttons above associate via `form=`. */}
{data.watchers.map((watcher) => (
<form key={`rm-${watcher.userId}`} id={watcherRemoveFormId(watcher.userId)} method="post" className="hidden">
<input type="hidden" name="intent" value="removeWatcher" />
<input type="hidden" name="userId" value={watcher.userId} />
</form>
))}
</Card>
) : (
<Card>
<span className={sectionHeading}>{t("tasks.detail.section.watchers")}</span>
<div className="flex w-full flex-col gap-3" data-ui-id="ui.tasks.detail.watchers">
<WatcherList watchers={data.watchers} canWrite={false} removeLabel="" emptyLabel={t("tasks.detail.watchers.empty")} />
</div>
</Card>
)}
{/* Delete confirmation dialog (real ~/ui Dialog, size XS) */}
<Dialog open={deleteOpen} onOpenChange={setDeleteOpen}>
@@ -257,6 +320,7 @@ export function TaskDetailPage({ data }: TaskDetailPageProps) {
</div>
</Dialog.Content>
</Dialog>
</div>
</PageBody>
</PageShell>
);
}
@@ -0,0 +1,140 @@
// AK-P4b Interim-UI (AD-28) — "Neue Aufgabe" as a modal, mirroring the automation
// list pattern (WF-P12 "Neue Automation starten"): creating a task is trivial enough
// that a dialog on the list beats a dedicated page. Presentational only: the form
// posts to the create route action (`createHref`) with the exact same field contract
// as the standalone TaskNewPage, so the action stays untouched. No useLoaderData /
// useFetcher (DoD A.5). Final Subframe optics land as a tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus, FeatherX } from "@subframe/core";
import type { TaskPriority } from "@hivegrid/view-models";
import { Button } from "~/ui/components/Button";
import { Dialog } from "~/ui/components/Dialog";
import { IconButton } from "~/ui/components/IconButton";
import { Select } from "~/ui/components/Select";
import { TextArea } from "~/ui/components/TextArea";
import { TextInput } from "~/ui/components/TextInput";
import { DateField } from "./DateField";
import type { TaskNewPrefill, TaskPickerOption } from "./TaskNewPage";
import { TASK_CREATOR_ASSIGNEE } from "./TaskNewPage";
const PRIORITIES: readonly TaskPriority[] = ["low", "normal", "high", "urgent"];
// The single assignee Select carries the kind in its value; the hidden
// assigneeType/assigneeId inputs restore the action's field contract on submit.
function assigneeValue(kind: "user" | "group", id: string): string {
return `${kind}:${id}`;
}
export type TaskNewDialogProps = {
open: boolean;
onOpenChange: (open: boolean) => void;
/** Route that owns the create action (the standalone /tasks/new route). */
createHref: string;
assignableUsers: readonly TaskPickerOption[];
assignableGroups: readonly TaskPickerOption[];
prefill?: TaskNewPrefill;
};
export function TaskNewDialog({
open,
onOpenChange,
createHref,
assignableUsers,
assignableGroups,
prefill = null,
}: TaskNewDialogProps) {
const { t } = useTranslation();
const [assignee, setAssignee] = useState<string>(TASK_CREATOR_ASSIGNEE);
const [assigneeType, assigneeId] = assignee === TASK_CREATOR_ASSIGNEE ? ["user", ""] : assignee.split(":");
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<Dialog.Content className="w-[560px] max-w-[92vw] p-0">
<form method="post" action={createHref} className="flex w-full flex-col" data-ui-id="ui.tasks.new.dialog">
<div className="flex w-full items-start justify-between gap-3 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
<div className="flex flex-col items-start gap-1">
<span className="text-heading- font-heading- text-text-neutral-primary">{t("tasks.new.title")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("tasks.new.subtitle")}</span>
</div>
<IconButton
type="button"
variant="ghost"
size="small"
icon={<FeatherX />}
aria-label={t("tasks.new.actions.cancel")}
onClick={() => onOpenChange(false)}
/>
</div>
<div className="flex w-full flex-col gap-4 px-6 py-5 max-h-[65vh] overflow-y-auto mobile:px-4">
<TextInput label={t("tasks.detail.field.title")} showLabel>
<TextInput.Input name="title" required autoFocus data-ui-id="ui.tasks.new.title" />
</TextInput>
<TextArea label={t("tasks.detail.field.description")} showLabel>
<TextArea.Input name="description" />
</TextArea>
<div className="flex flex-wrap items-end gap-4">
<Select className="max-w-[200px]" name="priority" label={t("tasks.detail.field.priority")} showLabel defaultValue="normal">
{PRIORITIES.map((priority) => (
<Select.Item key={priority} value={priority}>
{t(`tasks.priority.${priority}`)}
</Select.Item>
))}
</Select>
<DateField label={t("tasks.detail.field.deadline")} name="deadline" />
</div>
<Select
className="w-full"
label={t("tasks.detail.field.assignee")}
showLabel
value={assignee}
onValueChange={(value: string) => setAssignee(value)}
>
<Select.Item value={TASK_CREATOR_ASSIGNEE}>{t("tasks.new.assignee.default")}</Select.Item>
{assignableUsers.map((user) => (
<Select.Item key={`u-${user.id}`} value={assigneeValue("user", user.id)}>
{user.label}
</Select.Item>
))}
{assignableGroups.map((group) => (
<Select.Item key={`g-${group.id}`} value={assigneeValue("group", group.id)}>
{group.label}
</Select.Item>
))}
</Select>
<input type="hidden" name="assigneeType" value={assigneeType} />
<input type="hidden" name="assigneeId" value={assigneeId} />
{prefill ? (
<div data-ui-id="ui.tasks.new.dialog.prefill">
<input type="hidden" name="entityType" value={prefill.entityType} />
<input type="hidden" name="entityId" value={prefill.entityId} />
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{t(`tasks.entity.${prefill.entityType}`)} · {prefill.entityId}
</span>
</div>
) : null}
</div>
<div className="flex w-full items-center justify-end gap-2 border-t border-solid border-border-default bg-surface-neutral-secondary px-6 py-4 mobile:flex-col-reverse mobile:items-stretch mobile:px-4">
<Button
type="button"
className="mobile:w-full"
variant="tertiary"
onClick={() => onOpenChange(false)}
data-ui-id="ui.tasks.new.dialog.cancel"
>
{t("tasks.new.actions.cancel")}
</Button>
<Button type="submit" className="mobile:w-full" icon={<FeatherPlus />} data-ui-id="ui.tasks.new.dialog.submit">
{t("tasks.new.actions.create")}
</Button>
</div>
</form>
</Dialog.Content>
</Dialog>
);
}
@@ -6,13 +6,13 @@
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { TaskPriority } from "@hivegrid/view-models";
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Select } from "~/ui/components/Select";
import { TextArea } from "~/ui/components/TextArea";
import { TextInput } from "~/ui/components/TextInput";
import { DateField } from "./DateField";
import { AppLink } from "~/components/app/AppLink";
const PRIORITIES: readonly TaskPriority[] = ["low", "normal", "high", "urgent"];
@@ -36,13 +36,6 @@ export function TaskNewPage({ assignableUsers, assignableGroups, prefill, cancel
return (
<div className="flex w-full max-w-[720px] flex-col gap-6 p-6" data-ui-id="ui.tasks.new">
<Breadcrumbs>
<a href={cancelHref} className="no-underline">
<Breadcrumbs.Item>{t("tasks.nav.title")}</Breadcrumbs.Item>
</a>
<Breadcrumbs.Divider />
<Breadcrumbs.Item active>{t("tasks.new.title")}</Breadcrumbs.Item>
</Breadcrumbs>
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("tasks.new.title")}</span>
@@ -98,11 +91,11 @@ export function TaskNewPage({ assignableUsers, assignableGroups, prefill, cancel
<Button type="submit" icon={<FeatherPlus />} data-ui-id="ui.tasks.new.submit">
{t("tasks.new.actions.create")}
</Button>
<a href={cancelHref} className="no-underline" data-ui-id="ui.tasks.new.cancel">
<AppLink href={cancelHref} className="no-underline" data-ui-id="ui.tasks.new.cancel">
<Button type="button" variant="tertiary">
{t("tasks.new.actions.cancel")}
</Button>
</a>
</AppLink>
</div>
</form>
</Card>
@@ -1,6 +1,6 @@
import { vi, describe, it, expect } from "vitest";
import "@testing-library/jest-dom";
import { render } from "@testing-library/react";
import { act, fireEvent, render } from "@testing-library/react";
import { BrowserRouter as Router } from "react-router";
import {
buildTaskListVM,
@@ -11,6 +11,7 @@ import {
} from "@hivegrid/view-models";
import { TasksListPage } from "./TasksListPage";
import { LIVE_FILTER_DEBOUNCE_MS } from "~/hooks/use-live-filter";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (str: string) => str, i18n: { language: "de" } }),
@@ -36,10 +37,10 @@ function row(overrides: Partial<TaskListRow> = {}): TaskListRow {
};
}
const filter: TaskListFilterState = { preset: "all", status: null, priority: null, assignedToUserId: null, includeArchived: false };
const filter: TaskListFilterState = { search: null, status: null, priority: null, assignedToUserId: null, includeArchived: false };
function baseProps() {
return { includeDemoData: false, nextHref: null, actions: { onApply: vi.fn() } };
return { includeDemoData: false, showDemoToggle: true, nextHref: null, actions: { onApply: vi.fn() } };
}
describe("TasksListPage (interim-UI)", () => {
@@ -77,16 +78,134 @@ describe("TasksListPage (interim-UI)", () => {
expect(container.querySelector('[data-ui-id="ui.tasks.list.new"]')).not.toBeInTheDocument();
});
it("renders the preset tabs + status/priority filter selects", () => {
it("opens the create dialog instead of navigating to the create page", () => {
const vm = buildTaskListVM({ rows: [row()], filter, canWrite: true, canDelete: false, createHref: "/acme/tasks/new" });
const { container, baseElement } = render(
<Router>
<TasksListPage vm={vm} {...baseProps()} assignableUsers={[{ id: "u1", label: "Alex Meier" }]} assignableGroups={[]} />
</Router>,
);
const cta = container.querySelector('[data-ui-id="ui.tasks.list.new"]') as HTMLElement;
expect(cta.tagName).toBe("BUTTON");
expect(baseElement.querySelector('[data-ui-id="ui.tasks.new.dialog"]')).not.toBeInTheDocument();
fireEvent.click(cta);
const form = baseElement.querySelector('[data-ui-id="ui.tasks.new.dialog"]') as HTMLFormElement;
expect(form).toBeInTheDocument();
expect(form.getAttribute("action")).toBe("/acme/tasks/new");
expect(form.getAttribute("method")).toBe("post");
expect(baseElement.querySelector('[data-ui-id="ui.tasks.new.title"]')).toBeInTheDocument();
});
it("renders the search box + status/priority filter selects", () => {
const vm = buildTaskListVM({ rows: [row()], filter, canWrite: true, canDelete: false, createHref: "/acme/tasks/new" });
const { container, getByText } = render(
<Router>
<TasksListPage vm={vm} {...baseProps()} />
</Router>,
);
expect(container.querySelector('[data-ui-id="ui.tasks.list.presets"]')).toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.tasks.list.filter.search"]')).toBeInTheDocument();
// The preset tabs (mine/created/all) were dropped in favour of the search.
expect(container.querySelector('[data-ui-id="ui.tasks.list.presets"]')).not.toBeInTheDocument();
// Status and priority are facet buttons on the shared bar now, not labelled
// Selects — the same strip the files browser and the boards wear.
expect(getByText("tasks.list.filter.status.label")).toBeInTheDocument();
expect(getByText("tasks.list.filter.priority.label")).toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.tasks.list.filter.status"]')).toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.tasks.list.filter.priority"]')).toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.tasks.list.filter.archived"]')).toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.tasks.list.filter.demo"]')).toBeInTheDocument();
// The old bespoke toolbar is gone with it.
expect(container.querySelector('[data-ui-id="ui.tasks.list.toolbar"]')).not.toBeInTheDocument();
});
it("applies the search debounced and seeds the box from the applied query", async () => {
vi.useFakeTimers();
try {
const onApply = vi.fn();
const vm = buildTaskListVM({ rows: [row()], filter, canWrite: true, canDelete: false, createHref: "/acme/tasks/new" });
const { container } = render(
<Router>
<TasksListPage vm={vm} {...baseProps()} actions={{ onApply }} />
</Router>,
);
const input = container.querySelector('[data-ui-id="ui.tasks.list.filter.search"]') as HTMLInputElement;
fireEvent.change(input, { target: { value: "Angebot" } });
expect(onApply).not.toHaveBeenCalled(); // still settling
await act(async () => {
vi.advanceTimersByTime(LIVE_FILTER_DEBOUNCE_MS);
});
expect(onApply).toHaveBeenCalledWith(expect.objectContaining({ search: "Angebot" }));
// The shared bar's box has no Enter key of its own — the term settles and
// applies itself, as it does on every other list.
onApply.mockClear();
fireEvent.change(input, { target: { value: "Rechnung" } });
await act(async () => {
vi.advanceTimersByTime(LIVE_FILTER_DEBOUNCE_MS);
});
expect(onApply).toHaveBeenCalledWith(expect.objectContaining({ search: "Rechnung" }));
} finally {
vi.useRealTimers();
}
});
it("shows a search already present in the query", () => {
const applied: TaskListFilterState = { ...filter, search: "Angebot" };
const vm = buildTaskListVM({ rows: [row()], filter: applied, canWrite: true, canDelete: false, createHref: "/acme/tasks/new" });
const { container } = render(
<Router>
<TasksListPage vm={vm} {...baseProps()} />
</Router>,
);
expect((container.querySelector('[data-ui-id="ui.tasks.list.filter.search"]') as HTMLInputElement).value).toBe("Angebot");
});
it("offers status and priority as inline dropdowns that save on pick", () => {
const vm = buildTaskListVM({ rows: [row()], filter, canWrite: true, canDelete: false, createHref: "/acme/tasks/new" });
const onSetStatus = vi.fn();
const onSetPriority = vi.fn();
const { container, baseElement } = render(
<Router>
<TasksListPage vm={vm} {...baseProps()} actions={{ onApply: vi.fn(), onSetStatus, onSetPriority }} />
</Router>,
);
// Radix does not open on click in jsdom — drive it by keyboard.
const statusTrigger = container.querySelector('[data-ui-id="ui.tasks.list.row.status.t1"]') as HTMLElement;
expect(statusTrigger.tagName).toBe("BUTTON");
fireEvent.keyDown(statusTrigger, { key: "Enter" });
fireEvent.click(baseElement.querySelector('[data-ui-id="ui.tasks.list.row.status.t1.done"]') as HTMLElement);
expect(onSetStatus).toHaveBeenCalledWith("t1", "done");
const priorityTrigger = container.querySelector('[data-ui-id="ui.tasks.list.row.priority.t1"]') as HTMLElement;
fireEvent.keyDown(priorityTrigger, { key: "Enter" });
fireEvent.click(baseElement.querySelector('[data-ui-id="ui.tasks.list.row.priority.t1.urgent"]') as HTMLElement);
expect(onSetPriority).toHaveBeenCalledWith("t1", "urgent");
});
it("keeps status and priority read-only when no inline handlers are injected", () => {
const vm = buildTaskListVM({ rows: [row()], filter, canWrite: false, canDelete: false, createHref: "/acme/tasks/new" });
const { container, getByText } = render(
<Router>
<TasksListPage vm={vm} {...baseProps()} />
</Router>,
);
expect(container.querySelector('[data-ui-id="ui.tasks.list.row.status.t1"]')).not.toBeInTheDocument();
expect(getByText("tasks.status.open")).toBeInTheDocument();
});
it("hides the demo-data checkbox when the demo UI is disabled (production)", () => {
const vm = buildTaskListVM({ rows: [row()], filter, canWrite: true, canDelete: false, createHref: "/acme/tasks/new" });
const { getByText, queryByText } = render(
<Router>
<TasksListPage vm={vm} {...{ ...baseProps(), showDemoToggle: false }} />
</Router>,
);
expect(getByText("tasks.list.filter.archived")).toBeInTheDocument();
expect(queryByText("tasks.list.filter.demo")).not.toBeInTheDocument();
});
it("shows the pagination link when a next page exists", () => {
@@ -5,28 +5,31 @@
// (DoD 8); the standalone /tasks route is its host, entity detail views embed it.
// Final Subframe optics land as a tracked design-nachzug once David's D-P4 ships.
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { TaskListPreset, TaskListRow, TaskListVM, TaskPriority, TaskStatus } from "@hivegrid/view-models";
import { FeatherChevronDown, FeatherCircleDot, FeatherClipboard, FeatherFlag, FeatherPlus } from "@subframe/core";
import * as SubframeCore from "@subframe/core";
import type { TaskListRow, TaskListVM, TaskPriority, TaskStatus } from "@hivegrid/view-models";
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
import { FacetFilterBar, type ClientFacet } from "../shared/FacetFilterBar";
import { TaskNewDialog } from "./TaskNewDialog";
import type { TaskPickerOption } from "./TaskNewPage";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Checkbox } from "~/ui/components/Checkbox";
import { DropdownMenu } from "~/ui/components/DropdownMenu";
import { EmptyState } from "~/ui/components/EmptyState";
import { Select } from "~/ui/components/Select";
import { Table } from "~/ui/components/Table";
import { Tag_Label } from "~/ui/components/Tag_Label";
import { ToggleGroup } from "~/ui/components/ToggleGroup";
import { APP_TIME_ZONE } from "~/locale/format";
import { useLiveFilter } from "~/hooks/use-live-filter";
import { AppLink } from "~/components/app/AppLink";
const PRESETS: readonly TaskListPreset[] = ["mine", "created", "all"];
const STATUSES: readonly TaskStatus[] = ["open", "in_progress", "blocked", "done", "cancelled"];
const PRIORITIES: readonly TaskPriority[] = ["low", "normal", "high", "urgent"];
// Shared "no filter" sentinel for the status/priority Selects (empty string is not
// a valid Select value, so a non-empty sentinel maps back to null).
const FILTER_ALL = "__all__";
export type TaskListQuery = {
preset: TaskListPreset;
search: string | null;
status: TaskStatus | null;
priority: TaskPriority | null;
includeArchived: boolean;
@@ -36,18 +39,41 @@ export type TaskListQuery = {
export type TasksListActions = {
/** Navigate (GET) to the same route with the given preset/filter state. */
onApply: (query: TaskListQuery) => void;
/** Inline status change from the table (POST). Omitted for readers. */
onSetStatus?: (taskId: string, status: TaskStatus) => void;
/** Inline priority change from the table (POST). Omitted for readers. */
onSetPriority?: (taskId: string, priority: TaskPriority) => void;
};
export type TasksListPageProps = {
vm: TaskListVM;
/** Whether demo-data rows are currently shown (kept out of the VM). */
includeDemoData: boolean;
/** Demo-data toggle is a staging/dev-only affordance (env-gated by the loader). */
showDemoToggle: boolean;
/** Href for the next cursor page, or null on the last page. */
nextHref: string | null;
/** Assignee picker options for the create dialog (loader-provided, empty when read-only). */
assignableUsers?: readonly TaskPickerOption[];
assignableGroups?: readonly TaskPickerOption[];
actions: TasksListActions;
};
type BadgeFarbe = "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-neutral";
type BadgeFarbe = "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-neutral" | "subtle-information";
function priorityFarbe(priority: TaskPriority): BadgeFarbe {
switch (priority) {
case "urgent":
return "subtle-negative";
case "high":
return "subtle-warning";
case "normal":
return "subtle-information";
case "low":
default:
return "subtle-neutral";
}
}
function statusFarbe(status: TaskStatus): BadgeFarbe {
switch (status) {
@@ -64,119 +90,249 @@ function statusFarbe(status: TaskStatus): BadgeFarbe {
}
}
export function TasksListPage({ vm, includeDemoData, nextHref, actions }: TasksListPageProps) {
export function TasksListPage({
vm,
includeDemoData,
showDemoToggle,
nextHref,
assignableUsers = [],
assignableGroups = [],
actions,
}: TasksListPageProps) {
const { t, i18n } = useTranslation();
// Creating a task is trivial enough for a modal (like "Neue Automation"), so the
// list CTA opens the dialog instead of navigating to the standalone create page.
const [createOpen, setCreateOpen] = useState(false);
// Loading / not-ready: keep the marker so the shell + e2e see a stable surface.
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.tasks.list" />;
}
const { rows, filter, canWrite, createHref, emptyHeadlineKey, emptyBodyKey } = vm.data;
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium" });
const data = vm.status === "ready" ? vm.data : null;
const appliedSearch = data?.filter.search ?? "";
// Search draft: the input types locally, the applied value lives in the URL.
// Same contract as the lead inbox — free text settles (debounced) before the
// server round-trip, dropdowns/checkboxes apply immediately.
const [search, setSearch] = useState(appliedSearch);
function applyPatch(patch: Partial<TaskListQuery>) {
if (!data) return;
actions.onApply({
preset: filter.preset,
status: filter.status,
priority: filter.priority,
includeArchived: filter.includeArchived,
search: search.trim() || null,
status: data.filter.status,
priority: data.filter.priority,
includeArchived: data.filter.includeArchived,
includeDemoData,
...patch,
});
}
useLiveFilter(search.trim(), appliedSearch, () => applyPatch({}));
// The box both writes AND reads the query: arriving with `?q=` already set
// (shared link, back button) has to show up in the input. Guarded by the
// applied value so typing is never overwritten mid-keystroke.
const lastAppliedSearch = useRef(appliedSearch);
useEffect(() => {
if (lastAppliedSearch.current === appliedSearch) return;
lastAppliedSearch.current = appliedSearch;
setSearch(appliedSearch);
}, [appliedSearch]);
// Loading / not-ready: keep the marker so the shell + e2e see a stable surface.
if (!data) {
return (
<PageShell uiId="ui.tasks.list">
<PageHeader
icon={<FeatherClipboard className={PAGE_HEADER_ICON_CLASS} />}
title={t("tasks.list.title")}
subtitle={t("tasks.list.subtitle")}
/>
<PageBody>{null}</PageBody>
</PageShell>
);
}
const { rows, filter, canWrite, createHref, emptyHeadlineKey, emptyBodyKey } = data;
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium" });
// Single-select facets on a multi-select control: picking the active option
// again clears it, which is what the chip's X does too.
const facets: ClientFacet[] = [
{
key: "status",
label: t("tasks.list.filter.status.label"),
icon: <FeatherCircleDot />,
tone: "blue-subtle",
options: STATUSES.map((status) => ({ value: status, label: t(`tasks.status.${status}`) })),
selected: new Set(filter.status ? [filter.status] : []),
},
{
key: "priority",
label: t("tasks.list.filter.priority.label"),
icon: <FeatherFlag />,
tone: "violet-subtle",
options: PRIORITIES.map((priority) => ({ value: priority, label: t(`tasks.priority.${priority}`) })),
selected: new Set(filter.priority ? [filter.priority] : []),
},
];
function toggleFacet(facetKey: string, value: string) {
if (facetKey === "status") {
return applyPatch({ status: filter.status === value ? null : (value as TaskStatus) });
}
if (facetKey === "priority") {
return applyPatch({ priority: filter.priority === value ? null : (value as TaskPriority) });
}
return undefined;
}
/** Back to an unfiltered list, search box included. */
function resetFilter() {
setSearch("");
actions.onApply({ search: null, status: null, priority: null, includeArchived: false, includeDemoData });
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.tasks.list">
{/* Header: title + subtitle (0px rhythm) + create CTA */}
<div className="flex flex-wrap items-start justify-between gap-4">
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("tasks.list.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("tasks.list.subtitle")}
</span>
</div>
{canWrite ? (
<a href={createHref} className="no-underline" data-ui-id="ui.tasks.list.new">
<Button icon={<FeatherPlus />}>{t("tasks.list.actions.new")}</Button>
</a>
<PageShell uiId="ui.tasks.list">
<PageHeader
icon={<FeatherClipboard className={PAGE_HEADER_ICON_CLASS} />}
title={t("tasks.list.title")}
subtitle={t("tasks.list.subtitle")}
actions={
canWrite ? (
<Button icon={<FeatherPlus />} onClick={() => setCreateOpen(true)} data-ui-id="ui.tasks.list.new">
{t("tasks.list.actions.new")}
</Button>
) : undefined
}
/>
{/* --- Filter bar: the shared facet strip the files browser, the boards
and the plantafel wear - free-text box, facet buttons, chips for what
is active and one reset. Server-side navigation on change; the free
text settles (debounced) before the round-trip, a facet applies at
once. --- */}
<FacetFilterBar
uiId="ui.tasks.list.filter"
facets={facets}
onToggle={toggleFacet}
search={search}
onSearchChange={setSearch}
searchPlaceholder={t("tasks.list.filter.searchPlaceholder")}
onReset={resetFilter}
labels={{ reset: t("tasks.list.filter.reset"), removeChip: t("tasks.list.filter.removeChip") }}
trailing={
<>
<Checkbox
label={t("tasks.list.filter.archived")}
checked={filter.includeArchived}
onCheckedChange={(checked: boolean) => applyPatch({ includeArchived: checked })}
data-ui-id="ui.tasks.list.filter.archived"
/>
{showDemoToggle ? (
<Checkbox
label={t("tasks.list.filter.demo")}
checked={includeDemoData}
onCheckedChange={(checked: boolean) => applyPatch({ includeDemoData: checked })}
data-ui-id="ui.tasks.list.filter.demo"
/>
) : null}
</>
}
/>
<PageBody>
{rows.length === 0 ? (
<div data-ui-id="ui.tasks.list.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<TableView
rows={rows}
dateFormatter={dateFormatter}
t={t}
statusFarbe={statusFarbe}
canWrite={canWrite}
onSetStatus={actions.onSetStatus}
onSetPriority={actions.onSetPriority}
/>
)}
{nextHref ? (
<div className="flex justify-center pt-2" data-ui-id="ui.tasks.list.pagination">
<AppLink href={nextHref} className="no-underline">
<Button variant="tertiary">{t("tasks.list.pagination.next")}</Button>
</AppLink>
</div>
) : null}
</div>
{/* Preset tabs (server-side navigation) */}
<div className="flex flex-wrap items-center gap-4" data-ui-id="ui.tasks.list.presets">
<ToggleGroup
value={filter.preset}
onValueChange={(value: string) => {
if (PRESETS.includes(value as TaskListPreset)) applyPatch({ preset: value as TaskListPreset });
}}
>
{PRESETS.map((preset) => (
<ToggleGroup.Item key={preset} value={preset} aria-label={t(`tasks.list.preset.${preset}`)}>
{t(`tasks.list.preset.${preset}`)}
</ToggleGroup.Item>
))}
</ToggleGroup>
</div>
{canWrite ? (
<TaskNewDialog
open={createOpen}
onOpenChange={setCreateOpen}
createHref={createHref}
assignableUsers={assignableUsers}
assignableGroups={assignableGroups}
/>
) : null}
</PageBody>
</PageShell>
);
}
{/* Filter bar (server-side, navigation on change) */}
<div className="flex flex-wrap items-center gap-4" data-ui-id="ui.tasks.list.filter">
<Select
className="max-w-[240px]"
label={t("tasks.list.filter.status.label")}
showLabel
value={filter.status ?? FILTER_ALL}
onValueChange={(value: string) => applyPatch({ status: value === FILTER_ALL ? null : (value as TaskStatus) })}
>
<Select.Item value={FILTER_ALL}>{t("tasks.list.filter.status.all")}</Select.Item>
{STATUSES.map((status) => (
<Select.Item key={status} value={status}>
{t(`tasks.status.${status}`)}
</Select.Item>
))}
</Select>
<Select
className="max-w-[240px]"
label={t("tasks.list.filter.priority.label")}
showLabel
value={filter.priority ?? FILTER_ALL}
onValueChange={(value: string) => applyPatch({ priority: value === FILTER_ALL ? null : (value as TaskPriority) })}
>
<Select.Item value={FILTER_ALL}>{t("tasks.list.filter.priority.all")}</Select.Item>
{PRIORITIES.map((priority) => (
<Select.Item key={priority} value={priority}>
{t(`tasks.priority.${priority}`)}
</Select.Item>
))}
</Select>
<Checkbox
label={t("tasks.list.filter.archived")}
checked={filter.includeArchived}
onCheckedChange={(checked: boolean) => applyPatch({ includeArchived: checked })}
/>
<Checkbox
label={t("tasks.list.filter.demo")}
checked={includeDemoData}
onCheckedChange={(checked: boolean) => applyPatch({ includeDemoData: checked })}
/>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.tasks.list.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<TableView rows={rows} dateFormatter={dateFormatter} t={t} statusFarbe={statusFarbe} />
)}
{nextHref ? (
<div className="flex justify-center pt-2" data-ui-id="ui.tasks.list.pagination">
<a href={nextHref} className="no-underline">
<Button variant="tertiary">{t("tasks.list.pagination.next")}</Button>
</a>
</div>
) : null}
</div>
/**
* Badge that doubles as the edit control for an enum column (same affordance the
* lead inbox uses for its status): clicking it opens the list of values and
* picking one saves right away. Falls back to a plain badge for readers.
*/
function InlineBadgeSelect<TValue extends string>({
value,
values,
farbe,
labelKey,
ariaLabel,
uiId,
t,
onSelect,
}: {
value: TValue;
values: readonly TValue[];
farbe: (value: TValue) => BadgeFarbe;
labelKey: (value: TValue) => string;
ariaLabel: string;
uiId: string;
t: (key: string) => string;
onSelect?: (value: TValue) => void;
}) {
const badge = (
<BadgeFeedback farbe={farbe(value)} size="small">
{t(labelKey(value))}
</BadgeFeedback>
);
if (!onSelect) return badge;
return (
<SubframeCore.DropdownMenu.Root>
<SubframeCore.DropdownMenu.Trigger asChild>
<button type="button" className="focus-visible:shadow-focus flex items-center gap-1 rounded-sm outline-none" aria-label={ariaLabel} data-ui-id={uiId}>
{badge}
<FeatherChevronDown className="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary" />
</button>
</SubframeCore.DropdownMenu.Trigger>
<SubframeCore.DropdownMenu.Portal>
<SubframeCore.DropdownMenu.Content side="bottom" align="start" sideOffset={4} asChild>
<DropdownMenu className="gap-1">
{values.map((candidate) => (
<DropdownMenu.DropdownItem
key={candidate}
showCheckbox
selected={candidate === value}
className="bg-surface-neutral-primary hover:bg-surface-neutral-tertiary active:bg-surface-neutral-secondary"
onSelect={() => candidate !== value && onSelect(candidate)}
data-ui-id={`${uiId}.${candidate}`}
>
{t(labelKey(candidate))}
</DropdownMenu.DropdownItem>
))}
</DropdownMenu>
</SubframeCore.DropdownMenu.Content>
</SubframeCore.DropdownMenu.Portal>
</SubframeCore.DropdownMenu.Root>
);
}
@@ -185,17 +341,28 @@ function TableView({
dateFormatter,
t,
statusFarbe,
canWrite,
onSetStatus,
onSetPriority,
}: {
rows: readonly TaskListRow[];
dateFormatter: Intl.DateTimeFormat;
t: (key: string) => string;
statusFarbe: (status: TaskStatus) => BadgeFarbe;
canWrite: boolean;
onSetStatus?: (taskId: string, status: TaskStatus) => void;
onSetPriority?: (taskId: string, priority: TaskPriority) => void;
}) {
return (
<div className="w-full overflow-x-auto" data-ui-id="ui.tasks.list.table">
// Same table chrome as /automations: the rounded, bordered card keeps the
// rows visually contained instead of bleeding into the page background.
<div
className="flex w-full flex-col items-start overflow-hidden overflow-x-auto rounded-lg border border-solid border-border-default shadow-sm"
data-ui-id="ui.tasks.list.table"
>
<Table
header={
<Table.HeaderRow>
<Table.HeaderRow className="bg-surface-neutral-tertiary">
<Table.HeaderCell>{t("tasks.list.column.title")}</Table.HeaderCell>
<Table.HeaderCell>{t("tasks.list.column.status")}</Table.HeaderCell>
<Table.HeaderCell>{t("tasks.list.column.priority")}</Table.HeaderCell>
@@ -207,19 +374,33 @@ function TableView({
{rows.map((row) => (
<Table.Row key={row.id} data-row-id={row.id}>
<Table.Cell>
<a href={row.detailHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
<AppLink href={row.detailHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
{row.title}
</a>
</AppLink>
</Table.Cell>
<Table.Cell>
<BadgeFeedback farbe={statusFarbe(row.status)} size="small">
{t(row.statusKey)}
</BadgeFeedback>
<InlineBadgeSelect
value={row.status}
values={STATUSES}
farbe={statusFarbe}
labelKey={(status) => `tasks.status.${status}`}
ariaLabel={t("tasks.list.actions.changeStatus")}
uiId={`ui.tasks.list.row.status.${row.id}`}
t={t}
onSelect={canWrite && onSetStatus ? (status) => onSetStatus(row.id, status) : undefined}
/>
</Table.Cell>
<Table.Cell>
<Tag_Label tone="neutral-subtle" size="small" noAction>
{t(row.priorityKey)}
</Tag_Label>
<InlineBadgeSelect
value={row.priority}
values={PRIORITIES}
farbe={priorityFarbe}
labelKey={(priority) => `tasks.priority.${priority}`}
ariaLabel={t("tasks.list.actions.changePriority")}
uiId={`ui.tasks.list.row.priority.${row.id}`}
t={t}
onSelect={canWrite && onSetPriority ? (priority) => onSetPriority(row.id, priority) : undefined}
/>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">