Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+34
-76
@@ -4,11 +4,11 @@
|
||||
// filters. The list shape is the reusable component (DoD 8); this route is its
|
||||
// standalone host.
|
||||
//
|
||||
// Baseline functional UI (data-ui-id markers for e2e); the Subframe visual polish
|
||||
// follows Davids D-P4 delta (Dev-Nachzug).
|
||||
// Interim-UI (AD-28): renders the ~/ui preview screen TasksListPage; the loader
|
||||
// owns navigation for preset/filter changes (server-side). Final Subframe optics
|
||||
// land as a tracked design-nachzug once David's D-P4 delta ships.
|
||||
|
||||
import { type LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { type LoaderFunctionArgs, useLoaderData, useNavigate } from "react-router";
|
||||
import {
|
||||
buildTaskListVM,
|
||||
taskEntityLabelKey,
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
type TaskListPreset,
|
||||
type TaskListRow,
|
||||
type TaskListVM,
|
||||
} from "@toolctrl/view-models";
|
||||
} from "@hivegrid/view-models";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { loadTasksContext, notFoundResponse, requireTasksPermission } from "~/utils/integrations/taskAccess.server";
|
||||
import {
|
||||
@@ -30,9 +30,10 @@ import {
|
||||
type TaskStatus,
|
||||
} from "~/utils/integrations/taskService.server";
|
||||
import { tasksDetailPath, tasksNewPath } from "~/utils/integrations/taskRoutePaths";
|
||||
import { TasksListPage, type TaskListQuery } from "~/components/screens/tasks/TasksListPage";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
|
||||
type LoaderData = { title: string; vm: TaskListVM };
|
||||
type LoaderData = { title: string; vm: TaskListVM; includeDemoData: boolean; nextHref: string | null };
|
||||
|
||||
const PRESETS: readonly TaskListPreset[] = ["mine", "created", "all"];
|
||||
const TERMINAL: ReadonlySet<TaskStatus> = new Set<TaskStatus>(["done", "cancelled"]);
|
||||
@@ -45,11 +46,13 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const { t } = await getTranslations(request);
|
||||
const ctx = await loadTasksContext({ request, params });
|
||||
const tenantSlug = params.tenant ?? "";
|
||||
const url = new URL(request.url);
|
||||
const includeDemoData = url.searchParams.get("demo") === "show";
|
||||
|
||||
const emptyFilter = { preset: "all" as TaskListPreset, status: null, priority: null, assignedToUserId: null, includeArchived: false };
|
||||
if (!ctx.hasModule) {
|
||||
const vm = buildTaskListVM({ rows: [], filter: emptyFilter, canWrite: false, canDelete: false, createHref: tasksNewPath(tenantSlug) });
|
||||
return Response.json({ title: `${t("tasks.list.title")} | ${process.env.APP_NAME}`, vm } satisfies LoaderData);
|
||||
return Response.json({ title: `${t("tasks.list.title")} | ${process.env.APP_NAME}`, vm, includeDemoData, nextHref: null } satisfies LoaderData);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -58,7 +61,6 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
throw notFoundResponse();
|
||||
}
|
||||
|
||||
const url = new URL(request.url);
|
||||
const preset = parsePreset(url.searchParams.get("preset"));
|
||||
const status = (url.searchParams.get("status") as TaskStatus | null) || null;
|
||||
const priority = (url.searchParams.get("priority") as TaskPriority | null) || null;
|
||||
@@ -68,7 +70,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const { rows, nextCursor } = await listTasksForBrowser({
|
||||
tenantId: ctx.tenantId,
|
||||
ctx,
|
||||
filter: { preset, status, priority, includeArchived },
|
||||
filter: { preset, status, priority, includeArchived, includeDemoData },
|
||||
cursor,
|
||||
});
|
||||
|
||||
@@ -95,7 +97,17 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
nextCursor,
|
||||
});
|
||||
|
||||
return Response.json({ title: `${t("tasks.list.title")} | ${process.env.APP_NAME}`, vm } satisfies LoaderData);
|
||||
// Preserve the active preset/filter when paging via cursor.
|
||||
const nextParams = new URLSearchParams();
|
||||
if (preset !== "all") nextParams.set("preset", preset);
|
||||
if (status) nextParams.set("status", status);
|
||||
if (priority) nextParams.set("priority", priority);
|
||||
if (includeArchived) nextParams.set("archived", "1");
|
||||
if (includeDemoData) nextParams.set("demo", "show");
|
||||
if (nextCursor) nextParams.set("cursor", nextCursor);
|
||||
const nextHref = nextCursor ? `?${nextParams.toString()}` : null;
|
||||
|
||||
return Response.json({ title: `${t("tasks.list.title")} | ${process.env.APP_NAME}`, vm, includeDemoData, nextHref } satisfies LoaderData);
|
||||
};
|
||||
|
||||
/** Map a domain TaskRow to the routing-resolved TaskListRow (shared by embeds). */
|
||||
@@ -130,75 +142,21 @@ export function toTaskListRow(
|
||||
}
|
||||
|
||||
export default function TasksBrowserRoute() {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { vm } = useLoaderData<LoaderData>();
|
||||
const { vm, includeDemoData, nextHref } = useLoaderData<LoaderData>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <main className="mx-auto max-w-5xl px-4 py-10" data-ui-id="ui.tasks.list" />;
|
||||
function onApply(query: TaskListQuery) {
|
||||
const params = new URLSearchParams();
|
||||
if (query.preset !== "all") params.set("preset", query.preset);
|
||||
if (query.status) params.set("status", query.status);
|
||||
if (query.priority) params.set("priority", query.priority);
|
||||
if (query.includeArchived) params.set("archived", "1");
|
||||
if (query.includeDemoData) params.set("demo", "show");
|
||||
// Reset cursor pagination whenever the preset/filter changes.
|
||||
navigate({ search: params.toString() });
|
||||
}
|
||||
|
||||
const { rows, canWrite, createHref, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium" });
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-10" data-ui-id="ui.tasks.list">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-foreground text-xl font-semibold">{t("tasks.list.title")}</h1>
|
||||
<p className="text-muted-foreground mt-1 text-sm">{t("tasks.list.subtitle")}</p>
|
||||
</div>
|
||||
{canWrite ? (
|
||||
<a href={createHref} className="text-theme-600 font-medium" data-ui-id="ui.tasks.list.new">
|
||||
{t("tasks.list.actions.new")}
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<nav className="text-muted-foreground mt-4 flex gap-4 text-sm" data-ui-id="ui.tasks.list.presets">
|
||||
{PRESETS.map((preset) => (
|
||||
<a key={preset} href={`?preset=${preset}`} className="hover:text-foreground">
|
||||
{t(`tasks.list.preset.${preset}`)}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div className="mt-10 text-center" data-ui-id="ui.tasks.list.empty">
|
||||
<p className="text-foreground font-medium">{t(emptyHeadlineKey)}</p>
|
||||
<p className="text-muted-foreground mt-1 text-sm">{t(emptyBodyKey)}</p>
|
||||
</div>
|
||||
) : (
|
||||
<table className="mt-6 w-full text-left text-sm" data-ui-id="ui.tasks.list.table">
|
||||
<thead>
|
||||
<tr className="text-muted-foreground border-b">
|
||||
<th className="py-2">{t("tasks.list.column.title")}</th>
|
||||
<th className="py-2">{t("tasks.list.column.status")}</th>
|
||||
<th className="py-2">{t("tasks.list.column.priority")}</th>
|
||||
<th className="py-2">{t("tasks.list.column.assignee")}</th>
|
||||
<th className="py-2">{t("tasks.list.column.deadline")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => (
|
||||
<tr key={row.id} className="border-b" data-row-id={row.id}>
|
||||
<td className="py-2">
|
||||
<a href={row.detailHref} className="text-theme-600">
|
||||
{row.title}
|
||||
</a>
|
||||
</td>
|
||||
<td className="py-2">{t(row.statusKey)}</td>
|
||||
<td className="py-2">{t(row.priorityKey)}</td>
|
||||
<td className="py-2">{row.assignee ? row.assignee.label : "—"}</td>
|
||||
<td className="py-2" data-overdue={row.isOverdue}>
|
||||
{row.deadlineIso ? dateFormatter.format(new Date(row.deadlineIso)) : "—"}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
return <TasksListPage vm={vm} includeDemoData={includeDemoData} nextHref={nextHref} actions={{ onApply }} />;
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
|
||||
Reference in new issue
Block a user