Files
supabase/apps/studio/components/ui/UpgradePlanButton.tsx
Charis d8f7cc0d57 feat(support form): attach dashboard logs (#39539)
* o11y: mirror and sanitize breadcrumbs

Mirror Sentry breadcrumbs as the basis for our own support logging. Also
adds more sanitization to breadcrumbs.

* feat(support form): toggle for attaching dashboard  logs

Add a toggle to the support form when the category is "Dashboard bug",
to attach recent dashboard logs. Users can preview the attached logs and
opt out.

* feat(support links): dedicated support link component

Add a new component for support links, which:
- Uses the serializer for support link params to ensure
serialization/deserialization pairs correctly
- Snapshots breadcrumbs so the attached log on the support form will be
cut off at the support link click (otherwise we will get support form
actions cluttering up the log)

* tests(support form): extend timeout on flaky test

* Minor clean up

* fix(support form): allow url to specifically indicate no specified project

* minor nits

* Fix tests

* Fix tests

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-10-22 08:57:49 -04:00

55 lines
1.7 KiB
TypeScript

import Link from 'next/link'
import { PropsWithChildren } from 'react'
import { SupportLink } from 'components/interfaces/Support/SupportLink'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { Button } from 'ui'
export const PLAN_REQUEST_EMPTY_PLACEHOLDER =
'<Specify which plan to upgrade to: Pro | Team | Enterprise>'
interface UpgradePlanButtonProps {
source?: string
type?: 'default' | 'primary'
plan?: 'Pro' | 'Team' | 'Enterprise'
href?: string // [Joshen] As an override if needed (Used in UpgradeToPro)
disabled?: boolean
}
export const UpgradePlanButton = ({
source,
type = 'default',
plan,
href: propsHref,
disabled,
children,
}: PropsWithChildren<UpgradePlanButtonProps>) => {
const { data: organization } = useSelectedOrganizationQuery()
const slug = organization?.slug ?? '_'
const { billingAll } = useIsFeatureEnabled(['billing:all'])
const subject = `Enquiry to upgrade ${!!plan ? `to ${plan} ` : ''}plan for organization`
const message = `Name: ${organization?.name}\nSlug: ${organization?.slug}\nRequested plan: ${plan ?? PLAN_REQUEST_EMPTY_PLACEHOLDER}`
const href = billingAll
? propsHref ??
`/org/${slug}/billing?panel=subscriptionPlan${!!source ? `&source=${source}` : ''}`
: ''
const linkChildren = children || `Upgrade to ${plan}`
const link = billingAll ? (
<Link href={href}>{linkChildren}</Link>
) : (
<SupportLink queryParams={{ orgSlug: slug, category: 'Plan_upgrade', subject, message }}>
{linkChildren}
</SupportLink>
)
return (
<Button asChild type={type} disabled={disabled}>
{link}
</Button>
)
}