Skip to content

Added /#/portal/gift route for gift subscription checkout#27053

Merged
mike182uk merged 1 commit intomainfrom
BER-3484-add-portal-gift-route
Apr 1, 2026
Merged

Added /#/portal/gift route for gift subscription checkout#27053
mike182uk merged 1 commit intomainfrom
BER-3484-add-portal-gift-route

Conversation

@mike182uk
Copy link
Copy Markdown
Member

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

Walkthrough

Adds a gift subscriptions page and gating to the portal: a new GiftPage component is registered in pages.js, a hasGiftSubscriptions({site}) helper is added, and app.js now prevents navigation to the gift page when the site's labs.giftSubscriptions flag is not true (removing portal link from the URL in those cases). Tests covering link routing and the helper behavior were added, and the portal package version was bumped.

🚥 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 directly and accurately describes the main change: adding a new gift subscription checkout route at /#/portal/gift, which matches the primary purpose of the changeset.
Description check ✅ Passed The description is relevant and related to the changeset, covering the scaffolding of the Portal gift page, the labs flag gating, and the URL cleanup behavior for disabled states.

✏️ 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 BER-3484-add-portal-gift-route

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

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.
@mike182uk mike182uk force-pushed the BER-3484-add-portal-gift-route branch from af48e1f to 1cf895f Compare April 1, 2026 14:35
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

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)
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

📥 Commits

Reviewing files that changed from the base of the PR and between af48e1f and 1cf895f.

📒 Files selected for processing (7)
  • apps/portal/package.json
  • apps/portal/src/app.js
  • apps/portal/src/components/pages/gift-page.js
  • apps/portal/src/pages.js
  • apps/portal/src/utils/helpers.js
  • apps/portal/test/portal-links.test.js
  • apps/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

@mike182uk mike182uk merged commit de0cb4a into main Apr 1, 2026
35 checks passed
@mike182uk mike182uk deleted the BER-3484-add-portal-gift-route branch April 1, 2026 15:09
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