Skip to content

Cleaned up the gift subscriptions feature flag#27862

Open
mike182uk wants to merge 4 commits into
mainfrom
BER-3646-clean-up-feature-flag
Open

Cleaned up the gift subscriptions feature flag#27862
mike182uk wants to merge 4 commits into
mainfrom
BER-3646-clean-up-feature-flag

Conversation

@mike182uk
Copy link
Copy Markdown
Member

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 77822d23-afda-4d67-87fa-cb3f0de60b3f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BER-3646-clean-up-feature-flag

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (BER-3597-promote-to-ga@3146297). Learn more about missing BASE report.

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           
Flag Coverage Δ
admin-tests 53.45% <ø> (?)
e2e-tests 73.83% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mike182uk mike182uk changed the base branch from main to BER-3597-promote-to-ga May 13, 2026 13:44
@mike182uk mike182uk force-pushed the BER-3597-promote-to-ga branch from b4a2108 to c3683cd Compare May 13, 2026 13:47
@mike182uk mike182uk force-pushed the BER-3646-clean-up-feature-flag branch 3 times, most recently from 6e705dc to 21d7ade Compare May 13, 2026 14:11
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>
@mike182uk mike182uk force-pushed the BER-3597-promote-to-ga branch from c3683cd to 3146297 Compare May 14, 2026 07:00
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
@mike182uk mike182uk force-pushed the BER-3646-clean-up-feature-flag branch from 21d7ade to 3dddac7 Compare May 14, 2026 07:02
Copy link
Copy Markdown
Contributor

@sagzy sagzy left a comment

Choose a reason for hiding this comment

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

LGTM, left one nit

Comment thread apps/portal/src/utils/helpers.js Outdated
export function canPurchaseGift({site}) {
return hasGiftSubscriptions({site}) && isStripeConfigured({site});
return isStripeConfigured({site});
}
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.

nit: shall we remove canPurchaseGift() and directly use isStripeConfigured() where needed? Removes one (now unnecessary) layer of abstraction

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep good shout, removed in: 211624d

@mike182uk mike182uk marked this pull request as ready for review May 14, 2026 11:36
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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3146297 and 211624d.

⛔ Files ignored due to path filters (2)
  • ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (33)
  • apps/admin-x-settings/src/components/settings/general/users/email-notifications-tab.tsx
  • apps/admin-x-settings/src/components/settings/membership/portal/portal-links.tsx
  • apps/portal/package.json
  • apps/portal/src/app.js
  • apps/portal/src/components/pages/gift-redemption-page.js
  • apps/portal/src/utils/helpers.js
  • apps/portal/test/app.test.js
  • apps/portal/test/portal-links.test.js
  • apps/portal/test/unit/components/pages/gift-redemption-page.test.js
  • apps/portal/test/utils/helpers.test.js
  • apps/posts/src/views/members/components/bulk-action-modals/import-members-modal.tsx
  • apps/posts/src/views/members/components/bulk-action-modals/import-members/mapping.ts
  • apps/posts/src/views/members/components/members-filters.tsx
  • apps/posts/src/views/members/use-member-filter-fields.test.ts
  • apps/posts/src/views/members/use-member-filter-fields.ts
  • apps/posts/test/unit/views/members/import-members/mapping.test.ts
  • apps/posts/test/unit/views/members/import-members/modal.test.tsx
  • apps/stats/src/views/Stats/Growth/components/growth-kpis.tsx
  • ghost/admin/app/components/koenig-lexical-editor.js
  • ghost/admin/app/services/feature.js
  • ghost/core/core/server/services/gifts/gift-controller.ts
  • ghost/core/core/server/services/gifts/gift-service-wrapper.js
  • ghost/core/core/server/services/gifts/gift-service.ts
  • ghost/core/core/server/services/members/members-api/controllers/router-controller.js
  • ghost/core/core/server/services/members/members-api/members-api.js
  • ghost/core/core/server/web/gift-preview/controller.js
  • ghost/core/core/shared/labs.js
  • ghost/core/test/e2e-api/members/gift-subscriptions.test.js
  • ghost/core/test/integration/services/members/send-gift-reminders.test.js
  • ghost/core/test/unit/server/services/gifts/gift-controller.test.ts
  • ghost/core/test/unit/server/services/members/members-api/controllers/router-controller.test.js
  • ghost/core/test/unit/server/services/members/members-api/members-api.test.js
  • ghost/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

Comment on lines +303 to +310
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];
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

@sagzy sagzy force-pushed the BER-3597-promote-to-ga branch from 3146297 to 8c810f5 Compare May 21, 2026 08:14
Base automatically changed from BER-3597-promote-to-ga to main May 21, 2026 08:40
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