diff --git a/apps/studio/components/interfaces/Auth/Policies/Policies.tsx b/apps/studio/components/interfaces/Auth/Policies/Policies.tsx
index 047b511de69..59382c015e3 100644
--- a/apps/studio/components/interfaces/Auth/Policies/Policies.tsx
+++ b/apps/studio/components/interfaces/Auth/Policies/Policies.tsx
@@ -1,7 +1,6 @@
import type { PostgresPolicy } from '@supabase/postgres-meta'
import { isEmpty } from 'lodash'
-import { HelpCircle } from 'lucide-react'
-import { useRouter } from 'next/router'
+import Link from 'next/link'
import { useState } from 'react'
import { toast } from 'sonner'
@@ -11,32 +10,34 @@ import {
PolicyTableRowProps,
} from 'components/interfaces/Auth/Policies/PolicyTableRow'
import { ProtectedSchemaWarning } from 'components/interfaces/Database/ProtectedSchemaWarning'
-import NoSearchResults from 'components/to-be-cleaned/NoSearchResults'
-import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
-import InformationBox from 'components/ui/InformationBox'
+import { NoSearchResults } from 'components/ui/NoSearchResults'
import { useDatabasePolicyDeleteMutation } from 'data/database-policies/database-policy-delete-mutation'
import { useTableUpdateMutation } from 'data/tables/table-update-mutation'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { Button, Card, CardContent } from 'ui'
import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'
interface PoliciesProps {
+ search?: string
schema: string
tables: PolicyTableRowProps['table'][]
hasTables: boolean
isLocked: boolean
onSelectCreatePolicy: (table: string) => void
onSelectEditPolicy: (policy: PostgresPolicy) => void
+ onResetSearch?: () => void
}
-const Policies = ({
+export const Policies = ({
+ search,
schema,
tables,
hasTables,
isLocked,
onSelectCreatePolicy,
onSelectEditPolicy: onSelectEditPolicyAI,
+ onResetSearch,
}: PoliciesProps) => {
- const router = useRouter()
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
@@ -115,40 +116,21 @@ const Policies = ({
})
}
- if (tables.length === 0) {
+ if (!hasTables) {
return (
-
- router.push(`/project/${ref}/editor`)}
- >
-
- }
- description={
-
-
- Policies restrict, on a per-user basis, which rows can be returned by normal
- queries, or inserted, updated, or deleted by data modification commands.
-
-
- This is also known as Row-Level Security (RLS). Each policy is attached to a
- table, and the policy is executed each time its accessed.
-
-
- }
- />
-
- Create a table in this schema first before creating a policy.
-
-
-
-
+
+
+
No tables to create policies for
+
+
+ RLS Policies control per-user access to table rows. Create a table in this schema first
+ before creating a policy.
+
+
+
{!isLocked && (
@@ -127,9 +120,9 @@ const PolicyRow = ({
name: `Update policy ${policy.name}`,
open: true,
sqlSnippets: [sql],
- initialInput: `Update the policy with name "${policy.name}" in the ${policy.schema} schema on the ${policy.table} table. It should...`,
+ initialInput: `Update the policy with name \"${policy.name}\" in the ${policy.schema} schema on the ${policy.table} table. It should...`,
suggestions: {
- title: `I can help you make a change to the policy "${policy.name}" in the ${policy.schema} schema on the ${policy.table} table, here are a few example prompts to get you started:`,
+ title: `I can help you make a change to the policy \"${policy.name}\" in the ${policy.schema} schema on the ${policy.table} table, here are a few example prompts to get you started:`,
prompts: [
{
label: 'Improve Policy',
@@ -169,8 +162,8 @@ const PolicyRow = ({
)}
-
-
+
+
)
}
diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx
index 6858191349a..dfa72075deb 100644
--- a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx
+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx
@@ -1,13 +1,13 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { noop } from 'lodash'
-import { Lock, Unlock } from 'lucide-react'
+import { Lock, Table } from 'lucide-react'
import { useParams } from 'common'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { EditorTablePageLink } from 'data/prefetchers/project.$ref.editor.$id'
import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions'
import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state'
-import { AiIconAnimation, Badge } from 'ui'
+import { AiIconAnimation, Badge, CardTitle } from 'ui'
interface PolicyTableRowHeaderProps {
table: {
@@ -54,28 +54,19 @@ const PolicyTableRowHeader = ({
- {table.rls_enabled ? (
-
-
-
- {isPubliclyReadableWritable ? 'Warning' : 'Note'}:
- {' '}
-
+
{isPubliclyReadableWritable
- ? 'Row Level Security is disabled. Your table is publicly readable and writable.'
- : 'Row Level Security is enabled, but no policies exist. No data will be selectable via Supabase APIs.'}
-
- {isPubliclyReadableWritable && (
-
-
-
-
-
- Anyone with the project's anonymous key can modify or delete your data. Enable RLS
- and create access policies to keep your data secure.
-
-
- )}
-
+ ? "Anyone with your project's anonymous key can read, modify, or delete your data."
+ : 'No data will be selectable via Supabase APIs because RLS is enabled but no policies have been created yet.'}
+
+
)}
+
{isLoading && (
-