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
+9
-44
@@ -1,14 +1,16 @@
|
||||
// P4 Files (AK-P4a) §11 — Upload view with drag&drop + multi-file queue and
|
||||
// per-file progress (chunked init -> chunk -> complete). Loader gates on
|
||||
// files.write (404 if module off / missing). Baseline functional UI; Subframe
|
||||
// polish follows Davids D-P4 delta.
|
||||
// files.write (404 if module off / missing).
|
||||
//
|
||||
// Interim-UI (AD-28): the client chunked pipeline + queue state stay in this route;
|
||||
// the ~/ui preview screen FileUploadPage renders them (VM + items + onFiles as props).
|
||||
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { useCallback, useState } from "react";
|
||||
import { type LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { buildFileUploadVM, type FileUploadVM } from "@toolctrl/view-models";
|
||||
import { buildFileUploadVM, type FileUploadVM } from "@hivegrid/view-models";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { loadFilesContext, notFoundResponse, requireFilesPermission } from "~/utils/integrations/fileAccess.server";
|
||||
import { FileUploadPage, type FileUploadDisplayItem } from "~/components/screens/files/FileUploadPage";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
|
||||
type LoaderData = { title: string; vm: FileUploadVM; tenantSlug: string };
|
||||
@@ -25,13 +27,11 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
return Response.json({ title: `${t("files.upload.title")} | ${process.env.APP_NAME}`, vm, tenantSlug: params.tenant ?? "" } satisfies LoaderData);
|
||||
};
|
||||
|
||||
type QueueItem = { clientId: string; filename: string; sizeBytes: number; status: "queued" | "uploading" | "processing" | "done" | "error"; progressPercent: number; errorKey: string | null };
|
||||
type QueueItem = FileUploadDisplayItem;
|
||||
|
||||
export default function FilesUploadRoute() {
|
||||
const { t } = useTranslation();
|
||||
const { vm, tenantSlug } = useLoaderData<LoaderData>();
|
||||
const [items, setItems] = useState<QueueItem[]>([]);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const chunkSize = vm.status === "ready" && vm.data ? vm.data.chunkSizeBytes : 5 * 1024 * 1024;
|
||||
|
||||
const update = useCallback((clientId: string, patch: Partial<QueueItem>) => {
|
||||
@@ -96,42 +96,7 @@ export default function FilesUploadRoute() {
|
||||
[uploadOne],
|
||||
);
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <main className="mx-auto max-w-3xl px-4 py-10" data-ui-id="ui.files.upload" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-3xl px-4 py-10" data-ui-id="ui.files.upload">
|
||||
<h1 className="text-foreground text-xl font-semibold">{t("files.upload.title")}</h1>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => inputRef.current?.click()}
|
||||
onDragOver={(event) => event.preventDefault()}
|
||||
onDrop={(event) => {
|
||||
event.preventDefault();
|
||||
onFiles(event.dataTransfer.files);
|
||||
}}
|
||||
className="border-muted-foreground/40 mt-6 flex w-full flex-col items-center rounded-lg border-2 border-dashed px-6 py-12"
|
||||
data-ui-id="ui.files.upload.dropzone"
|
||||
>
|
||||
<span className="text-foreground font-medium">{t(vm.data.dropzoneHeadlineKey)}</span>
|
||||
<span className="text-muted-foreground mt-1 text-sm">{t(vm.data.dropzoneBodyKey)}</span>
|
||||
<span className="text-muted-foreground mt-3 text-xs">{t(vm.data.heicNoticeKey)}</span>
|
||||
</button>
|
||||
<input ref={inputRef} type="file" multiple className="hidden" onChange={(event) => onFiles(event.target.files)} data-ui-id="ui.files.upload.input" />
|
||||
|
||||
<ul className="mt-6 space-y-2" data-ui-id="ui.files.upload.queue">
|
||||
{items.map((item) => (
|
||||
<li key={item.clientId} className="border-b py-2 text-sm" data-row-id={item.clientId} data-status={item.status}>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>{item.filename}</span>
|
||||
<span className="text-muted-foreground">{item.status === "error" && item.errorKey ? t(item.errorKey) : `${item.progressPercent}%`}</span>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</main>
|
||||
);
|
||||
return <FileUploadPage vm={vm} items={items} actions={{ onFiles }} />;
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
|
||||
Reference in new issue
Block a user