Skip to content

Added archived custom fields management to Settings - #29417

Merged
rob-ghost merged 6 commits into
mainfrom
feat/custom-fields-archived
Jul 17, 2026
Merged

rob-ghost merged 6 commits into
mainfrom
feat/custom-fields-archived

Conversation

@renatoworks

Copy link
Copy Markdown
Contributor

Describe the problem you are solving

Archiving a custom field used to be a dead end: archived fields disappeared from Settings entirely, and since field names are globally unique, an archived field silently blocked its name with no way to reach it. This PR makes archived fields visible and manageable — and adds a way to permanently remove one.

  • The Custom fields group now splits into Active and Archived tabs (the newsletters pattern). Archived fields can be found, renamed, and reactivated.
  • Archiving and reactivating are status edits over the existing PUT, both behind confirmation dialogs that spell out what changes (and that collected values are preserved).
  • Permanent deletion follows the API's own two-step: only an archived field can be deleted, and the UI keeps the same distance — a … menu on the archived field's edit modal reveals "Delete custom field", which opens a heavy confirmation (the field and every collected value are permanently deleted from the database).

Ref https://linear.app/ghost/issue/BER-3802/view-and-manage-archived-custom-fields-in-settings

Changelog for devs

  • Added Active/Archived tabs to Settings → Membership → Custom fields; Settings opts into archived fields via filter=status:[active,archived] (browse hides them by default, so other consumers like member details are untouched)
  • Added archive/reactivate confirmation flows as status edits over the existing PUT
  • Added permanent delete for archived fields behind a header … menu, calling the DELETE endpoint (cascades collected values; API rejects it for active fields)
  • Added an optional icon to the design system Menu items (this modal is currently its only consumer)
  • Added browser-mode acceptance tests for the tab split, filter opt-in, archive/reactivate/delete flows, empty states, and the Show all collapse (13 total)
  • Fixed a cross-test flake: a test ending before its modal finished closing let the pending removal fire into the next test's freshly-opened modal (NiceModal keys modals by component and dispatches globally)

Changelog for customers

  • Nothing yet — everything ships behind the membersCustomFields flag

Notes

Technical debt

  • None introduced

PR Scope (mark all that apply)

  • Improves the user experience
  • Enhances the readability of our code
  • Simplifies the maintenance of our software
  • Fixes a bug
  • Provide a core layer to allow one of the points above

Checklist before requesting a review (mark all that apply)

  • I have performed a self-review of my code
  • It's simple enough
  • The PR is not extensive
  • It includes documentation
  • I have added thorough tests.
  • Do we need to implement analytics?
  • Will this be part of a product update? If yes, please write one phrase about this update.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Custom fields now include active or archived status, and edits can patch name or status. The settings page fetches both statuses and displays them in separate collapsible tabs. The modal archives and reactivates fields through status updates, while permanent deletion is available for archived fields through a destructive menu. Acceptance and end-to-end tests cover filtering, tab behavior, expansion, and the complete field lifecycle.

Possibly related PRs

  • TryGhost/Ghost#29373: Adds backend custom-field status definitions, filtering, and archived-field behavior.
  • TryGhost/Ghost#29393: Adds server-side support for custom-field status filtering and archive lifecycle operations.

Suggested reviewers: 9larsons

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: managing archived custom fields in Settings.
Description check ✅ Passed The description is directly related to the changeset and explains the archived custom fields workflow and tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/custom-fields-archived

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit ee53a18

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 5m 45s View ↗
nx run-many -t test:unit -p @tryghost/admin-x-d... ✅ Succeeded 4m 25s View ↗
nx run ghost-admin:test ✅ Succeeded 3m 1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 1m 44s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 15s View ↗
nx run-many -t lint -p @tryghost/admin-x-design... ✅ Succeeded 1m 27s View ↗
nx run @tryghost/activitypub:test:acceptance ✅ Succeeded 44s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-17 12:18:40 UTC

@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.27%. Comparing base (3a5f3bb) to head (ee53a18).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29417      +/-   ##
==========================================
- Coverage   74.27%   74.27%   -0.01%     
==========================================
  Files        1595     1595              
  Lines      139583   139583              
  Branches    16946    16946              
