Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Table Editor link to policies page use table name as search instead of ID (#40376)

Joshen Lim1f6ce0d096fa
diff --git a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
index 8edd24d7161..270a1d31fb5 100644
--- a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
@@ -267,7 +267,7 @@ export const GridHeaderActions = ({ table, isRefetching }: GridHeaderActionsProp
>
<Link
passHref
- href={`/project/${projectRef}/auth/policies?search=${table.id}&schema=${table.schema}`}
+ href={`/project/${projectRef}/auth/policies?search=${table.name}&schema=${table.schema}`}
>
Add RLS policy
</Link>
@@ -297,7 +297,7 @@ export const GridHeaderActions = ({ table, isRefetching }: GridHeaderActionsProp
>
<Link
passHref
- href={`/project/${projectRef}/auth/policies?search=${table.id}&schema=${table.schema}`}
+ href={`/project/${projectRef}/auth/policies?search=${table.name}&schema=${table.schema}`}
>
RLS {policies.length > 1 ? 'policies' : 'policy'}
</Link>
diff --git a/apps/studio/pages/project/[ref]/auth/policies.tsx b/apps/studio/pages/project/[ref]/auth/policies.tsx
index d5a939e2143..90b51957566 100644
--- a/apps/studio/pages/project/[ref]/auth/policies.tsx
+++ b/apps/studio/pages/project/[ref]/auth/policies.tsx
@@ -1,6 +1,6 @@
import type { PostgresPolicy, PostgresTable } from '@supabase/postgres-meta'
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { Search } from 'lucide-react'
+import { Search, X } from 'lucide-react'
import { parseAsString, useQueryState } from 'nuqs'
import { useCallback, useDeferredValue, useMemo, useState } from 'react'
@@ -30,6 +30,7 @@ import { DOCS_URL } from 'lib/constants'
import { useEditorPanelStateSnapshot } from 'state/editor-panel-state'
import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
import type { NextPageWithLayout } from 'types'
+import { Button } from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
/**
@@ -198,7 +199,18 @@ const AuthPoliciesPage: NextPageWithLayout = () => {
return (
<ScaffoldContainer size="large">
<ScaffoldSection isFullWidth>
- <div className="mb-4 flex flex-row gap-2 justify-between">
+ <div className="mb-4 flex flex-row gap-x-2">
+ <SchemaSelector
+ className="w-full lg:w-[180px]"
+ size="tiny"
+ align="end"
+ showError={false}
+ selectedSchemaName={schema}
+ onSelectSchema={(schemaName) => {
+ setSchema(schemaName)
+ setSearchString('')
+ }}
+ />
<Input
size="tiny"
placeholder="Filter tables and policies"
@@ -210,17 +222,17 @@ const AuthPoliciesPage: NextPageWithLayout = () => {
setSearchString(str)
}}
icon={<Search size={14} />}
- />
- <SchemaSelector
- className="w-full lg:w-[180px]"
- size="tiny"
- align="end"
- showError={false}
- selectedSchemaName={schema}
- onSelectSchema={(schemaName) => {
- setSchema(schemaName)
- setSearchString('')
- }}
+ actions={
+ searchString ? (
+ <Button
+ size="tiny"
+ type="text"
+ className="p-0 h-5 w-5"
+ icon={<X />}
+ onClick={() => setSearchString('')}
+ />
+ ) : null
+ }
/>
</div>