mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 04:45:08 +03:00
## Problem Some pages still use the old `<Alert>` component ## Solution - [x] Use the new `<Admonition>` - [x] Remove `<Alert>` ## Screenshots ### Table Editor - Disable RLS modal Before: <img width="582" height="527" alt="image" src="https://github.com/user-attachments/assets/bbc5b874-2569-4cd6-98c0-5edd5ac78e0f" /> After: <img width="543" height="505" alt="image" src="https://github.com/user-attachments/assets/bb1da899-2163-4b26-ba0b-74726e0cb5df" /> ### Organization Billing Before: <img width="1111" height="512" alt="image" src="https://github.com/user-attachments/assets/6fb410fb-9ac0-4fb7-8dde-e304ddee7ece" /> After: <img width="1103" height="531" alt="image" src="https://github.com/user-attachments/assets/6eda6ede-edc6-482f-ab9c-d085402cbd64" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Replaced Alert UIs with Admonition across billing, settings, storage, integrations, and editor interfaces. * Removed the deprecated AlphaPreview component. * **Chores** * Removed the Alert component from the UI library, including its styles, tests, and theme configuration. [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45797) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
154 lines
6.0 KiB
TypeScript
154 lines
6.0 KiB
TypeScript
import { PermissionAction, SupportCategories } from '@supabase/shared-types/out/constants'
|
|
import { useFlag, useParams } from 'common'
|
|
import Link from 'next/link'
|
|
import { Button } from 'ui'
|
|
import { Admonition } from 'ui-patterns/admonition'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { ProjectUpdateDisabledTooltip } from '../ProjectUpdateDisabledTooltip'
|
|
import { Restriction } from '../Restriction'
|
|
import { PlanUpdateSidePanel } from './PlanUpdateSidePanel'
|
|
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 { useOrgSettingsPageStateSnapshot } from '@/state/organization-settings'
|
|
|
|
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>
|
|
) : projectUpdateDisabled ? (
|
|
<Admonition
|
|
type="default"
|
|
layout="horizontal"
|
|
title={`Unable to update plan from ${planName}`}
|
|
description="We have temporarily disabled project and subscription changes - our
|
|
engineers are working on a fix."
|
|
/>
|
|
) : (
|
|
<Admonition
|
|
type="default"
|
|
layout="horizontal"
|
|
title={`Unable to update plan from ${planName}`}
|
|
description="Please contact us if you'd like to change your plan."
|
|
actions={
|
|
<Button asChild key="contact-support" type="default">
|
|
<SupportLink
|
|
queryParams={{
|
|
category: SupportCategories.SALES_ENQUIRY,
|
|
subject: `Change plan away from ${planName}`,
|
|
}}
|
|
>
|
|
Contact support
|
|
</SupportLink>
|
|
</Button>
|
|
}
|
|
/>
|
|
)}
|
|
</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
|