shefing

changes button

by shefing
payload-tools
Publishing workflow
v3
>=3.84.0
Apache-2.0

Overview

Summary generated from the README

Adds a Changes button to drafts-enabled collections and globals. Clicking it opens a drawer showing a field-by-field diff against the published version, using the same diff UI as the Versions view. It is registered in the plugins array and needs a small change to the Payload layout file to register a server function. It requires Payload 3.84 or later.

Features

  • Auto-injects into every drafts-enabled collection and global
  • Shows only when there are unpublished changes and the user has publish permission
  • Toggle between unsaved form values and the latest saved draft
  • Diff against an empty baseline for new documents
  • Options to exclude collections or globals, or disable the plugin
  • Built-in labels for English, Arabic, Spanish, French, Hebrew and Chinese

Use cases

  • Review unpublished edits before publishing a draft document
  • Let editors compare unsaved form values with the published version
  • Audit what changed in a global before pushing it live

Installation

npm i @shefing/changes-button

183

Stars

8

Forks

89

Open Issues

3 months ago

Last Updated

43

Weekly Downloads

v0.1.3

npm Version

394.8 KB

Unpacked Size

1

Dependencies

Repository stars

183+4 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 2026183
Dec 5, 2026183
Dec 4, 2026183
Dec 3, 2026183
Dec 2, 2026183
Dec 1, 2026183
Nov 30, 2026183
Nov 29, 2026183
Nov 28, 2026183
Nov 27, 2026183
Nov 26, 2026183
Nov 25, 2026182
Nov 24, 2026182
Nov 23, 2026182
Nov 22, 2026182
Nov 21, 2026182
Nov 20, 2026182
Nov 19, 2026182
Nov 18, 2026182
Nov 17, 2026182
Nov 16, 2026183
Nov 15, 2026183
Nov 14, 2026183
Nov 13, 2026183
Nov 12, 2026183
Nov 11, 2026183
Nov 10, 2026183
Nov 9, 2026182
Nov 8, 2026182
Nov 7, 2026182
Nov 6, 2026182
Nov 5, 2026182
Nov 4, 2026182
Nov 3, 2026181
Nov 2, 2026181
Nov 1, 2026181
Oct 31, 2026181
Oct 30, 2026181
Oct 29, 2026181
Oct 28, 2026181
Oct 27, 2026181
Oct 26, 2026181
Oct 25, 2026181
Oct 24, 2026181
Oct 23, 2026181
Oct 22, 2026181
Oct 21, 2026180
Oct 20, 2026180
Oct 19, 2026180
Oct 18, 2026180
Oct 17, 2026180
Oct 16, 2026180
Oct 15, 2026180
Oct 14, 2026180
Oct 13, 2026180
Oct 12, 2026180
Oct 11, 2026180
Oct 10, 2026180
Oct 9, 2026180
Oct 8, 2026180
Oct 7, 2026180
Oct 6, 2026180
Oct 5, 2026180
Oct 4, 2026180
Oct 3, 2026180
Oct 2, 2026180
Oct 1, 2026180
Sep 30, 2026180
Sep 29, 2026180
Sep 28, 2026180
Sep 27, 2026180
Sep 26, 2026180
Sep 25, 2026180
Sep 24, 2026179
Sep 23, 2026179
Sep 22, 2026179
Sep 21, 2026179
Sep 20, 2026179
Sep 19, 2026179
Sep 18, 2026179
Sep 17, 2026179
Sep 16, 2026179
Sep 15, 2026179
Sep 14, 2026179
Sep 13, 2026179
Sep 12, 2026179
Sep 11, 2026179
Sep 10, 2026179
Sep 9, 2026179
Sep 8, 2026179
Sep 7, 2026179

Shared by 4 plugins in shefing/payload-tools.

npm weekly downloads

