Skip to content

Added gift subscription label in Admin member page#27393

Closed
sagzy wants to merge 1 commit intomainfrom
gift-subscriptions/display-gift-in-admin
Closed

Added gift subscription label in Admin member page#27393
sagzy wants to merge 1 commit intomainfrom
gift-subscriptions/display-gift-in-admin

Conversation

@sagzy
Copy link
Copy Markdown
Contributor

@sagzy sagzy commented Apr 14, 2026

closes https://linear.app/ghost/issue/BER-3482

Summary

Update the Admin member details page to treat gift subscriptions as a distinct subscription type instead of displaying them as complimentary subscriptions.

For gift subscriptions, we now display:

Gift subscription – Expires {date}

with no action menu to remove the subscription:

CleanShot 2026-04-14 at 20 52 05@2x

What changed

  • Added gift-specific subscription normalization in the Admin subscription data helper
  • Added a giftExpiry helper sourced from sub.tier.expiry_at
  • Updated the subscription label logic so gift members render Gift subscription
  • Updated validity details so gift subscriptions render Expires {date}
  • Hid the action menu for gift subscriptions on the member details page
  • Kept complimentary subscriptions unchanged:
    • still render as Complimentary
    • still use the complimentary expiry path
    • still show the Remove complimentary subscription action
  • Tightened isComplimentary so it only applies to comped members with manual subscriptions

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Walkthrough

The changes add explicit handling for gift subscriptions across UI, utilities, and tests. getSubscriptionData now accepts memberStatus and returns isGift and giftExpiry, and isComplimentary/compExpiry now consider memberStatus. Template logic in the member settings form gains an else if sub.isGift branch that omits the subscription action menu for gifts. The tiers getter calls getSubscriptionData(sub, memberStatus) when computing tier associations. Unit and acceptance tests were added/updated to cover gift and comped subscription rendering and expiry displays.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a gift subscription label display on the Admin member page.
Description check ✅ Passed The description comprehensively explains the changes, including what was added, how gift subscriptions are now displayed, and clarifies that complimentary subscriptions remain unchanged.

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

✨ 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 gift-subscriptions/display-gift-in-admin

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb777c2aa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

},
isComplimentary: isComplimentary(sub),
compExpiry: compExpiry(sub),
isGift: isGiftSubscription(memberStatus),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Determine gift state per subscription

isGift is currently derived from the member’s global status, so when a member with historical canceled Stripe subscriptions later redeems a gift (status becomes gift), all subscription rows are treated as gift subscriptions. The member page still renders historical canceled subscriptions, so those past paid rows will be mislabeled as “Gift subscription”, lose their normal validity text, and skip the regular action menu. This should be computed from the individual subscription record instead of memberStatus to avoid misclassifying non-gift subscriptions on gift members.

Useful? React with 👍 / 👎.

@sagzy sagzy force-pushed the gift-subscriptions/display-gift-in-admin branch from cb777c2 to 3a98b6e Compare April 15, 2026 10:32
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
ghost/admin/tests/unit/utils/subscription-data-test.js (1)

256-262: Test confirms gift subscription validity details format.

Consider adding a test for gift subscriptions without giftExpiry (should return '') for symmetry with the complimentary "forever" test at lines 248-254.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ghost/admin/tests/unit/utils/subscription-data-test.js` around lines 256 -
262, Add a unit test that verifies validityDetails returns an empty string for
gift subscriptions when giftExpiry is missing: create a test case similar to the
existing gift test but set isGift: true and omit giftExpiry (or set it
undefined/null) and assert validityDetails(data) === ''. Update or add the test
near the other validityDetails tests so it mirrors the complimentary "forever"
case and references the validityDetails helper used in the current tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ghost/admin/tests/unit/utils/subscription-data-test.js`:
- Around line 256-262: Add a unit test that verifies validityDetails returns an
empty string for gift subscriptions when giftExpiry is missing: create a test
case similar to the existing gift test but set isGift: true and omit giftExpiry
(or set it undefined/null) and assert validityDetails(data) === ''. Update or
add the test near the other validityDetails tests so it mirrors the
complimentary "forever" case and references the validityDetails helper used in
the current tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a9fbc5cb-2ae8-4182-a5a3-3071fd155fcb

📥 Commits

Reviewing files that changed from the base of the PR and between cb777c2 and 3a98b6e.

📒 Files selected for processing (5)
  • ghost/admin/app/components/gh-member-settings-form.hbs
  • ghost/admin/app/components/gh-member-settings-form.js
  • ghost/admin/app/utils/subscription-data.js
  • ghost/admin/tests/acceptance/members/details-test.js
  • ghost/admin/tests/unit/utils/subscription-data-test.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • ghost/admin/app/components/gh-member-settings-form.hbs
  • ghost/admin/app/components/gh-member-settings-form.js
  • ghost/admin/tests/acceptance/members/details-test.js

@sagzy
Copy link
Copy Markdown
Contributor Author

sagzy commented Apr 15, 2026

As the Admin page shows a history of subscriptions, this is not going to be sufficient. Closing for another solution

@sagzy sagzy closed this Apr 15, 2026
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.

1 participant