Skip to Content

RevisionHistory

Display caller-provided CMS revision snapshots and forward host-owned actions.

RevisionHistory displays caller-provided revisions, offers a JSON field snapshot preview and a field-by-field comparison with the current revision, and invokes onRestore with the selected revision ID and revision number. The component does not restore history; use the verified CMS/Fullstack lifecycle contract for any restore action.

390 × 844

API

PropTypeRequiredDefault
revisionsreadonly CmsRevisionItem[]Yes—
currentRevisionNumbernumberNo—
loadingbooleanNofalse
errorReactNodeNo—
confirmRestorebooleanNofalse
onRestore(revisionId, revisionNumber) => void | Promise<void>NoRead only
classNamestringNo—
import { createCmsClient } from "@puzzle-ui/fullstack/cms/client";
import { RevisionHistory } from "@puzzle-ui/pieces";

const cms = createCmsClient({ basePath: "/api/cms" });
const articles = cms.collection("articles");
const revisions = await articles.listRevisions(entry.id, 20);

const restoreRevision = async (revisionId: string) => {
  await articles.restoreRevision(entry.id, {
    expectedRevision: entry.revision,
    revisionId,
  });
};

<RevisionHistory
  revisions={revisions}
  currentRevisionNumber={entry.revisionNumber}
  onRestore={(revisionId) => restoreRevision(revisionId)}
/>;

The Fullstack collection client exposes listRevisions and restoreRevision when the collection enables drafts. listRevisions returns an array of flat CmsApiRevision records whose public fields map to CmsRevisionItem; no tenant ID is sent to the browser. The comparison is shown when the revision identified by currentRevisionNumber is included in revisions; provide it alongside any historical page you want to compare. It shows added, removed, and changed top-level fields, including nested values, but does not compare metadata such as status or slug. Set confirmRestore to ask before invoking the callback. The active revision cannot be restored. Callback failures are announced to the user.

API maturity

API maturity: Stable.