Added /#/portal/gift route for gift subscription checkout#27053
Added /#/portal/gift route for gift subscription checkout#27053
/#/portal/gift route for gift subscription checkout#27053Conversation
WalkthroughAdds a gift subscriptions page and gating to the portal: a new 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
ref https://linear.app/ghost/issue/BER-3484 Scaffolds the Portal gift page behind the `giftSubscriptions` labs flag. When the flag is disabled, both hash links and `data-portal` attributes are blocked and the URL is cleaned up.
af48e1f to
1cf895f
Compare
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/portal/src/app.js (1)
585-589: Consider consolidating duplicated gift-gate logic into a single helper method.The same guard + URL cleanup pattern appears here and in the click handler, which risks behavior drift.
♻️ Suggested refactor
+ shouldBlockGiftRoute({page, site}) { + if (page === 'gift' && !hasGiftSubscriptions({site})) { + removePortalLinkFromUrl(); + return true; + } + return false; + } setupCustomTriggerButton() { // Handler for custom buttons this.clickHandler = (event) => { event.preventDefault(); const target = event.currentTarget; const pagePath = (target && target.dataset.portal); const {page, pageQuery, pageData} = this.getPageFromLinkPath(pagePath) || {}; if (this.state.initStatus === 'success') { - if (page === 'gift' && !hasGiftSubscriptions({site: this.state.site})) { - removePortalLinkFromUrl(); - + if (this.shouldBlockGiftRoute({page, site: this.state.site})) { return; } if (pageQuery && pageQuery !== 'free') { this.handleSignupQuery({site: this.state.site, pageQuery}); } else { this.dispatchAction('openPopup', {page, pageQuery, pageData}); } } }; }- if (page === 'gift' && !hasGiftSubscriptions({site})) { - removePortalLinkFromUrl(); - + if (this.shouldBlockGiftRoute({page, site})) { return {}; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/portal/src/app.js` around lines 585 - 589, The gift-gate guard and URL cleanup (the conditional checking page === 'gift' + hasGiftSubscriptions({site}) + call to removePortalLinkFromUrl()) are duplicated; extract that logic into a single helper (e.g., shouldAllowGiftPage or enforceGiftGate) and call it from both this block and the click handler so behavior stays consistent. Implement the helper to accept the same context (site and page or event) and perform the hasGiftSubscriptions check and removePortalLinkFromUrl() side-effect, returning the appropriate empty object or boolean to drive the caller flow, then replace both original conditionals with calls to the new helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/portal/src/app.js`:
- Around line 585-589: The gift-gate guard and URL cleanup (the conditional
checking page === 'gift' + hasGiftSubscriptions({site}) + call to
removePortalLinkFromUrl()) are duplicated; extract that logic into a single
helper (e.g., shouldAllowGiftPage or enforceGiftGate) and call it from both this
block and the click handler so behavior stays consistent. Implement the helper
to accept the same context (site and page or event) and perform the
hasGiftSubscriptions check and removePortalLinkFromUrl() side-effect, returning
the appropriate empty object or boolean to drive the caller flow, then replace
both original conditionals with calls to the new helper.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cdabb361-ec25-4426-a642-a2f5ed313b0d
📒 Files selected for processing (7)
apps/portal/package.jsonapps/portal/src/app.jsapps/portal/src/components/pages/gift-page.jsapps/portal/src/pages.jsapps/portal/src/utils/helpers.jsapps/portal/test/portal-links.test.jsapps/portal/test/utils/helpers.test.js
✅ Files skipped from review due to trivial changes (4)
- apps/portal/package.json
- apps/portal/src/components/pages/gift-page.js
- apps/portal/test/portal-links.test.js
- apps/portal/test/utils/helpers.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/portal/src/pages.js



ref https://linear.app/ghost/issue/BER-3484
Scaffolds the Portal gift page behind the
giftSubscriptionslabs flag. When the flag is disabled, both hash links anddata-portalattributes are blocked and the URL is cleaned up