Files
Gildas GarciaandIvan Vasilov 96d43099bb chore: refactor Button API so that it can be used a standard button (#46880)
## Problem

Our `<Button>` component breaks the default `button` contract by
redefining the `type` prop to set its variant (`primary`, `default`,
etc) instead of the button type (`submit`, `button`, etc).
This is confusing and forces to write more code when using it with
shadcn components that expect/inject the standard button props.

## Solution

- rename the `type` prop to `variant`
- rename the `htmlType` prop to `type`
- propagate the changes where necessary
- format code

## How to test

As this is just prop renaming, if it builds it's ok

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-06-16 23:59:58 +02:00

63 lines
2.0 KiB
TypeScript

import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { Clock } from 'lucide-react'
import Link from 'next/link'
import { Button } from 'ui'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useAppStateSnapshot } from '@/state/app-state'
export const BranchingPITRNotice = () => {
const { ref } = useParams()
const snap = useAppStateSnapshot()
const { can: canUpdateSubscription } = useAsyncCheckPermissions(
PermissionAction.BILLING_WRITE,
'stripe.subscriptions'
)
return (
<div className="flex flex-row gap-4">
<div>
<figure className="w-10 h-10 rounded-md border flex items-center justify-center">
<Clock className="text-warning-700" size={20} strokeWidth={2} />
</figure>
</div>
<div className="flex grow items-center justify-between gap-4">
<div className="flex flex-col gap-y-1">
<p className="text-sm text-foreground">Consider enabling Point in Time Recovery (PITR)</p>
<p className="text-sm text-foreground-light">
This ensures you can recover production data if you merge a bad migration (e.g. delete a
column).
</p>
</div>
{!canUpdateSubscription ? (
<ButtonTooltip
disabled
size="tiny"
variant="default"
tooltip={{
content: {
side: 'bottom',
text: 'You need additional permissions to amend subscriptions',
},
}}
>
Enable PITR add-on
</ButtonTooltip>
) : (
<Button size="tiny" variant="default" asChild>
<Link
href={`/project/${ref}/settings/addons?panel=pitr`}
onClick={() => snap.setShowCreateBranchModal(false)}
>
Enable PITR
</Link>
</Button>
)}
</div>
</div>
)
}