Skip to the content

Capsid menu

app/components/history/history-panel.tsx

45 lines and 1 functions in DrDustinEdwards/carrel, at commit d5d5e82 on 2026-10-24. This file on GitHub.

Functions

The functions of history-panel.tsx
FunctionLinesComplexityCoveredCRAPMutation
HistoryPanel23 to 4960%CriticalCRAP 42No data: mutation testing has not run on this repo yet

Imports

It imports app/components/history/draft-links.tsx, app/components/history/revision-picker.tsx. Imported by app/routes/editor.tsx.

Source

// The editor's History panel (routes/editor.tsx): the newest revisions on the site, and links to compare
// the drafts kept in Carrel. The history page lists every revision.

import { Link } from "react-router";
import { Banner } from "capsomer/react/banner";
import { Panel } from "capsomer/react/panel";

import { DraftLinks, type AiDraftLink } from "./draft-links";
import { RevisionPicker, type RevisionRow } from "./revision-picker";

type Props = {
  revisions: RevisionRow[] | null;
  revisionCount: number;
  historyError: string | null;
  historyPath: string;
  /** "post", "page": what the revisions are of. */
  noun: string;
  /** Whether a draft in Carrel can be compared against the site's copy. */
  againstSite: boolean;
  aiDrafts: AiDraftLink[];
};

export function HistoryPanel({ revisions, revisionCount, historyError, historyPath, noun, againstSite, aiDrafts }: Props) {
  return (
    <Panel
      title="History"
      id="history"
      count={revisionCount}
      src="Saves and publishes on the site"
      actions={
        revisionCount > 0 ? (
          <Link className="cap-btn" data-size="sm" to={historyPath}>
            All revisions
          </Link>
        ) : undefined
      }
    >
      <div className="app-stack" data-tight>
        {historyError ? <Banner tone="warn">{historyError}</Banner> : null}
        {revisions && revisions.length > 0 ? (
          <RevisionPicker revisions={revisions} historyPath={historyPath} label="Recent revisions" />
        ) : revisions ? (
          <p className="cap-muted">The site has no saved revisions of this {noun} yet.</p>
        ) : null}
        <DraftLinks historyPath={historyPath} againstSite={againstSite} aiDrafts={aiDrafts} />
      </div>
    </Panel>
  );
}