mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
## Context Previous PR was [here](https://github.com/supabase/supabase/pull/45143) but it got stale with lots of conflicts so figured it'll be easier redo it off the latest master Moves policies page from Auth to Database under an Access Control section along with Roles. This moves all existing files, applies redirects, and updates urls to point to the new route <img width="274" height="412" alt="image" src="https://github.com/user-attachments/assets/7952c185-64ae-4355-ba36-45397efe1787" /> <img width="453" height="471" alt="image" src="https://github.com/user-attachments/assets/04b3dcb3-48a5-4049-9893-d01109fb46a9" /> ## To test - [ ] Verify that policies now live under Database correctly <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a quick navigation shortcut to open **Database > Policies (RLS)**. * **Bug Fixes** * Updated Policies and RLS-related links across the product to open the **Database policies** area (menus, command palette, context actions, alerts, and link-outs). * Added a permanent redirect from the old **auth policies** URL to the new **database policies** URL. * **Documentation** * Updated RLS Dashboard and security checklist instructions to reference **Database > Policies**. * **Tests** * Adjusted automated tests to validate the new Policies route. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
127 lines
4.7 KiB
TypeScript
127 lines
4.7 KiB
TypeScript
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 (
|
|
<div className="bg-surface-300 pt-2 pb-1">
|
|
<div className="flex items-center justify-between px-5 mb-1">
|
|
<div className="flex items-center">
|
|
<div className="pl-0.5 pr-5 flex items-center justify-center">
|
|
<Lock size={14} className="text-foreground-lighter" />
|
|
</div>
|
|
<p className="text-xs text-foreground-lighter font-mono uppercase">
|
|
Use options above to edit
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">1</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">{isEditing ? 'alter' : 'create'}</span> policy "
|
|
{isRenamingPolicy ? selectedPolicy?.name : name.length === 0 ? 'policy_name' : name}"
|
|
</p>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">2</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">on</span> "{schema}"."
|
|
{table}"
|
|
</p>
|
|
</div>
|
|
{!isEditing && (
|
|
<>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">3</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">as</span> {behavior.toLocaleUpperCase()}
|
|
</p>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">4</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">for</span> {command.toLocaleUpperCase()}
|
|
</p>
|
|
</div>
|
|
</>
|
|
)}
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">5</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">to</span> {roles.length === 0 ? 'public' : roles}
|
|
</p>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">6</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">{command === 'insert' ? 'with check' : 'using'}</span>{' '}
|
|
<span className="text-[#ffd700]">(</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const LockedRenameQuerySection = ({
|
|
oldName,
|
|
newName,
|
|
schema,
|
|
table,
|
|
lineNumber,
|
|
}: {
|
|
oldName: string
|
|
newName: string
|
|
schema: string
|
|
table: string
|
|
lineNumber: number
|
|
}) => {
|
|
return (
|
|
<div className="bg-surface-300 py-1">
|
|
<div className="flex items-center" style={{ fontSize: '14px' }}>
|
|
<div className="w-[57px]">
|
|
<p className="w-[31px] flex justify-end font-mono text-sm text-foreground-light select-none">
|
|
{lineNumber}
|
|
</p>
|
|
</div>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">alter</span> policy "{oldName}"
|
|
</p>
|
|
</div>
|
|
<div className="flex items-center" style={{ fontSize: '14px' }}>
|
|
<div className="w-[57px]">
|
|
<p className="w-[31px] flex justify-end font-mono text-sm text-foreground-light select-none">
|
|
{lineNumber + 1}
|
|
</p>
|
|
</div>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">on</span> "{schema}"."{table}"
|
|
</p>
|
|
</div>
|
|
<div className="flex items-center" style={{ fontSize: '14px' }}>
|
|
<div className="w-[57px]">
|
|
<p className="w-[31px] flex justify-end font-mono text-sm text-foreground-light select-none">
|
|
{lineNumber + 2}
|
|
</p>
|
|
</div>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">rename</span> to "{newName}";
|
|
</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|