==========================================
- Hits       103674   103672       -2     
- Misses      34891    34892       +1     
- Partials     1018     1019       +1     
Flag Coverage Δ
admin-tests 55.45% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@rob-ghost
rob-ghost force-pushed the feat/custom-fields-archived branch from a584acb to 8aaf6c9 Compare July 17, 2026 11:24
@rob-ghost
rob-ghost marked this pull request as ready for review July 17, 2026 11:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/admin/src/settings/membership/custom-fields.acceptance.test.tsx (1)

239-259: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the archived-only deletion constraint.

This proves archived fields can be deleted, but not that active fields lack the destructive menu. Add a negative test because deletion permanently removes collected values.

Proposed coverage
+    it("does not expose permanent deletion for an active field", async () => {
+        fakeSettingsScreens();
+        fakeCustomFields([companyField]);
+        await renderAdminApp("/settings", {boot: customFieldsBoot()});
+
+        await settingsScreen.customFields().getByTestId("custom-field-list-item").click();
+        const modal = settingsScreen.customFieldModal();
+        await expect(modal.getByRole("button", {name: "Menu"})).toHaveCount(0);
+    });
+
     it("permanently deletes an archived field from the header menu, after a heavy warning", async () => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/admin/src/settings/membership/custom-fields.acceptance.test.tsx` around
lines 239 - 259, Add a negative acceptance test alongside the archived deletion
case using an active custom field, open its custom-field modal and header Menu,
and assert that the “Delete custom field” action is absent or unavailable. Reuse
the existing settings-screen helpers and fixtures, and ensure no delete request
is made.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/admin-x-settings/src/components/settings/membership/custom-fields.tsx`:
- Around line 60-62: Remove the hideActions prop from the ListItem configured
with onClick={() => openModal(field)} so its Edit control remains available and
keyboard-accessible at desktop widths; preserve the existing separator and click
behavior.
- Line 51: Update the Edit action in the custom-fields list so its click does
not bubble to the ListItem root, preventing duplicate openModal(field) calls.
Also preserve keyboard accessibility by ensuring fields remain editable through
a focusable, keyboard-operable control even when hideActions applies, rather
than relying solely on the row’s div click handler.

---

Nitpick comments:
In `@apps/admin/src/settings/membership/custom-fields.acceptance.test.tsx`:
- Around line 239-259: Add a negative acceptance test alongside the archived
deletion case using an active custom field, open its custom-field modal and
header Menu, and assert that the “Delete custom field” action is absent or
unavailable. Reuse the existing settings-screen helpers and fixtures, and ensure
no delete request is made.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ed8876d7-708f-43f4-80bf-81e476818aab

📥 Commits

Reviewing files that changed from the base of the PR and between 9b3bbe5 and 8aaf6c9.

📒 Files selected for processing (5)
  • apps/admin-x-design-system/src/global/menu.tsx
  • apps/admin-x-framework/src/api/member-custom-fields.ts
  • apps/admin-x-settings/src/components/settings/membership/custom-fields.tsx
  • apps/admin-x-settings/src/components/settings/membership/custom-fields/custom-field-modal.tsx
  • apps/admin/src/settings/membership/custom-fields.acceptance.test.tsx

renatoworks and others added 6 commits July 17, 2026 12:55
Settings now lists archived custom fields alongside active ones, split into tabs. The list opts into both statuses with a status filter and splits client-side. An archived field can be reactivated (a status flip back to active) or, from a header menu, permanently deleted, which removes the field and its collected values. This consumes the archive, restore and delete API.
Drives the full definition lifecycle through Settings against a real backend
(define, rename, archive, reactivate, archive, then permanently delete),
asserting the field moves between the Active and Archived tabs and disappears
once deleted. Extends the custom fields settings page object with archive,
reactivate, delete and tab helpers.
The destructive class was interpolated with `&&`, emitting a literal
"false" class token on every non-destructive item; a ternary appends
nothing when not destructive. Decorative menu item icons are now
marked aria-hidden so they stay out of the accessibility tree beside
their text labels.
The Edit button was hover-only (hideActions) and the row is a non-focusable div, so keyboard users had no way to open a field. Keeping the Edit button visible makes it focusable, and stopping its click from bubbling to the row's own handler keeps the modal opening only once.
Settings hand-wrote the NQL filter string to opt into archived fields,
leaking the API's query grammar into the view. A dedicated
useBrowseMemberCustomFieldsIncludingArchived variant lives next to the
endpoint definition, so the filter is defined once beside the browse hook.
An active field exposes no header menu, so permanent deletion is
unreachable from the UI — mirroring the backend rule that only archived
fields can be deleted. A negative acceptance test pins that guarantee.
@rob-ghost
rob-ghost force-pushed the feat/custom-fields-archived branch from 8aaf6c9 to ee53a18 Compare July 17, 2026 12:10
@rob-ghost
rob-ghost requested a review from 9larsons as a code owner July 17, 2026 12:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
e2e/helpers/pages/admin/settings/sections/custom-fields-section.ts (1)

1-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extend AdminPage and expose locators as public readonly.

As per path instructions for e2e/helpers/pages/**/*.{ts,tsx}:

  • Page Objects must extend AdminPage or PublicPage (instead of BasePage).
  • Locators should be exposed as public readonly.
♻️ Proposed refactor
-import {BasePage} from '`@/helpers/pages`';
+import {AdminPage} from '`@/helpers/pages`';
 import {Locator, Page} from '`@playwright/test`';
 
 /**
  * Settings -> Membership -> Custom fields. The whole section is behind the
  * `membersCustomFields` flag, so a test using it must enable that flag via
  * test.use({labs: {membersCustomFields: true}}).
  */
-export class CustomFieldsSection extends BasePage {
-    readonly section: Locator;
-    readonly addButton: Locator;
-    readonly modal: Locator;
+export class CustomFieldsSection extends AdminPage {
+    public readonly section: Locator;
+    public readonly addButton: Locator;
+    public readonly modal: Locator;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/helpers/pages/admin/settings/sections/custom-fields-section.ts` around
lines 1 - 13, Update CustomFieldsSection to extend AdminPage instead of
BasePage, and explicitly declare section, addButton, and modal as public
readonly Locator properties. Preserve their existing locator behavior and
initialization.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@e2e/helpers/pages/admin/settings/sections/custom-fields-section.ts`:
- Around line 1-13: Update CustomFieldsSection to extend AdminPage instead of
BasePage, and explicitly declare section, addButton, and modal as public
readonly Locator properties. Preserve their existing locator behavior and
initialization.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1c7bc00e-7ad0-4b7d-824f-27ebc4208be2

📥 Commits

Reviewing files that changed from the base of the PR and between 8aaf6c9 and ee53a18.

📒 Files selected for processing (7)
  • apps/admin-x-design-system/src/global/menu.tsx
  • apps/admin-x-framework/src/api/member-custom-fields.ts
  • apps/admin-x-settings/src/components/settings/membership/custom-fields.tsx
  • apps/admin-x-settings/src/components/settings/membership/custom-fields/custom-field-modal.tsx
  • apps/admin/src/settings/membership/custom-fields.acceptance.test.tsx
  • e2e/helpers/pages/admin/settings/sections/custom-fields-section.ts
  • e2e/tests/admin/settings/custom-fields-lifecycle.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/admin-x-settings/src/components/settings/membership/custom-fields/custom-field-modal.tsx
  • apps/admin-x-settings/src/components/settings/membership/custom-fields.tsx
  • apps/admin-x-design-system/src/global/menu.tsx
  • apps/admin/src/settings/membership/custom-fields.acceptance.test.tsx

@rob-ghost
rob-ghost enabled auto-merge (squash) July 17, 2026 12:21
@rob-ghost
rob-ghost merged commit 9f86dd7 into main Jul 17, 2026
44 checks passed
@rob-ghost
rob-ghost deleted the feat/custom-fields-archived branch July 17, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants