Files
Charis 5986fecc89 fix(studio): use table + card component in log retention upgrade prompt (#48713)
## Summary
- Refactor the SQL Editor / Logs "Log retention" upgrade-prompt dialog
to use the design system's `Card` + `Table` components instead of a
custom flexbox-div table, matching the pattern in
`apps/design-system/registry/default/example/table-demo.tsx`
- No behavior or data change

Fixes FE-4034

Non-blocking review nit from #48452 (comment:
https://github.com/supabase/supabase/pull/48452#issuecomment-5128918096)

## Test plan
- [x] `pnpm --filter studio typecheck` passes
- [x] `pnpm --filter studio run lint:ratchet` passes (no new warnings)
- [x] Prettier check passes

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Style**
* Updated the upgrade prompt with a more consistent card and table
layout.
  * Preserved existing plan names and log retention details.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-04 16:01:14 -04:00

105 lines
3.1 KiB
TypeScript

import Link from 'next/link'
import {
Button,
Card,
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogSection,
DialogSectionSeparator,
DialogTitle,
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} 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>
<Card>
<Table>
<TableHeader>
<TableRow>
<TableHead>Plan</TableHead>
<TableHead>Retention duration</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>Free</TableCell>
<TableCell>{TIER_QUERY_LIMITS.FREE.text}</TableCell>
</TableRow>
<TableRow>
<TableCell>Pro</TableCell>
<TableCell>{TIER_QUERY_LIMITS.PRO.text}</TableCell>
</TableRow>
<TableRow>
<TableCell>Team</TableCell>
<TableCell>{TIER_QUERY_LIMITS.TEAM.text}</TableCell>
</TableRow>
<TableRow>
<TableCell>Enterprise</TableCell>
<TableCell>{TIER_QUERY_LIMITS.ENTERPRISE.text}</TableCell>
</TableRow>
</TableBody>
</Table>
</Card>
</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