The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Show the number of active policies in table editor and link directly to the table in the auth policies page
Joshen Limcfb986fc8ef5
diff --git a/studio/components/interfaces/Authentication/Policies/PolicyTableRow/PolicyTableRowHeader.tsx b/studio/components/interfaces/Authentication/Policies/PolicyTableRow/PolicyTableRowHeader.tsxindex 4fa0563d36f..ef84e01c1ab 100644--- a/studio/components/interfaces/Authentication/Policies/PolicyTableRow/PolicyTableRowHeader.tsx+++ b/studio/components/interfaces/Authentication/Policies/PolicyTableRow/PolicyTableRowHeader.tsx@@ -19,7 +19,7 @@ const PolicyTableRowHeader: FC<Props> = ({const { ref } = router.queryreturn (- <div className="flex w-full items-center justify-between">+ <div id={table.id.toString()} className="flex w-full items-center justify-between"><div className="flex space-x-4 text-left"><Link href={`/project/${ref}/editor/${table.id}`}><a>diff --git a/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx b/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsxindex f79f86b6d34..58347bd93be 100644--- a/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx+++ b/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx@@ -1,7 +1,8 @@import { FC } from 'react'import Link from 'next/link'import { Button, IconAlertCircle, IconLock } from '@supabase/ui'-import { PostgresTable } from '@supabase/postgres-meta'+import { PostgresPolicy, PostgresTable } from '@supabase/postgres-meta'+import { useStore } from 'hooks'interface Props {@@ -9,26 +10,28 @@ interface Props {}const GridHeaderActions: FC<Props> = ({ table }) => {- // Will need to import from a constants json of sorts- const { ui } = useStore()+ const { ui, meta } = useStore()const projectRef = ui.selectedProject?.ref- const urlToRLSPolicies = `/project/${projectRef}/auth/policies`+ const policies = meta.policies.list((policy: PostgresPolicy) => policy.table_id === table.id)return (<div className="space-x-3 flex items-center">- <Link href={urlToRLSPolicies}>- <Button- type={table.rls_enabled ? 'link' : 'warning'}- icon={- table.rls_enabled ? (- <IconLock strokeWidth={2} size={14} />- ) : (- <IconAlertCircle strokeWidth={2} size={14} />- )- }- >- RLS {table.rls_enabled ? 'is' : 'not'} enabled- </Button>+ <Link href={`/project/${projectRef}/auth/policies#${table.id}`}>+ <a>+ <Button+ type={table.rls_enabled ? 'link' : 'warning'}+ icon={+ table.rls_enabled ? (+ <IconLock strokeWidth={2} size={14} />+ ) : (+ <IconAlertCircle strokeWidth={2} size={14} />+ )+ }+ >+ {/* RLS {table.rls_enabled ? 'is' : 'not'} enabled */}+ {!table.rls_enabled ? 'RLS is not enabled' : `${policies.length} active RLS policies`}+ </Button>+ </a></Link></div>)diff --git a/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx b/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsxindex 1ab3f658cdd..aa6863c6300 100644--- a/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx+++ b/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx@@ -37,6 +37,7 @@ const TableEditorLayout: FC<Props> = ({meta.schemas.load()meta.tables.load()meta.types.load()+ meta.policies.load()meta.publications.load()}}, [ui.selectedProject])