mirror of
https://github.com/supabase/supabase.git
synced 2026-07-26 17:32:31 -04:00
96d43099bb
## 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>
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useParams } from 'common'
|
|
import { Calendar } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
|
|
import { getPITRRetentionDuration } from './PITR.utils'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import { FormPanel } from '@/components/ui/Forms/FormPanel'
|
|
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
|
|
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
|
|
export const PITRNotice = () => {
|
|
const { ref: projectRef } = useParams()
|
|
const { data: addonsResponse } = useProjectAddonsQuery({ projectRef })
|
|
const retentionPeriod = getPITRRetentionDuration(addonsResponse?.selected_addons ?? [])
|
|
|
|
const { can: canUpdateSubscription } = useAsyncCheckPermissions(
|
|
PermissionAction.BILLING_WRITE,
|
|
'stripe.subscriptions'
|
|
)
|
|
|
|
return (
|
|
<FormPanel
|
|
disabled={true}
|
|
footer={
|
|
<div className="flex items-center justify-between p-6">
|
|
<span className="text-sm text-foreground-light">
|
|
You can also increase your recovery retention period updating your PITR add-on
|
|
</span>
|
|
<ButtonTooltip
|
|
asChild
|
|
disabled={!canUpdateSubscription}
|
|
variant="default"
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: !canUpdateSubscription
|
|
? 'You need additional permissions to amend subscriptions'
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
<Link href={`/project/${projectRef}/settings/addons?panel=pitr`}>
|
|
Increase retention period
|
|
</Link>
|
|
</ButtonTooltip>
|
|
</div>
|
|
}
|
|
>
|
|
<div className="flex p-6 space-x-6">
|
|
<div className="flex items-center justify-center w-10 h-10 rounded-sm bg-border-strong">
|
|
<Calendar strokeWidth={2} />
|
|
</div>
|
|
<div className="space-y-2">
|
|
<p className="text-sm">Recovery retention period</p>
|
|
<p className="text-sm text-foreground-light">
|
|
Database changes are logged every <span className="text-foreground">2 minutes</span>,
|
|
with a total recovery period of up to{' '}
|
|
<span className="text-brand">{retentionPeriod} days</span>.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</FormPanel>
|
|
)
|
|
}
|