Skip to content

Added disable/enable commenting to member detail screen#26222

Merged
rob-ghost merged 1 commit intomainfrom
feat/ber-3184-ban-members-screen
Feb 4, 2026
Merged

Added disable/enable commenting to member detail screen#26222
rob-ghost merged 1 commit intomainfrom
feat/ber-3184-ban-members-screen

Conversation

@rob-ghost
Copy link
Contributor

@rob-ghost rob-ghost commented Feb 4, 2026

Admins need the ability to disable commenting for individual members directly from the member detail screen, rather than only from the comments moderation list. This adds that capability behind the disableMemberCommenting labs flag as part of the broader member banning feature (BER-3184).

The implementation adds "Disable commenting" and "Enable commenting" actions to the member detail gear menu. Clicking "Disable commenting" opens a confirmation modal that shows the member's name, explains the consequence, and offers a "Hide all previous comments" checkbox. Disabling swaps the menu item to "Enable commenting" and shows a "Comments disabled — Enable" indicator in the member details sidebar. The enable link appears on hover for a clean default look. Re-enabling is immediate (no modal) matching the comments moderation list behaviour.

Because the comments moderation list is a React app using React Query while the member detail page is Ember, disabling/enabling commenting from the Ember side doesn't automatically invalidate the React Query cache. This PR bridges that gap by calling window.adminXQueryClient.invalidateQueries() for both CommentsResponseType and MembersResponseType after the API calls, following the same pattern used by the billing iframe. An E2E test specifically verifies this cross-navigation cache invalidation by disabling commenting from the member page and then checking the comments page reflects the change.
Screenshot 2026-02-04 at 11 21 56
Screenshot 2026-02-04 at 11 21 59
Screenshot 2026-02-04 at 11 22 04
Screenshot 2026-02-04 at 11 22 08

Summary by CodeRabbit

  • New Features

    • Per-member disable/enable commenting controls (menu actions and an "Enable" link in member details)
    • Confirmation modal to disable commenting with "Hide all previous comments" option
    • Visual "Comments disabled" indicator shown in member details
  • Style

    • Added styles for disabled-commenting UI and enable-link reveal
  • Tests

    • End-to-end tests covering commenting controls and comment visibility/cache updates

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

Adds per-member commenting controls: model attrs, feature flag, member UI (indicator, enable link, menu actions), a disable-commenting modal component with task/API calls and cache invalidation, controller actions for enable/disable, styles, and E2E tests/page-object locators.

Changes

Cohort / File(s) Summary
E2E tests & page objects
e2e/tests/admin/members/disable-commenting.test.ts, e2e/helpers/pages/admin/comments/comments-page.ts, e2e/helpers/pages/admin/members/member-details-page.ts
Adds E2E coverage for disabling/enabling member commenting and updates page objects with locators for the "View member" menu item, disable/enable controls, modal elements, checkbox, and indicators.
Disable commenting modal
ghost/admin/app/components/members/modals/disable-commenting.hbs, ghost/admin/app/components/members/modals/disable-commenting.js
New modal template and component with hide-comments toggle and an async task that POSTs disable requests, shows notifications, invokes callbacks, and invalidates React Query caches.
Member details & settings UI
ghost/admin/app/components/gh-member-details.hbs, ghost/admin/app/components/gh-member-details.js, ghost/admin/app/components/gh-member-settings-form.hbs, ghost/admin/app/templates/member.hbs
Adds "Comments disabled" indicator and Enable link/button, injects feature service, forwards @onEnableCommenting, and conditionally renders disable/enable actions based on the disableMemberCommenting feature and member.canComment.
Controller, model, feature service
ghost/admin/app/controllers/member.js, ghost/admin/app/models/member.js, ghost/admin/app/services/feature.js
Adds confirmDisableCommenting and confirmEnableCommenting actions (API calls, notifications, cache invalidation, refresh), introduces canComment and commenting model attrs, and exposes commentModeration feature flag.
Styles
ghost/admin/app/styles/layouts/members.css
Adds CSS for the disabled-comment indicator, revealable enable link on hover/focus, and SVG stroke adjustments in member details.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Member Details UI
    participant Controller as Member Controller
    participant Modal as DisableCommentingModal
    participant API as Ghost API
    participant Cache as React Query Cache

    rect rgba(100, 150, 255, 0.5)
    Note over User,UI: Disable commenting flow
    User->>UI: Click "Disable commenting"
    UI->>Controller: confirmDisableCommenting()
    Controller->>UI: Open DisableCommentingModal
    User->>Modal: Toggle "Hide comments" (optional)
    User->>Modal: Click Confirm
    Modal->>API: POST /members/{id}/disable-commenting {hide_comments}
    API-->>Modal: 200 OK
    Modal->>Cache: Invalidate CommentsResponseType
    Modal->>Cache: Invalidate MembersResponseType
    Modal->>Controller: afterDisable callback (refresh)
    Controller->>UI: Re-render member (canComment=false)
    end
