A published global is read-only in the admin to a user whose update access allows drafts

Open Beginner friendly
#19,839 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active

Research direction

Open the global branch of the permission probe in packages/next/src/views/Document/getDocumentPermissions.tsx (on main, packages/ui/src/utilities/getDocumentPermissions.ts) and read it next to the collection branch just above, which already spreads { ...data, _status: 'draft' }. Compare that with the client refetch in providers/DocumentInfo/useGetDocPermissions.tsx, which posts the same draft status to /globals/{slug}/access. Apply the same spread in the global call, then verify with the reproduction repo that an editor sees Save Draft but not Publish changes on a published global, and run the existing access/permissions tests for globals.

Written by the indexing model from the issue text.

Description

area: ui Bug Payload OSS
Describe the Bug

An access rule that lets a user save drafts but not publish (the aim of the docs' Controlling who can publish, written as a check on the incoming data._status so a draft can be saved over a published document) works in the admin for a collection and not for a global.

On a collection, the edit view asks update access with { ...data, _status: 'draft' }, so such a user gets an editable form and a Save Draft button over a published document. On a global, the view asks update with data as stored. Once the global is published, that is _status: 'published', so the rule refuses: the form is read-only and no button is shown. The publish probe (hasPublishPermission) then asks the same question, so for a published global no access rule can tell "may save a draft" from "may publish".

The rest of Payload already treats globals like collections here:

  • the client's refetch, useGetDocPermissions (@payloadcms/ui, providers/DocumentInfo/useGetDocPermissions.tsx), posts { ...doc, _status: 'draft' } to /globals/{slug}/access. But since the server's first render shows no Save button, it never runs;
  • the global's update operation lets the same user save a draft: in the reproduction, POST /api/globals/settings?draft=true as the editor succeeds, POST /api/globals/settings/access with _status: 'draft' returns update: true, and publishing as the editor returns 403.

Where (packages/next/src/views/Document/getDocumentPermissions.tsx on 3.x; the same code in packages/ui/src/utilities/getDocumentPermissions.ts on main):

// collection branch
docPermissions = await docAccessOperation({
  id,
  collection: { config: collectionConfig },
  data: { ...data, _status: 'draft' },
  req,
})

// global branch
docPermissions = await docAccessOperationGlobal({
  data, // as stored: `_status: 'published'` once published
  globalConfig,
  req,
})

Expected: the global branch asks with { ...data, _status: 'draft' }, as the collection branch and the client's refetch do. With that one change applied to the installed @payloadcms/next 3.94.1 (dist/views/Document/getDocumentPermissions.js), the editor in the reproduction gets an editable global with Save Draft and still no Publish changes; the admin's view is unchanged.

Link to the code that reproduces this issue

https://github.com/khaleel737/payload-global-draft-access

Reproduction Steps

The reproduction is the blank template (pnpx create-payload-app@latest -t blank, SQLite) with a role on Users, a settings global with drafts and a posts collection with drafts, both using this update rule (src/access/drafts-or-admin.ts):

import type { Access } from 'payload'

const publishes = (data: unknown): boolean =>
  typeof data === 'object' && data !== null && '_status' in data && data._status === 'published'

/** Anyone signed in may save drafts; only an admin may publish. */
export const draftsOrAdmin: Access = ({ data, req: { user } }) =>
  Boolean(user) && (user?.role === 'admin' || !publishes(data))
  1. cp .env.example .env, set PAYLOAD_SECRET, pnpm install, pnpm dev.
  2. Create the first user at /admin with role admin, then a second user with role editor.
  3. As the admin, open /admin/globals/settings, type a title and click Publish changes. Create a post and click Publish changes too.
  4. Sign in as the editor and open /admin/globals/settings: the title field is read-only and there is no Save Draft button.
  5. As the editor, open the published post: the title is editable and Save Draft is there.

Checked in headless Chromium against the reproduction:

User View Title field Buttons
editor published global read-only none
editor published post editable Save Draft
admin published global editable Save Draft, Publish changes
admin published post editable Save Draft, Publish changes
Which area(s) are affected?

area: ui

Environment Info
Binaries:
  Node: 26.13.1
  npm: 11.19.1
  pnpm: 12.16.1
Relevant Packages:
  payload: 3.94.1
  next: 16.4.6
  @payloadcms/db-sqlite: 3.94.1
  @payloadcms/drizzle: 3.94.1
  @payloadcms/graphql: 3.94.1
  @payloadcms/next/utilities: 3.94.1
  @payloadcms/richtext-lexical: 3.94.1
  @payloadcms/translations: 3.94.1
  @payloadcms/ui/shared: 3.94.1
  react: 19.2.9
  react-dom: 19.2.9
Operating System:
  Platform: darwin
  Arch: x64

The global branch reads the same on 3.x and main today.

Dominant language
TypeScript
Stars
45.8k
Forks
4.4k
Avg merge
3d 4h
Merged PRs (30d)
210

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from payloadcms/payload

All issues in payloadcms/payload

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.