Added gift subscriptions discovery section in membership settings#27982
Conversation
Mirrors the tips & donations pattern with a shareable link and preview/copy controls. Gated on the giftSubscriptions flag and Stripe being connected.
WalkthroughThis PR introduces gift subscriptions support to the admin settings. A new 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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
`@apps/admin-x-settings/src/components/settings/membership/gift-subscriptions.tsx`:
- Line 10: The current giftUrl construction uses siteData?.url directly and can
produce "undefined/..." if siteData or siteData.url is missing; update the logic
around giftUrl (the giftUrl constant) to defensively handle missing siteData by
either returning early from the component when siteData?.url is falsy or by
computing a safe baseUrl (e.g., const base = siteData?.url ?
siteData.url.replace(/\/$/, '') : window.location?.origin || '') and then
building giftUrl from that base; ensure you reference the giftUrl constant and
any early-return placement inside the component so copy/preview are disabled or
hidden when valid siteData is unavailable.
- Around line 12-16: The copyGiftUrl function should handle clipboard failures
and clear the timeout on unmount: make writeText usage async and wrap it in
try/catch (call navigator.clipboard.writeText(giftUrl) inside copyGiftUrl,
setCopied(true) only on success and log or surface an error on failure), store
the timeout id in a ref (e.g. copyTimeoutRef) instead of an ephemeral value,
call setTimeout to reset setCopied(false) and save its id, and add a useEffect
cleanup that clears the timeout via clearTimeout(copyTimeoutRef.current) when
the component unmounts so no dangling timers remain; update references to
copyGiftUrl, setCopied, and giftUrl accordingly.
🪄 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: 7333160a-941c-4b11-bd09-3ba1835bc997
⛔ Files ignored due to path filters (1)
apps/admin-x-design-system/src/assets/icons/gift.svgis excluded by!**/*.svg
📒 Files selected for processing (3)
apps/admin-x-settings/src/components/settings/membership/gift-subscriptions.tsxapps/admin-x-settings/src/components/settings/membership/membership-settings.tsxapps/admin-x-settings/src/components/sidebar.tsx
ref https://linear.app/ghost/issue/BER-3676/add-gift-subscriptions-discovery-link-in-settings
Mirrors the tips & donations pattern with a shareable link and preview/copy controls. Gated on the giftSubscriptions flag and Stripe being connected.