Blocks / Publish bar

Publish bar

Draft or published, the active switch, Publish; the dialog that lists changes and checks.

import { PublishBar, PublishDialog, ChangeList } from "@forgeron/ui";
/01 → States
Never published
v4 published
Draft · 2 changes
import { PublishBar } from "@forgeron/ui";

export default function States() {
  return (
    <div style={{ display: "grid", gap: 12 }}>
      <PublishBar changes={3} onPublish={() => {}} />
      <PublishBar version={4} changes={0} active onActiveChange={() => {}} onPublish={() => {}} />
      <PublishBar version={4} changes={2} active onActiveChange={() => {}} onPublish={() => {}} />
    </div>
  );
}
/02 → Publish with checks
Draft · 3 changes
import { PublishBar, PublishDialog, type VersionChange } from "@forgeron/ui";
import { useState } from "react";

const changes: VersionChange[] = [
  { kind: "add", text: "Step “Mail the CFO”" },
  { kind: "change", text: "Above €5,000?: compare to" },
  { kind: "remove", text: "Step “Log the deal”" },
];

export default function PublishWithChecks() {
  const [open, setOpen] = useState(false);
  const [version, setVersion] = useState(4);
  const [pending, setPending] = useState(changes.length);
  const [active, setActive] = useState(true);
  return (
    <div>
      <PublishBar
        version={version}
        changes={pending}
        active={active}
        onActiveChange={setActive}
        onPublish={() => setOpen(true)}
      />
      {open ? (
        <PublishDialog
          version={version + 1}
          changes={changes}
          active={active}
          checks={[
            {
              level: "warning",
              text: "Thank the client: credential mail-backup has no value in the vault.",
            },
          ]}
          note="Steps run the code of the deployed flows build, 0.2.0+3c9e1f4. A published version cannot change; restore it later as a draft."
          onClose={() => setOpen(false)}
          onPublish={() => {
            setVersion(version + 1);
            setPending(0);
            setOpen(false);
          }}
        />
      ) : null}
    </div>
  );
}
API → Props
PropTypeDefaultDescription
versionnumber—The last published; none: never published.
changesnumber—Changes in the draft since.
active / onActiveChangeboolean—Listens to its trigger.
onPublish() => void—Opens the PublishDialog.
PublishDialog{ version, changes, checks?, active?, onPublish(message), onClose, note? }—A blocking check keeps Publish off.
classNamestring—Extra classes.