app/components/admin/media-trash-controls.tsx
52 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| MediaTrashControls | 8 to 56 | 7 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports app/components/admin/confirm-dialog.tsx, app/lib/media/view.mjs. Imported by app/routes/admin.media._index.tsx.
Source
import { Link } from "react-router";
import { Banner } from "capsomer/react/banner";
import { ConfirmDialog } from "~/components/admin/confirm-dialog";
import type { hrefWith, sortHref } from "~/lib/media/view.mjs";
/** The trash view's note, its Empty trash link and the typed confirmation that link opens. */
export function MediaTrashControls({
view,
trashedCount,
linkTo,
}: {
view: Parameters<typeof sortHref>[0];
trashedCount: number;
linkTo: (over?: Parameters<typeof hrefWith>[1]) => string;
}) {
return (
<>
{view.trash ? (
<Banner tone="info">
This is a library view, not a takedown. A trashed file keeps its address, and any published
page using it is unchanged. Restore puts it back in the library.{" "}
<strong>Only Empty trash deletes anything, and it still refuses anything a post cites.</strong>
</Banner>
) : null}
{view.trash && trashedCount > 0 ? (
<div className="app-actions">
{/* A link, not `prompt()`, so the confirmation holds without script. */}
<Link to={linkTo({ confirm: "empty-trash" })} className="cap-btn" data-variant="danger">
Empty trash
</Link>
<span className="cap-muted">Deletes the objects. Anything a post cites is kept and named.</span>
</div>
) : null}
{view.confirm === "empty-trash" && trashedCount > 0 ? (
<ConfirmDialog
title={`Permanently delete ${trashedCount} file${trashedCount === 1 ? "" : "s"}`}
body={
<p>
Addresses are content hashes, so a deleted file cannot be restored
by re-uploading it under the same URL. Anything a post cites is
kept and named.
</p>
}
requireTyped={String(trashedCount)}
confirmLabel="Delete permanently"
cancelHref={linkTo({ confirm: "" })}
>
<input type="hidden" name="intent" value="empty-trash" />
</ConfirmDialog>
) : null}
</>
);
}