mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 21:29:08 +03:00
## What kind of change does this PR introduce? UI clarification. ## What is the current behavior? Our messaging around the compatibility of: - Dedicated pooler - Shared pooler ...in conjunction with the following connection types: - IPv4 - IPv6 - Direct connection ...is hard to parse. ## What is the new behavior? Copywriting clarifications to all of the above. Plus: - Broader copywriting clarifications to `IPV4SidePanel` - Replace deprecated `Radio` component with `RadioGroupItem_Shadcn_` as the former has little-to-no visual difference between unselected and selected states - Fixed `SidePanel` header gap and button labelling ## Additional context | Before | After | | --- | --- | | <img width="1024" height="563" alt="AWS Healthy Toolshed Supabase-4587771A-83A2-40E8-845B-256CE7E1A7DB" src="https://github.com/user-attachments/assets/09591fa1-48b8-4f3c-aaef-733af8dbdc9a" /> | <img width="1024" height="563" alt="AWS Healthy Toolshed Supabase-D56A2209-7421-43C2-A7C1-6C6965B3F008" src="https://github.com/user-attachments/assets/13a05e51-02a5-486a-9549-4c5fe049c65a" /> | | <img width="1024" height="563" alt="Add ons Supabase-10CC55BC-C3D8-4E40-9F73-31FFE8D7F42A" src="https://github.com/user-attachments/assets/73e206dc-58a3-4356-8e31-cf2ad74383f8" /> | <img width="1024" height="563" alt="Add ons Supabase-6311B7FE-4291-4982-968E-5EDBA76DE519" src="https://github.com/user-attachments/assets/503667ef-9b36-4d62-9872-53ac6b32f56f" /> | --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
160 lines
6.2 KiB
TypeScript
160 lines
6.2 KiB
TypeScript
import { PermissionAction, SupportCategories } from '@supabase/shared-types/out/constants'
|
|
import { useFlag, useParams } from 'common'
|
|
import { SupportLink } from 'components/interfaces/Support/SupportLink'
|
|
import {
|
|
ScaffoldSection,
|
|
ScaffoldSectionContent,
|
|
ScaffoldSectionDetail,
|
|
} from 'components/layouts/Scaffold'
|
|
import AlertError from 'components/ui/AlertError'
|
|
import NoPermission from 'components/ui/NoPermission'
|
|
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
|
|
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
|
import Link from 'next/link'
|
|
import { useOrgSettingsPageStateSnapshot } from 'state/organization-settings'
|
|
import { Alert, Button } from 'ui'
|
|
import { Admonition } from 'ui-patterns'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { ProjectUpdateDisabledTooltip } from '../ProjectUpdateDisabledTooltip'
|
|
import { Restriction } from '../Restriction'
|
|
import { PlanUpdateSidePanel } from './PlanUpdateSidePanel'
|
|
|
|
const Subscription = () => {
|
|
const { slug } = useParams()
|
|
const snap = useOrgSettingsPageStateSnapshot()
|
|
const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
|
|
|
|
const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = useAsyncCheckPermissions(
|
|
PermissionAction.BILLING_READ,
|
|
'stripe.subscriptions'
|
|
)
|
|
|
|
const {
|
|
data: subscription,
|
|
error,
|
|
isPending: isLoading,
|
|
isError,
|
|
isSuccess,
|
|
} = useOrgSubscriptionQuery({ orgSlug: slug }, { enabled: canReadSubscriptions })
|
|
|
|
const currentPlan = subscription?.plan
|
|
const planName = currentPlan?.name ?? 'Unknown'
|
|
|
|
const canChangeTier =
|
|
!projectUpdateDisabled && !['enterprise', 'platform'].includes(currentPlan?.id ?? '')
|
|
|
|
return (
|
|
<>
|
|
<ScaffoldSection>
|
|
<div className="col-span-12 pb-2">
|
|
<Restriction />
|
|
</div>
|
|
<ScaffoldSectionDetail>
|
|
<div className="sticky space-y-6 top-12">
|
|
<div className="space-y-2 mb-4">
|
|
<p className="text-foreground text-base m-0">Subscription Plan</p>
|
|
<p className="text-sm text-foreground-light m-0">
|
|
Each organization has it's own subscription plan, billing cycle, payment methods and
|
|
usage quotas.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</ScaffoldSectionDetail>
|
|
<ScaffoldSectionContent>
|
|
{isPermissionsLoaded && !canReadSubscriptions ? (
|
|
<NoPermission resourceText="view this organization's subscription" />
|
|
) : (
|
|
<>
|
|
{isLoading && (
|
|
<div className="space-y-2">
|
|
<ShimmeringLoader />
|
|
<ShimmeringLoader className="w-3/4" />
|
|
<ShimmeringLoader className="w-1/2" />
|
|
</div>
|
|
)}
|
|
|
|
{isError && <AlertError subject="Failed to retrieve subscription" error={error} />}
|
|
|
|
{isSuccess && (
|
|
<div className="space-y-6">
|
|
<div>
|
|
<p className="text-2xl text-brand">{currentPlan?.name ?? 'Unknown'} Plan</p>
|
|
</div>
|
|
|
|
<div>
|
|
{canChangeTier && (
|
|
<ProjectUpdateDisabledTooltip projectUpdateDisabled={projectUpdateDisabled}>
|
|
<Button
|
|
type="default"
|
|
className="pointer-events-auto"
|
|
disabled={!canChangeTier}
|
|
onClick={() => snap.setPanelKey('subscriptionPlan')}
|
|
>
|
|
Change subscription plan
|
|
</Button>
|
|
</ProjectUpdateDisabledTooltip>
|
|
)}
|
|
{!canChangeTier &&
|
|
(projectUpdateDisabled ? (
|
|
<Alert
|
|
className="mt-2"
|
|
withIcon
|
|
variant="info"
|
|
title={`Unable to update plan from ${planName}`}
|
|
>
|
|
We have temporarily disabled project and subscription changes - our
|
|
engineers are working on a fix.
|
|
</Alert>
|
|
) : (
|
|
<Alert
|
|
withIcon
|
|
className="mt-2"
|
|
variant="info"
|
|
title={`Unable to update plan from ${planName}`}
|
|
actions={[
|
|
<Button asChild key="contact-support" type="default">
|
|
<SupportLink
|
|
queryParams={{
|
|
category: SupportCategories.SALES_ENQUIRY,
|
|
subject: `Change plan away from ${planName}`,
|
|
}}
|
|
>
|
|
Contact support
|
|
</SupportLink>
|
|
</Button>,
|
|
]}
|
|
>
|
|
Please contact us if you'd like to change your plan.
|
|
</Alert>
|
|
))}
|
|
</div>
|
|
|
|
{!subscription?.usage_billing_enabled && (
|
|
<Admonition
|
|
type="default"
|
|
title="This organization is limited by the included usage"
|
|
>
|
|
<div className="[&>p]:!leading-normal prose text-sm">
|
|
Projects may become unresponsive when this organization exceeds its{' '}
|
|
<Link href={`/org/${slug}/usage`}>included usage quota</Link>. To scale
|
|
seamlessly,{' '}
|
|
{currentPlan?.id === 'free'
|
|
? 'upgrade to a paid plan.'
|
|
: 'you can disable Spend Cap under the Cost Control settings.'}
|
|
</div>
|
|
</Admonition>
|
|
)}
|
|
</div>
|
|
)}
|
|
</>
|
|
)}
|
|
</ScaffoldSectionContent>
|
|
</ScaffoldSection>
|
|
<PlanUpdateSidePanel />
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default Subscription
|