Skip to the content

Capsid menu

app/components/admin/media-upload-actions.tsx

59 lines and 2 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of media-upload-actions.tsx
FunctionLinesComplexityCoveredCRAPMutation
MediaUploadForm9 to 451No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
MediaMaintenance48 to 631No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports app/components/admin/media-drop-anywhere.tsx, app/components/admin/overflow-menu.tsx, app/lib/media/upload-contract.mjs. Imported by app/routes/admin.media._index.tsx.

Source

import { useRef } from "react";
import { Form } from "react-router";

import { DropAnywhere } from "~/components/admin/media-drop-anywhere";
import { OverflowMenu } from "~/components/admin/overflow-menu";
import { ACCEPT_ATTRIBUTE, UPLOAD_FORM_INTENT } from "~/lib/media/upload-contract.mjs";

/** The upload form: one file, loaded by browsing or by dropping anywhere on the page. */
export function MediaUploadForm() {
  const fileRef = useRef<HTMLInputElement>(null);

  return (
      <>
      {/* The hidden `intent` alone selects the upload redirect branch. Images only. */}
      <Form
        method="post"
        action="/admin/media/upload"
        encType="multipart/form-data"
        className="app-actions"
      >
        <label className="cap-field-label" htmlFor="media-file">
          Drop files anywhere, or browse
        </label>
        <input
          ref={fileRef}
          id="media-file"
          className="cap-input"
          type="file"
          name="file"
          accept={ACCEPT_ATTRIBUTE}
        />
        <button
          type="submit"
          name="intent"
          value={UPLOAD_FORM_INTENT}
          className="cap-btn"
          data-variant="primary"
        >
          Upload
        </button>
        <DropAnywhere inputRef={fileRef} />
      </Form>
      </>
  );
}

/** The maintenance menu, in the page head. */
export function MediaMaintenance() {
  return (
    <>
      <OverflowMenu label="Maintenance">
        <Form method="post">
          <button type="submit" name="intent" value="rebuild" className="cap-option" data-menu-item>
            <span className="cap-option-label">Rebuild media index</span>
            <span className="cap-option-hint">
              Re-derive every row from R2 and the repo, preserving alt and captions
            </span>
          </button>
        </Form>
      </OverflowMenu>
    </>
  );
}