// Upload dialog of the files browser. Same chrome as the project quick-action // upload (shared QuickActionDialog + the same dashed dropzone), so uploading a // file looks the same wherever it is started. Unlike the project dialog it takes // several files at once and shows the chunked pipeline's progress per file, // which is what the standalone upload view offered before. // // Deliberate delta from the project dialog: no category/description fields. // Those describe a file's role *on a project* and have nowhere to go on a file // that is uploaded into the tenant's library. // // Pure/presentational: the queue and the upload pipeline live in the route and // arrive as props. No useLoaderData/useFetcher, no server imports. import { useRef } from "react"; import { useTranslation } from "react-i18next"; import { FeatherUpload, FeatherUploadCloud } from "@subframe/core"; import type { FileUploadDisplayItem } from "./FileUploadPage"; import { QuickActionDialog } from "../shared/QuickActionDialog"; import { Button } from "~/ui/components/Button"; import { Progress } from "~/ui/components/Progress"; export type FileUploadDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; /** Queue of the current dialog session, newest selection last. */ items: readonly FileUploadDisplayItem[]; /** Hand the picked/dropped files to the route's chunked upload pipeline. */ onFiles: (files: FileList | null) => void; /** True while at least one file is still on its way. */ uploading: boolean; }; function progressState(status: FileUploadDisplayItem["status"]): "uploading" | "success" | "error" { if (status === "done") return "success"; if (status === "error") return "error"; return "uploading"; } export function FileUploadDialog(props: FileUploadDialogProps) { const { t } = useTranslation(); const inputRef = useRef(null); function statusText(item: FileUploadDisplayItem): string { if (item.status === "error") return t(item.errorKey ?? "files.error.uploadIncomplete"); if (item.status === "done") return t("files.upload.status.done"); if (item.status === "processing") return t("files.upload.status.processing"); if (item.status === "queued") return t("files.upload.status.queued"); return `${item.progressPercent}%`; } return ( } iconVariant="neutral" title={t("files.upload.title")} subtitle={t("files.upload.dialogSubtitle")} submitLabel={t("files.upload.actions.done")} submitIcon={} submitting={props.uploading} // Closing is the only way out while nothing has been picked yet; the // primary button confirms that the finished uploads are accepted. submitDisabled={props.items.length === 0} onSubmit={() => props.onOpenChange(false)} uiId="ui.files.browser.uploadDialog" >
{ props.onFiles(event.target.files); // The same file twice in a row must fire again. event.target.value = ""; }} data-ui-id="ui.files.browser.uploadDialog.input" />
event.preventDefault()} onDrop={(event) => { event.preventDefault(); props.onFiles(event.dataTransfer.files); }} className="flex w-full flex-col items-center justify-center gap-5 rounded-lg border border-dashed border-border-strong bg-surface-neutral-primary px-6 py-8" data-ui-id="ui.files.browser.uploadDialog.dropzone" > {t("files.upload.dropzone.headline")}
{props.items.length > 0 ? (
    {props.items.map((item) => (
  • {item.filename} {statusText(item)}
  • ))}
) : null}
); } export default FileUploadDialog;