@pramen/cms-editor 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pramen/cms-editor",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "Visual block/page editor for @pramen/cms — a standalone React SPA that talks to the CMS handlers over HTTP.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -379,6 +379,26 @@ function Workflow({ api, page, onChanged, onError }: { api: Api; page: Page; onC
379
379
  onError(errMsg(e));
380
380
  }
381
381
  };
382
+ // Show only the transitions valid FROM the current status, so a draft never surfaces a
383
+ // primary "Approve" that the server rejects (approve requires status === "review"). The
384
+ // server still enforces role gates; this just stops the UI from offering dead-end actions.
385
+ // `publish` = publishPage (any → published, reviewer/admin) — the one-click path for a solo
386
+ // operator; `approve` is the reviewer step of the two-actor review pipeline.
387
+ const status = String(page.status);
388
+ const buttons: Array<{ label: string; action: string; variant?: "secondary" | "ghost" }> =
389
+ status === "review"
390
+ ? [
391
+ { label: "Approve (publish)", action: "approve" },
392
+ { label: "Reject", action: "reject", variant: "secondary" },
393
+ { label: "Publish directly", action: "publishPage", variant: "secondary" },
394
+ ]
395
+ : status === "published"
396
+ ? [{ label: "Unpublish", action: "unpublishPage", variant: "secondary" }]
397
+ : // draft | rejected | archived
398
+ [
399
+ { label: "Publish", action: "publishPage" },
400
+ { label: "Submit for review", action: "submitForReview", variant: "secondary" },
401
+ ];
382
402
  return (
383
403
  <div>
384
404
  <Section>Workflow</Section>
@@ -387,13 +407,11 @@ function Workflow({ api, page, onChanged, onError }: { api: Api; page: Page; onC
387
407
  <Pill status={page.status}>{page.status}</Pill>
388
408
  </div>
389
409
  <div className="flex flex-col gap-2">
390
- <Button variant="secondary" onPress={() => act("submitForReview")}>Submit for review</Button>
391
- <Button onPress={() => act("approve")}>Approve (publish)</Button>
392
- <Button variant="secondary" onPress={() => act("reject")}>Reject</Button>
393
- <Button variant="secondary" onPress={() => act("publishPage")}>Publish directly</Button>
394
- <Button variant="ghost" onPress={() => act("unpublishPage")}>Unpublish</Button>
410
+ {buttons.map((b) => (
411
+ <Button key={b.action} variant={b.variant} onPress={() => act(b.action)}>{b.label}</Button>
412
+ ))}
395
413
  </div>
396
- <p className="mt-2.5 text-fg-subtle">Submit is editor-gated; approve/publish are reviewer-gated.</p>
414
+ <p className="mt-2.5 text-fg-subtle">Publish needs a reviewer/admin role; submit-for-review is editor-gated.</p>
397
415
  </div>
398
416
  );
399
417
  }