Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+192
-128
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user