Files
supabase/apps/studio/components/interfaces/Settings/Logs/UpgradePrompt.tsx
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

94 lines
3.3 KiB
TypeScript

import Link from 'next/link'
import {
Button,
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogSection,
DialogSectionSeparator,
DialogTitle,
} from 'ui'
import { TIER_QUERY_LIMITS } from './Logs.constants'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
interface Props {
show: boolean
setShowUpgradePrompt: (value: boolean) => void
title?: string
description?: string
source?: string
}
/**
* @param show - whether to show the modal
* @param setShowUpgradePrompt - function to set the show state
* @param title - title of the modal
* @param description - description of the modal
* @param source - source of the upgrade prompt used to track the source of the upgrade prompt in the billing page
* @returns
*/
const UpgradePrompt: React.FC<Props> = ({
show,
setShowUpgradePrompt,
title = 'Log retention',
description = 'Logs can be retained up to a duration of 3 months depending on the plan that your project is on.',
source = 'logsRetentionUpgradePrompt',
}) => {
const { data: organization } = useSelectedOrganizationQuery()
return (
<Dialog open={show} onOpenChange={() => setShowUpgradePrompt(false)}>
<DialogContent size="medium">
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
<DialogSectionSeparator />
<DialogSection>
<div className="space-y-4">
<p className="text-sm">{description}</p>
<div className="border-control bg-surface-300 rounded-sm border">
<div className="flex items-center px-4 pt-2 pb-1">
<p className="text-foreground-light w-[40%] text-sm">Plan</p>
<p className="text-foreground-light w-[60%] text-sm">Retention duration</p>
</div>
<div className="py-1">
<div className="flex items-center px-4 py-1">
<p className="w-[40%] text-sm">Free</p>
<p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.FREE.text}</p>
</div>
<div className="flex items-center px-4 py-1">
<p className="w-[40%] text-sm">Pro</p>
<p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.PRO.text}</p>
</div>
<div className="flex items-center px-4 py-1">
<p className="w-[40%] text-sm">Team</p>
<p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.TEAM.text}</p>
</div>
<div className="flex items-center px-4 py-1">
<p className="w-[40%] text-sm">Enterprise</p>
<p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.ENTERPRISE.text}</p>
</div>
</div>
</div>
</div>
</DialogSection>
<DialogFooter className="flex justify-end gap-3">
<Button variant="default" onClick={() => setShowUpgradePrompt(false)}>
Close
</Button>
<Button asChild size="tiny">
<Link
href={`/org/${organization?.slug}/billing?panel=subscriptionPlan&source=${source}`}
>
Upgrade
</Link>
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
export default UpgradePrompt