43+31 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202643
Dec 5, 202627
Dec 4, 202635
Dec 3, 202631
Dec 2, 202624
Dec 1, 202628
Nov 30, 202626
Nov 29, 202627
Nov 28, 202634
Nov 27, 202681
Nov 26, 2026175
Nov 25, 2026180
Nov 24, 2026178
Nov 23, 2026176
Nov 22, 2026182
Nov 21, 2026177
Nov 20, 2026128
Nov 19, 202638
Nov 18, 202630
Nov 17, 202628
Nov 16, 202628
Nov 15, 202626
Nov 14, 202623
Nov 13, 202619
Nov 12, 202633
Nov 11, 2026123
Nov 10, 2026126
Nov 9, 2026129
Nov 8, 2026128
Nov 7, 2026133
Nov 6, 2026145
Nov 5, 2026166
Nov 4, 202673
Nov 3, 202670
Nov 2, 202668
Nov 1, 202664
Oct 31, 202659
Oct 30, 202644
Oct 29, 20265
Oct 28, 20264
Oct 27, 20267
Oct 26, 20267
Oct 25, 20269
Oct 24, 202616
Oct 23, 202616
Oct 22, 202620
Oct 21, 202629
Oct 20, 202640
Oct 19, 202639
Oct 18, 202646
Oct 17, 202638
Oct 16, 202643
Oct 15, 202661
Oct 14, 202654
Oct 13, 202640
Oct 12, 202640
Oct 11, 202633
Oct 10, 202636
Oct 9, 202635
Oct 8, 202621
Oct 7, 202627
Oct 6, 202639
Oct 5, 202649
Oct 4, 202650
Oct 3, 202661
Oct 2, 202668
Oct 1, 202664
Sep 30, 202662
Sep 29, 202651
Sep 28, 202641
Sep 27, 202637
Sep 26, 202625
Sep 25, 202617
Sep 24, 202616
Sep 23, 202615
Sep 22, 202614
Sep 21, 202617
Sep 20, 202617
Sep 19, 202614
Sep 18, 202612
Sep 17, 20269
Sep 16, 20265
Sep 15, 20266
Sep 14, 20263
Sep 13, 20265
Sep 12, 20267
Sep 11, 20266
Sep 10, 20268
Sep 9, 20268
Sep 8, 202611
Sep 7, 202612

Each point is npm's rolling 7-day download count.

Health Score

