Skip to content

WIP: Changed Portal offer links to always open the offer page#28322

Open
kevinansfield wants to merge 1 commit into
mainfrom
portal-offer-links-always-open
Open

WIP: Changed Portal offer links to always open the offer page#28322
kevinansfield wants to merge 1 commit into
mainfrom
portal-offer-links-always-open

Conversation

@kevinansfield
Copy link
Copy Markdown
Member

Summary

  • changed Portal offer links to open the offer page even when the Portal button is disabled
  • kept checkout buttons on the direct checkout path
  • added handling for checkout responses that should continue into the sign-in email flow
  • added Portal context docs and root context map

Testing

  • CI=true pnpm --filter @tryghost/portal test -- actions.test.ts api.test.js signup-flow.test.js upgrade-flow.test.js data-attributes.test.js

no issue

Offer links should show the same Portal offer flow regardless of the Portal button setting, while checkout buttons continue to start checkout directly.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 84f2d98d-193e-431d-aca6-d577c81b61c1

📥 Commits

Reviewing files that changed from the base of the PR and between 6081172 and 66aeebe.

📒 Files selected for processing (11)
  • CONTEXT-MAP.md
  • apps/portal/CONTEXT.md
  • apps/portal/src/actions.js
  • apps/portal/src/app.js
  • apps/portal/src/components/pages/offer-page.js
  • apps/portal/src/utils/api.js
  • apps/portal/test/actions.test.ts
  • apps/portal/test/api.test.js
  • apps/portal/test/data-attributes.test.js
  • apps/portal/test/signup-flow.test.js
  • apps/portal/test/upgrade-flow.test.js

Walkthrough

This PR refactors Portal's offer-link behavior to streamline the code path and improve handling of existing subscriptions. The key changes include removing conditional portal-button logic to always open offer popups, implementing metadata-based upgrade marking for logged-in checkouts, and adding a dedicated error handler that redirects users with existing subscriptions to sign-in instead of retrying checkout. Newsletter selection is now skipped for authenticated users. API error responses now preserve error codes for better error classification. Comprehensive test updates verify the new behavior across data-attributes, signup, and upgrade flows.

Suggested reviewers

  • weylandswart
🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: Portal offer links now open the offer page instead of branching based on portal button state.
Description check ✅ Passed The description is directly related to the changeset, providing context on offer link behavior, checkout handling, and documentation additions that align with the code changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 portal-offer-links-always-open

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

@kevinansfield kevinansfield changed the title Changed Portal offer links to always open the offer page WIP: Changed Portal offer links to always open the offer page Jun 2, 2026
@kevinansfield kevinansfield marked this pull request as ready for review June 2, 2026 19:25
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: 66aeebee36

ℹ️ 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".

Comment on lines +212 to +214
if (e.code === CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION) {
return {
page: 'magiclink',
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 Avoid showing magic-link success for authenticated paid members

When an already-authenticated paid member hits a direct paid signup link (for example #/portal/signup/monthly), signup still calls checkout and the members API returns CANNOT_CHECKOUT_WITH_EXISTING_SUBSCRIPTION; in router-controller.js that path only sends a sign-in email for unauthenticated requests with an email, so no email is sent for the authenticated member. This new branch nevertheless switches Portal to the magic-link page with an empty email, telling the user to check their inbox instead of showing the checkout failure/account state.

Useful? React with 👍 / 👎.

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