Skip to content

feat(audience): let group owners rename their groups (NPPD-1813)#460

Open
adekbadek wants to merge 4 commits into
mainfrom
nppd-1813-group-rename
Open

feat(audience): let group owners rename their groups (NPPD-1813)#460
adekbadek wants to merge 4 commits into
mainfrom
nppd-1813-group-rename

Conversation

@adekbadek

Copy link
Copy Markdown
Member

All Submissions:

Changes proposed in this Pull Request:

Owners of multiple group subscriptions saw every card labelled "Group" in the My Account group picker, with no way to tell them apart (NPPD-1813). This adds a reader-facing way to rename a group, following @thomasguillot's design direction (pencil button in the header → small modal).

  • New POST /name route on the group-subscription REST API (newspack-group-subscription/v1/name). Reuses the existing manager/admin permission_callback. Renaming is metadata-only, so unlike member/invite changes it is not state-gated — an owner can still rename a cancelled or expired group to tell them apart in the picker. An empty name clears the override, falling back to the product name and then the default group label. Length is capped to GROUP_NAME_MAX_LENGTH (100), mirrored by the input's maxlength.
  • Pencil ghost button in the group page header (Group {pencil} [Active]) with tooltip + aria-label, opening a small newspack-ui modal with a name input and stacked Save/Cancel actions. On save, the header and the picker cards reflect the new name (via a data-group-name hook).
  • The name is persisted to the existing _newspack_group_subscription_name meta, already honoured by the picker, the header, and the admin meta box, so no data-model change was needed.

Closes NPPD-1813.

How to test the changes in this Pull Request:

  1. On a site with Reader Activation enabled and NEWSPACK_CONTENT_GATES on, create a reader who owns two group-enabled subscriptions with no custom name (both will show as "Group").
  2. Visit /my-account/group/ — confirm the picker shows two indistinguishable "Group" cards.
  3. Open one group, click the pencil next to the name. Confirm a modal opens with the current name prefilled.
  4. Enter a new name and Save. Confirm: the header updates in place, a "Name updated." snackbar appears, and the modal closes.
  5. Go back to the picker — the renamed card is now distinct from the other "Group" card.
  6. Re-open the modal, clear the field, and Save — confirm the name reverts to the default group label.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable? (5 new Test_Group_Subscription_API cases: persist, trim, empty→fallback, length cap, allowed-on-cancelled.)
  • Have you successfully run tests with your changes locally? (13/13 green; PHPCS clean.)

🤖 Generated with Claude Code

Owners of multiple group subscriptions saw every card labelled "Group" in
the My Account group picker, with no way to tell them apart. Add a reader-facing
rename affordance:

- New `POST /name` route on the group-subscription REST API. Reuses the
  manager/admin permission callback. Renaming is metadata-only, so unlike
  member/invite changes it is not state-gated (an owner can rename a cancelled
  or expired group). An empty name clears the override, falling back to the
  product name then the default group label. Name length is capped to
  GROUP_NAME_MAX_LENGTH.
- A pencil ghost button in the group page header (Group {pencil} [Active])
  opens a small modal with a name input and stacked Save/Cancel actions, per
  design. On save the header and picker reflect the new name.

The name is persisted to the existing `_newspack_group_subscription_name` meta,
already honoured by the picker, header, and admin meta box.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Q8L6Wb1ZhTf7AS4Jp3wjK
Copilot AI review requested due to automatic review settings June 30, 2026 08:30

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@adekbadek adekbadek requested a review from Copilot June 30, 2026 08:30

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

adekbadek and others added 2 commits June 30, 2026 10:50
- Move GROUP_NAME_MAX_LENGTH to Group_Subscription_Settings (owns the name meta);
  the template no longer imports Group_Subscription_API just for the constant.
- Seed the rename input from the stored custom name (empty when the group uses an
  inherited fallback) and show the resolved fallback as the placeholder, so the
  "clear to reset" affordance reads cleanly. Track the typed value in JS so it
  survives a rename without a page reload.
- Read the subscription id from the rename form's own data-subscription-id so the
  feature is self-contained rather than coupled to the invite-link panel element.
- Extract a withLoadingButton() helper, removing the third copy of the
  loading-state boilerplate (now shared by generate/delete/rename).
- Drop the dead group_name_update_failed label (JS uses the form's data-error-text,
  matching the invite-link flow); fix the stale "PATCHes" comment (the request is POST).
- Tests: add route-dispatch coverage for the new permission surface (non-manager
  denied) and arg sanitization (markup stripped), plus the 404 branch; clarify the
  empty-name fallback test name.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Q8L6Wb1ZhTf7AS4Jp3wjK
…PPD-1813)

Round-2 review follow-up: drop the `|| subId` fallback so the rename request's
subscription id comes only from the form's own data-subscription-id. A missing
attribute now surfaces as a failed request rather than silently falling back to
the invite-panel id, and the comment no longer over-claims full independence.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Q8L6Wb1ZhTf7AS4Jp3wjK
@adekbadek adekbadek marked this pull request as ready for review June 30, 2026 08:56
@adekbadek adekbadek requested a review from a team as a code owner June 30, 2026 08:56
Per design feedback, the "Group name" label in the rename modal is now
screen-reader-only (screen-reader-text). The label stays associated with the
input via `for`, so the input keeps its accessible name; only the visible text
is dropped for a cleaner modal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Q8L6Wb1ZhTf7AS4Jp3wjK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants