CLSPreview.tsx57 lines · main
1import { useParams } from 'common'
2import Image from 'next/image'
3import { Alert, AlertDescription, AlertTitle, WarningIcon } from 'ui'
4
5import { Markdown } from '@/components/interfaces/Markdown'
6import { InlineLink } from '@/components/ui/InlineLink'
7import { useCustomContent } from '@/hooks/custom-content/useCustomContent'
8import { BASE_PATH, DOCS_URL } from '@/lib/constants'
9
10export const CLSPreview = () => {
11 const { ref } = useParams()
12
13 const { docsRowLevelSecurityGuidePath } = useCustomContent(['docs:row_level_security_guide_path'])
14
15 return (
16 <div className="flex flex-col gap-2">
17 <div className="mb-4 flex flex-col gap-y-2">
18 <Markdown
19 className="text-foreground-light max-w-full"
20 content={`[Postgres Column-Level Privileges](${DOCS_URL}/guides/auth/column-level-security) is a feature of Postgres that allows you to grant or revoke privileges on tables and columns based on user roles.`}
21 />
22 <Markdown
23 className="text-foreground-light max-w-full"
24 content={`This is an advanced feature and should be used with caution. Unless you have a very specific use case, we recommend just using [Row-Level Security](${DOCS_URL}${docsRowLevelSecurityGuidePath}).`}
25 />
26 <Alert variant="warning" className="mt-2">
27 <WarningIcon />
28 <AlertTitle>
29 Changes to column privileges will not be reflected in migrations when running{' '}
30 <code className="text-code-inline">briven db diff</code>.
31 </AlertTitle>
32 <AlertDescription>
33 Column privileges are not supported in the current version of the Briven CLI.
34 <br />
35 You will need to manually apply these changes to your database.
36 </AlertDescription>
37 </Alert>
38 </div>
39 <Image
40 src={`${BASE_PATH}/img/previews/cls-preview.png`}
41 width={1860}
42 height={970}
43 alt="api-docs-side-panel-preview"
44 className="rounded-sm border"
45 />
46 <div className="space-y-2 mt-4!">
47 <p className="text-sm">Enabling this preview will:</p>
48 <ul className="list-disc pl-6 text-sm text-foreground-light space-y-1">
49 <li>
50 Grant access to a new UI for granting and/or revoking column-level privileges{' '}
51 <InlineLink href={`/project/${ref}/database/column-privileges`}>here</InlineLink>.
52 </li>
53 </ul>
54 </div>
55 </div>
56 )
57}