Cleaned up the gift subscriptions feature flag#27862
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## BER-3597-promote-to-ga #27862 +/- ##
=========================================================
Coverage ? 73.83%
=========================================================
Files ? 1519
Lines ? 128142
Branches ? 15353
=========================================================
Hits ? 94613
Misses ? 32573
Partials ? 956
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b4a2108 to
c3683cd
Compare
6e705dc to
21d7ade
Compare
ref https://linear.app/ghost/issue/BER-3597 Gift subscriptions let anyone purchase a paid subscription on behalf of someone else — a friend, family member, or colleague — giving them full access to a site's paid content for up to a year. --- Co-authored-by: Sag <guptazy@gmail.com> Co-authored-by: Sodbileg Gansukh <sodbileg.gansukh@gmail.com>
c3683cd to
3146297
Compare
ref https://linear.app/tryghost/issue/BER-3646/ - removed the `giftSubscriptions` labs flag and all backend / frontend code guards - dropped the now-redundant `hasGiftSubscriptions` Portal helper and simplified `canPurchaseGift` to a Stripe check - removed the corresponding disabled-branch unit/integration/e2e tests and updated the admin config snapshot
21d7ade to
3dddac7
Compare
| export function canPurchaseGift({site}) { | ||
| return hasGiftSubscriptions({site}) && isStripeConfigured({site}); | ||
| return isStripeConfigured({site}); | ||
| } |
There was a problem hiding this comment.
nit: shall we remove canPurchaseGift() and directly use isStripeConfigured() where needed? Removes one (now unnecessary) layer of abstraction
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@ghost/admin/app/components/koenig-lexical-editor.js`:
- Around line 303-310: The giftLink object (label/value) is always added to the
returned array; change the return logic to only include giftLink when the site
supports purchases (i.e., when the purchase capability check on the component
returns true). Modify the code around giftLink, offersLinks
(offerUrls.call(this)), and the final return so you conditionally push giftLink
into the array only if a purchase-capability predicate (for example an existing
method like this.canPurchase() or a boolean flag that indicates Stripe/purchases
are enabled) is true; otherwise return the array without giftLink.
🪄 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: 601a92bf-d036-498f-a440-6564fd39d6b0
⛔ Files ignored due to path filters (2)
ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snapis excluded by!**/*.snapghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snapis excluded by!**/*.snap
📒 Files selected for processing (33)
apps/admin-x-settings/src/components/settings/general/users/email-notifications-tab.tsxapps/admin-x-settings/src/components/settings/membership/portal/portal-links.tsxapps/portal/package.jsonapps/portal/src/app.jsapps/portal/src/components/pages/gift-redemption-page.jsapps/portal/src/utils/helpers.jsapps/portal/test/app.test.jsapps/portal/test/portal-links.test.jsapps/portal/test/unit/components/pages/gift-redemption-page.test.jsapps/portal/test/utils/helpers.test.jsapps/posts/src/views/members/components/bulk-action-modals/import-members-modal.tsxapps/posts/src/views/members/components/bulk-action-modals/import-members/mapping.tsapps/posts/src/views/members/components/members-filters.tsxapps/posts/src/views/members/use-member-filter-fields.test.tsapps/posts/src/views/members/use-member-filter-fields.tsapps/posts/test/unit/views/members/import-members/mapping.test.tsapps/posts/test/unit/views/members/import-members/modal.test.tsxapps/stats/src/views/Stats/Growth/components/growth-kpis.tsxghost/admin/app/components/koenig-lexical-editor.jsghost/admin/app/services/feature.jsghost/core/core/server/services/gifts/gift-controller.tsghost/core/core/server/services/gifts/gift-service-wrapper.jsghost/core/core/server/services/gifts/gift-service.tsghost/core/core/server/services/members/members-api/controllers/router-controller.jsghost/core/core/server/services/members/members-api/members-api.jsghost/core/core/server/web/gift-preview/controller.jsghost/core/core/shared/labs.jsghost/core/test/e2e-api/members/gift-subscriptions.test.jsghost/core/test/integration/services/members/send-gift-reminders.test.jsghost/core/test/unit/server/services/gifts/gift-controller.test.tsghost/core/test/unit/server/services/members/members-api/controllers/router-controller.test.jsghost/core/test/unit/server/services/members/members-api/members-api.test.jsghost/core/test/unit/server/web/gift-preview/controller.test.js
💤 Files with no reviewable changes (11)
- ghost/core/core/server/services/gifts/gift-service.ts
- ghost/core/test/integration/services/members/send-gift-reminders.test.js
- apps/portal/src/utils/helpers.js
- ghost/core/test/e2e-api/members/gift-subscriptions.test.js
- ghost/core/core/server/web/gift-preview/controller.js
- ghost/core/core/server/services/members/members-api/controllers/router-controller.js
- ghost/core/test/unit/server/services/members/members-api/members-api.test.js
- ghost/core/test/unit/server/services/members/members-api/controllers/router-controller.test.js
- ghost/admin/app/services/feature.js
- apps/portal/test/utils/helpers.test.js
- ghost/core/test/unit/server/web/gift-preview/controller.test.js
| const giftLink = { | ||
| label: 'Gift subscriptions', | ||
| value: '#/portal/gift' | ||
| }; | ||
|
|
||
| const offersLinks = await offerUrls.call(this); | ||
|
|
||
| return [...defaults, ...memberLinks(), ...donationLink(), ...recommendationLink(), ...giftLink(), ...offersLinks]; | ||
| return [...defaults, ...memberLinks(), ...donationLink(), ...recommendationLink(), giftLink, ...offersLinks]; |
There was a problem hiding this comment.
Gate the gift link on purchase capability.
Line 303 and Line 310 now always include #/portal/gift. This can expose a non-functional Portal route in autocomplete on sites that can’t sell gifts (e.g., no Stripe capability).
Proposed fix
- const giftLink = {
- label: 'Gift subscriptions',
- value: '#/portal/gift'
- };
+ const giftLink = () => {
+ if (!checkStripeEnabled()) {
+ return [];
+ }
+
+ return [{
+ label: 'Gift subscriptions',
+ value: '#/portal/gift'
+ }];
+ };
@@
- return [...defaults, ...memberLinks(), ...donationLink(), ...recommendationLink(), giftLink, ...offersLinks];
+ return [...defaults, ...memberLinks(), ...donationLink(), ...recommendationLink(), ...giftLink(), ...offersLinks];🤖 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 `@ghost/admin/app/components/koenig-lexical-editor.js` around lines 303 - 310,
The giftLink object (label/value) is always added to the returned array; change
the return logic to only include giftLink when the site supports purchases
(i.e., when the purchase capability check on the component returns true). Modify
the code around giftLink, offersLinks (offerUrls.call(this)), and the final
return so you conditionally push giftLink into the array only if a
purchase-capability predicate (for example an existing method like
this.canPurchase() or a boolean flag that indicates Stripe/purchases are
enabled) is true; otherwise return the array without giftLink.
3146297 to
8c810f5
Compare
ref https://linear.app/tryghost/issue/BER-3646/
giftSubscriptionslabs flag and all backend / frontend code guardshasGiftSubscriptionsPortal helper and simplifiedcanPurchaseGiftto a Stripe check