49/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/888484677-changes-button.svg)](https://payloaddirectory.dev/plugins/888484677-changes-button)
HTML
<a href="https://payloaddirectory.dev/plugins/888484677-changes-button"><img src="https://payloaddirectory.dev/badge/888484677-changes-button.svg" alt="Payload Directory"></a>
Updated Aug 18, 2026Created Nov 14, 2024Published May 7, 2026

README

@shefing/changes-button

A Payload CMS plugin that adds a Changes button to drafts-enabled documents. Clicking it opens a slide-in drawer that shows a field-by-field diff between the current document state (or the latest draft) and the currently published version — using the same diff UI as the built-in Versions view.

Features

  • Auto-injects into every drafts-enabled collection / global (no manual component wiring).
  • Visibility is fully driven by document state: the button only shows when there are unpublished changes AND the user has publish permission.
  • Toggle inside the drawer to switch between Unsaved (live form values) and Latest draft (saved draft) when both exist.
  • Self-contained — the diff renderer is vendored from Payload's Versions view, so the plugin works against any payload / @payloadcms/next release without waiting for new exports to land upstream.
  • All UI strings live in src/labels.ts (en/ar/es/fr/he/zh) and are picked up via useTranslation().i18n.language.

Status

Two upstream Payload PRs would let the plugin install with a single line and zero layout edits, but they have not been merged yet:

FeatureIssuePR
@payloadcms/next/views/diff subpath export#16496#16498
config.admin.serverFunctions registry#16497#16499

Until they ship, this package vendors the diff pipeline from @payloadcms/next/src/views/Version/RenderFieldsToDiff/ (see src/vendor/diff/) and requires a small (payload)/layout.tsx change to register the server function. Once both PRs land, the vendor copy can be deleted and the layout edit removed.

Install

pnpm add @shefing/changes-button

Usage

1. Register the plugin in payload.config.ts

import { buildConfig } from 'payload'
import { changesButtonPlugin } from '@shefing/changes-button'

export default buildConfig({
  // ...
  plugins: [
    changesButtonPlugin({
      // optional — exclude collections / globals from receiving the button
      excludedCollections: ['users'],
      excludedGlobals: [],
    }),
  ],
})

2. Wrap handleServerFunctions in app/(payload)/layout.tsx

The plugin needs a server function (shefing/changes-button:render-diff) registered alongside Payload's built-in ones. Until upstream PR #16499 lands, this is done by wrapping the serverFunction you pass to <RootLayout />:

// app/(payload)/layout.tsx
import type { ServerFunctionClient } from 'payload'
import { handleServerFunctions, RootLayout } from '@payloadcms/next/layouts'
import { wrapServerFunctions } from '@shefing/changes-button/server'
import config from '@payload-config'
import { importMap } from './admin/importMap.js'

const baseServerFunction: ServerFunctionClient = async function (args) {
  'use server'
  return handleServerFunctions({ ...args, config, importMap })
}

const serverFunction = wrapServerFunctions(baseServerFunction)

export default async function Layout({ children }: { children: React.ReactNode }) {
  return (
    <RootLayout config={config} importMap={importMap} serverFunction={serverFunction}>
      {children}
    </RootLayout>
  )
}

wrapServerFunctions intercepts only the shefing/changes-button:render-diff key and forwards every other call to the base handler unchanged.

Configuration

OptionTypeDefaultDescription
excludedCollectionsstring[][]Slugs of collections that should NOT receive the Changes button.
excludedGlobalsstring[][]Slugs of globals that should NOT receive the Changes button.
disabledbooleanfalseDisable the plugin entirely without removing it from plugins.

When the button appears

The button is rendered only when all of the following are true for the open document:

  • The entity has drafts enabled (versions.drafts is configured).
  • The current user has publish permission.
  • The document is not in trash.
  • There are unpublished changes — either the form is modified or unpublishedVersionCount > 0.

For brand-new entities (no published baseline) the diff renders against an empty baseline so every populated field shows as an addition.

Localization

All user-facing strings are declared in src/labels.ts and consumed via the getLabel(key, locale) helper. The active locale is read from useTranslation().i18n.language so the button automatically follows the admin UI language.

Built-in locales: en, ar, es, fr, he, zh. Missing keys/locales fall back to English.

Manual server-function wiring (advanced)

If you don't want to use wrapServerFunctions, register the handler explicitly in your serverFunctions map:

import { renderChangesDiffHandler, SERVER_FUNCTION_KEY } from '@shefing/changes-button/server'

const serverFunction: ServerFunctionClient = async function (args) {
  'use server'
  return handleServerFunctions({
    ...args,
    config,
    importMap,
    serverFunctions: { [SERVER_FUNCTION_KEY]: renderChangesDiffHandler },
  })
}

Local development

The vendored diff pipeline lives in src/vendor/diff/ — a snapshot of @payloadcms/next/src/views/Version/RenderFieldsToDiff/ (minus *.spec.ts). When upstream PR #16498 ships in a release:

  1. Replace the vendor imports in src/server/renderChangesDiff.tsx with import { countChangedFields, RenderDiff } from '@payloadcms/next/views/diff'.
  2. Delete src/vendor/diff/ and the copied SelectedLocalesContext.tsx.
  3. Bump the @payloadcms/next peerDependency to the release that exposes the subpath.

When PR #16499 ships, additionally:

  1. Re-add config.admin.serverFunctions self-registration in ChangesButtonPlugin.ts (see git history).
  2. Drop the wrapServerFunctions step from this README — the plugin will be a single-line install again.

Roadmap

See the consolidated ROADMAP.md at the repo root and the live RoadMap issues for Changes Button.

P0 — user-requested

  • AI-generated change summary at the top of the drawer:
    • Pluggable summarize adapter (openai, anthropic, custom). The plugin sends the structured diff + collection field metadata; receives a markdown summary + bullet list of risky changes.
    • Server-side via a new Payload endpoint registered by the plugin, so API keys stay on the server.
    • Cached per (docId, fromVersion, toVersion).
    • Per-collection toggle via admin.custom.changesButton.aiSummary.

P1

  • Inline approval workflow — "Request review" button creating a change-request record (or hooking into authorization roles).
  • Comment-on-diff — reuse the comments plugin's Lexical mark on changed fields.
  • Filter the diff (only changed / added / removed; by tab/group).
  • Copy summary / export diff as Markdown or PDF.

P2

  • Once upstream Payload PRs #16498 / #16499 land, drop src/vendor/diff and the (payload)/layout.tsx edit.
  • Granular i18n for AI summaries (locale passed to adapter).

License

MIT — © shefing

Similar plugins