Loading
sequenceDiagram
    actor User
    participant UI as Member Details UI
    participant Controller as Member Controller
    participant API as Ghost API
    participant Cache as React Query Cache

    rect rgba(150, 255, 100, 0.5)
    Note over User,UI: Enable commenting flow
    User->>UI: Click "Enable" (menu or link)
    UI->>Controller: confirmEnableCommenting()
    Controller->>API: POST /members/{id}/enable-commenting
    API-->>Controller: 200 OK
    Controller->>Cache: Invalidate CommentsResponseType
    Controller->>Cache: Invalidate MembersResponseType
    Controller->>UI: Refresh member (canComment=true)
    end
Loading

Possibly related PRs

Suggested reviewers

  • kevinansfield
  • jonatansberg
  • cmraible
  • 9larsons
  • peterzimon

Poem

🐇
I hopped into the member view and found,
a toggle where old whispers were bound.
With a click the modal softly sighed,
caches cleared, the quiet pried—
now voices sleep or spring unbound.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding disable/enable commenting functionality to the member detail screen, which matches the primary objective of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ber-3184-ban-members-screen

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 and usage tips.

@rob-ghost rob-ghost marked this pull request as ready for review February 4, 2026 13:54
@rob-ghost rob-ghost self-assigned this Feb 4, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@ghost/admin/app/styles/layouts/members.css`:
- Around line 806-827: The visibility of the “Enable” link is currently only
toggled on hover, making it inaccessible to keyboard users; update the CSS so
the rule that sets opacity: 1 applies on keyboard focus as well by adding a
:focus-within state to the container selector (i.e., change the selector
targeting .gh-member-commenting-disabled:hover .gh-member-details-enable-link to
also include .gh-member-commenting-disabled:focus-within
.gh-member-details-enable-link) and ensure the existing
.gh-member-details-enable-link button remains keyboard-focusable and visually
clear when focused.

In `@ghost/admin/app/templates/member.hbs`:
- Around line 81-103: Add the new admin UI strings used in member.hbs ("Disable
commenting" and "Enable commenting") to the English locale file so they are
localizable; update ghost/i18n/locales/en/ghost.json by adding appropriate keys
(e.g., "members.disable_commenting" and "members.enable_commenting") and include
the matching string values, then replace the hardcoded text in the template
(member.hbs) with calls to the i18n helper referencing those keys (targets: the
label text currently inside the <span> elements for the buttons).
🧹 Nitpick comments (3)
e2e/helpers/pages/admin/members/member-details-page.ts (1)

79-84: Prefer a role-based checkbox locator for reliability.
getByText targets the label text, which can be brittle for isChecked/toBeChecked assertions.

♻️ Suggested change
-        this.hideCommentsCheckbox = this.disableCommentingModal.getByText('Hide all previous comments');
+        this.hideCommentsCheckbox = this.disableCommentingModal.getByRole('checkbox', {name: 'Hide all previous comments'});
e2e/tests/admin/members/disable-commenting.test.ts (2)

15-231: Add explicit AAA sections for readability.
Consider splitting each test into clear Arrange / Act / Assert sections (even with minimal separators) to align with the E2E test standard.

As per coding guidelines Use the AAA Pattern (Arrange, Act, Assert) in E2E tests with clear sections.


74-75: Use getByRole('checkbox', {name: 'Hide all previous comments'}) for higher priority semantic locator.

The current implementation uses getByText(), which is semantic but lower priority. getByRole() should be the primary choice for checkbox elements to improve stability and accessibility alignment with Playwright best practices.

@rob-ghost rob-ghost force-pushed the feat/ber-3184-ban-members-screen branch from db7c830 to 0e3017c Compare February 4, 2026 14:06
Copy link
Contributor

@weylandswart weylandswart left a comment

Choose a reason for hiding this comment

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

Looks good to me. Some minor things that I think should be squared up.

@rob-ghost rob-ghost force-pushed the feat/ber-3184-ban-members-screen branch from 0e3017c to e2158ac Compare February 4, 2026 15:42
ref https://linear.app/tryghost/issue/BER-3184/

Adds gear menu actions, confirmation modal with hide-comments checkbox, sidebar
indicator, and React Query cache invalidation so the comments list stays in sync
when commenting is toggled from the Ember member detail page. Behind the
disableMemberCommenting labs flag.
@rob-ghost rob-ghost force-pushed the feat/ber-3184-ban-members-screen branch from e2158ac to e443ae2 Compare February 4, 2026 17:10
@rob-ghost rob-ghost enabled auto-merge (rebase) February 4, 2026 17:14
@rob-ghost rob-ghost merged commit 640ebbf into main Feb 4, 2026
30 checks passed
@rob-ghost rob-ghost deleted the feat/ber-3184-ban-members-screen branch February 4, 2026 17:34
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