import type { PGPolicy } from '@supabase/pg-meta' import { Lock } from 'lucide-react' interface LockedCreateQuerySection { schema: string selectedPolicy?: PGPolicy isRenamingPolicy: boolean formFields: { name: string; table: string; behavior: string; command: string; roles: string } } export const LockedCreateQuerySection = ({ schema, isRenamingPolicy, selectedPolicy, formFields, }: LockedCreateQuerySection) => { const isEditing = selectedPolicy !== undefined const { name, table, behavior, command, roles } = formFields return (

Use options above to edit

1

{isEditing ? 'alter' : 'create'} policy " {isRenamingPolicy ? selectedPolicy?.name : name.length === 0 ? 'policy_name' : name}"

2

on "{schema}"." {table}"

{!isEditing && ( <>

3

as {behavior.toLocaleUpperCase()}

4

for {command.toLocaleUpperCase()}

)}

5

to {roles.length === 0 ? 'public' : roles}

6

{command === 'insert' ? 'with check' : 'using'}{' '} (

) } export const LockedRenameQuerySection = ({ oldName, newName, schema, table, lineNumber, }: { oldName: string newName: string schema: string table: string lineNumber: number }) => { return (

{lineNumber}

alter policy "{oldName}"

{lineNumber + 1}

on "{schema}"."{table}"

{lineNumber + 2}

rename to "{newName}";

) }