Repository navigation
Added archived custom fields management to Settings - #29417
Conversation
WalkthroughCustom 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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
| 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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a584acb to
8aaf6c9
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/admin/src/settings/membership/custom-fields.acceptance.test.tsx (1)
239-259: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover 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
📒 Files selected for processing (5)
apps/admin-x-design-system/src/global/menu.tsxapps/admin-x-framework/src/api/member-custom-fields.tsapps/admin-x-settings/src/components/settings/membership/custom-fields.tsxapps/admin-x-settings/src/components/settings/membership/custom-fields/custom-field-modal.tsxapps/admin/src/settings/membership/custom-fields.acceptance.test.tsx
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.
8aaf6c9 to
ee53a18
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
e2e/helpers/pages/admin/settings/sections/custom-fields-section.ts (1)
1-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtend
AdminPageand expose locators aspublic readonly.As per path instructions for
e2e/helpers/pages/**/*.{ts,tsx}:
- Page Objects must extend
AdminPageorPublicPage(instead ofBasePage).- 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
📒 Files selected for processing (7)
apps/admin-x-design-system/src/global/menu.tsxapps/admin-x-framework/src/api/member-custom-fields.tsapps/admin-x-settings/src/components/settings/membership/custom-fields.tsxapps/admin-x-settings/src/components/settings/membership/custom-fields/custom-field-modal.tsxapps/admin/src/settings/membership/custom-fields.acceptance.test.tsxe2e/helpers/pages/admin/settings/sections/custom-fields-section.tse2e/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

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.
…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
filter=status:[active,archived](browse hides them by default, so other consumers like member details are untouched)statusedits over the existing PUT…menu, calling the DELETE endpoint (cascades collected values; API rejects it for active fields)iconto the design systemMenuitems (this modal is currently its only consumer)Changelog for customers
membersCustomFieldsflagNotes
statuson the wire, browse hiding archived by default, PUT status edits, DELETE gated on archived). Draft until that lands.Technical debt
PR Scope (mark all that apply)
Checklist before requesting a review (mark all that apply)