Skip to content

feat(cms): draft mode, versioning and CI improvements#419

Merged
hakalb merged 4 commits intomainfrom
cod-293-support-draft-mode-and-versioning
Apr 19, 2026
Merged

feat(cms): draft mode, versioning and CI improvements#419
hakalb merged 4 commits intomainfrom
cod-293-support-draft-mode-and-versioning

Conversation

@hakalb
Copy link
Copy Markdown
Member

@hakalb hakalb commented Apr 18, 2026

Summary

  • Drafts & versioning — enables versions.drafts with autosave (3 s interval) on pages and posts collections; adds _status field and DB migration for _pages_v/_posts_v tables
  • Preview route — new /api/preview and /api/preview/exit Next.js route handlers enable/disable draft mode after verifying a Payload admin user session; site pages pass draft: true to data-access functions when draft mode is active
  • Access controluserOrApiKeyAccess extended with hasStatus flag to restrict API key clients to published/null-status documents while leaving admin users unrestricted
  • Local media storage — removes S3 in development; replaces 5 oversized PNG seed images (~15 MB) with 3 small JPEGs (~19 KB); drops the unused prefix column from the media table via migration
  • CIpaths-ignore on PR trigger skips CI for docs/media-only changes; merge queue skips E2E, integration and smoke tests (already verified in PR); fixes ephemeral run_id cache key in e2e-matrix

Test plan

  • nx dev-fresh cms — verify migrations apply cleanly and seed completes
  • Create a page, save as draft — confirm it returns 404 on the site
  • Open live preview from admin — confirm draft content renders
  • Publish the page — confirm it becomes publicly visible without preview cookie
  • Verify media uploads go to apps/cms/public/media/ locally (no S3 credentials needed)
  • E2E: nx e2e cms-e2e — new tests in api/preview.spec.ts, admin/drafts.admin.spec.ts, site/draft-mode.spec.ts pass
  • Open a docs-only PR and confirm CI is skipped
  • Merge a PR via merge queue and confirm E2E/integration steps are skipped

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 18, 2026 18:27
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Comment thread libs/app-cms/data-access/src/lib/collections/get-page.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables draft mode + versioning for Payload pages/posts, adds Next.js preview route handlers to toggle draft mode after validating an authenticated admin session, and includes related access-control, media-storage, seeding, migrations, E2E tests, and CI improvements.

Changes:

  • Add _status + Payload drafts/versioning (autosave) for pages/posts, including migrations and seed updates.
  • Introduce /api/preview and /api/preview/exit, and pass draft: true through site data-access when draft mode is enabled.
  • Improve local dev media handling (no S3 required) and optimize CI behavior (paths-ignore + better cache keys), plus add E2E coverage for preview/drafts.

Reviewed changes

Copilot reviewed 31 out of 41 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
libs/shared/util/seed/src/lib/static-data/read-media-files.ts Switch expected remote seed images from PNG to JPG.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-1.jpg Add smaller seed image asset.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-2.jpg Add smaller seed image asset.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-3.jpg Add smaller seed image asset.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-1.png Remove/replace oversized seed image.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-2.png Remove/replace oversized seed image.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-3.png Remove/replace oversized seed image.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-4.png Remove/replace oversized seed image.
libs/shared/util/seed/src/lib/static-data/media/abstract-image-5.png Remove/replace oversized seed image.
libs/shared/util/payload-types/src/lib/payload-types.ts Add _status to Page/Post types; remove prefix from Media types/selectors.
libs/shared/util/payload-api/src/lib/utils/resolve-navigation-tree.ts Avoid crashing when navigation references are missing (deleted docs).
libs/app-cms/util/plugins/src/lib/plugins/get-s3-storage-plugin.ts Don’t disable local storage unless S3 is configured; remove prefix usage.
libs/app-cms/feature/seed/src/lib/local-api/ensure-post.ts Seed posts as published.
libs/app-cms/feature/seed/src/lib/local-api/ensure-page.ts Seed pages as published.
libs/app-cms/data-access/src/lib/get-authenticated-payload.ts Update doc comment to reflect session auth behavior.
libs/app-cms/data-access/src/lib/collections/types.ts Add draft?: boolean to query options.
libs/app-cms/data-access/src/lib/collections/get-posts.ts Forward draft option to Payload find for posts.
libs/app-cms/data-access/src/lib/collections/get-post.ts Support draft fetching and bypass status filter in preview context.
libs/app-cms/data-access/src/lib/collections/get-page.ts Support draft fetching and bypass status filter in preview context.
apps/cms/src/security/user-or-api-key-access.ts Add hasStatus flag to restrict API key reads to published/null-status docs.
apps/cms/src/payload.config.ts Route live preview through /api/preview to enable draft mode before redirect.
apps/cms/src/migrations/index.ts Register new migrations for drafts/versioning and dropping media prefix.
apps/cms/src/migrations/20260416_053006_cod_293.ts Create drafts/versioning tables/types; add _status for pages/posts.
apps/cms/src/migrations/20260418_101207_cod_293_drop_media_prefix.ts Drop unused media.prefix column (and restore on down).
apps/cms/src/components/NavigationArrayRowLabel.tsx Guard against missing navigation references when rendering row labels.
apps/cms/src/collections/posts/posts.collection.ts Add _status column in admin list, enable drafts/autosave, tighten API key access.
apps/cms/src/collections/pages/pages.collection.ts Add _status column in admin list, enable drafts/autosave, tighten API key access.
apps/cms/src/app/api/preview/route.ts New route to validate session and enable Next.js draft mode.
apps/cms/src/app/api/preview/exit/route.ts New route to disable Next.js draft mode.
apps/cms/src/app/(site)/posts/[...slug]/page.tsx Pass draft-mode state into getPost.
apps/cms/src/app/(site)/page.tsx Pass draft-mode state into getPage for landing page.
apps/cms/src/app/(site)/[...slug]/page.tsx Pass draft-mode state into getPageData.
apps/cms/.env.local Remove hardcoded dev S3 credentials; document optional S3 usage.
apps/cms-e2e/src/site/draft-mode.spec.ts New E2E coverage for draft visibility + preview + publish flow.
apps/cms-e2e/src/api/preview.spec.ts New E2E coverage for preview enable/exit behaviors.
apps/cms-e2e/src/admin/pages.admin.spec.ts Update admin UI test to match new publish button label.
apps/cms-e2e/src/admin/drafts.admin.spec.ts New E2E coverage for status column visibility.
.github/workflows/e2e-matrix.yml Fix cache key to use lockfile hash instead of run_id.
.github/workflows/ci.yml Skip CI for docs/media-only PRs; skip E2E/integration/smoke in merge queue.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/cms/src/app/api/preview/route.ts Outdated
Comment thread apps/cms/src/app/api/preview/exit/route.ts Outdated
Comment thread libs/app-cms/data-access/src/lib/collections/get-posts.ts Outdated
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 18, 2026

View your CI Pipeline Execution ↗ for commit 1b8b66f

Command Status Duration Result
nx affected -t e2e --exclude *,!tag:scope:nx-pa... ✅ Succeeded 7m 20s View ↗
nx affected -t integration-test -c ci ✅ Succeeded <1s View ↗
nx affected -t e2e -c ci --exclude nx-payload-e2e ✅ Succeeded 7m 42s View ↗
nx affected -t lint,test,build -c ci ✅ Succeeded 4m 30s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 9s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-19 18:56:57 UTC

@codeware-actions
Copy link
Copy Markdown

✨ Your pull request projects are ready for preview

Project App name Preview
cms (demo) cdwr-cms-pr-419-demo https://cdwr-cms-pr-419-demo.fly.dev
web (demo) cdwr-web-pr-419-demo https://cdwr-web-pr-419-demo.fly.dev

@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.19%. Comparing base (a0b1751) to head (1b8b66f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #419   +/-   ##
=======================================
  Coverage   64.19%   64.19%           
=======================================
  Files         207      207           
  Lines        5348     5348           
  Branches      735      735           
=======================================
  Hits         3433     3433           
  Misses       1865     1865           
  Partials       50       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codeware-actions
Copy link
Copy Markdown

✨ Your pull request projects are ready for preview

Project App name Preview
cms (_default) cdwr-cms-pr-419 https://cdwr-cms-pr-419.fly.dev
cms (demo) cdwr-cms-pr-419-demo https://cdwr-cms-pr-419-demo.fly.dev
web (demo) cdwr-web-pr-419-demo https://cdwr-web-pr-419-demo.fly.dev

@hakalb hakalb added the preview-deploy PR Trigger: run continuous preview deployments label Apr 19, 2026
@codeware-actions
Copy link
Copy Markdown

✨ Your pull request projects are ready for preview

Project App name Preview
cms (_default) cdwr-cms-pr-419 https://cdwr-cms-pr-419.fly.dev
cms (demo) cdwr-cms-pr-419-demo https://cdwr-cms-pr-419-demo.fly.dev
web (demo) cdwr-web-pr-419-demo https://cdwr-web-pr-419-demo.fly.dev

@hakalb hakalb enabled auto-merge April 19, 2026 19:26
@hakalb hakalb added this pull request to the merge queue Apr 19, 2026
Merged via the queue into main with commit a13f0f1 Apr 19, 2026
16 checks passed
@hakalb hakalb deleted the cod-293-support-draft-mode-and-versioning branch April 19, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-deploy PR Trigger: run continuous preview deployments

Development

Successfully merging this pull request may close these issues.

2 participants