Skip to content

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

Make both rls modals consistent

Terry Suttonb808664ff30c
diff --git a/studio/components/grid/components/header/RLSBannerWarning.tsx b/studio/components/grid/components/header/RLSBannerWarning.tsx
index a5862dd447f..d1ddda62903 100644
--- a/studio/components/grid/components/header/RLSBannerWarning.tsx
+++ b/studio/components/grid/components/header/RLSBannerWarning.tsx
@@ -1,20 +1,12 @@
import { useState } from 'react'
-import {
- Alert,
- Button,
- IconAlertCircle,
- IconBookOpen,
- IconExternalLink,
- IconUnlock,
- Modal,
-} from 'ui'
+import { Button, IconAlertCircle, Modal } from 'ui'
import Link from 'next/link'
import { useStore } from 'hooks'
import { useParams } from 'common/hooks'
import ConfirmationModal from 'components/ui/ConfirmationModal'
import type { PostgresTable } from '@supabase/postgres-meta'
-
-const RLS_ACKNOWLEDGED_KEY = 'supabase-acknowledge-rls-warning'
+import { RLS_ACKNOWLEDGED_KEY } from 'components/grid/constants'
+import RLSDisableModalContent from 'components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/RLSDisableModal'
export default function RLSBannerWarning() {
const { meta } = useStore()
@@ -60,50 +52,14 @@ export default function RLSBannerWarning() {
<ConfirmationModal
visible={isOpen}
- header="Confirm"
+ header="Turn off Row Level Security"
buttonLabel="Confirm"
size="medium"
onSelectCancel={() => setIsOpen(false)}
onSelectConfirm={handleDismissWarning}
children={
<Modal.Content>
- <div className="flex gap-4 my-6">
- <div>
- <div className="w-16 h-16 bg-scale-300 flex flex-col justify-center text-center items-center rounded-full">
- <IconUnlock strokeWidth={2} size={24} />
- </div>
- </div>
- <div className="text-sm text-scale-1100 grid gap-4">
- <div className="grid gap-1">
- <p>
- Row Level Security will be turned <u>off</u> for this table.
- </p>
-
- <Alert
- variant="warning"
- className="!px-4 !py-3 mt-3"
- title=" You are making this table public"
- >
- <p>
- Anyone with the anon key can modify or delete data. <br />
- We recommend using RLS policies to control access to your data.
- </p>
- </Alert>
- </div>
-
- <div className="mt-3">
- <p className="mt-2">
- <Link href="https://supabase.com/docs/guides/auth/row-level-security">
- <a target="_blank">
- <Button type="default" icon={<IconBookOpen strokeWidth={1.5} />}>
- RLS Documentation
- </Button>
- </a>
- </Link>
- </p>
- </div>
- </div>
- </div>
+ <RLSDisableModalContent />
</Modal.Content>
}
/>
diff --git a/studio/components/grid/constants.ts b/studio/components/grid/constants.ts
index 1f4b8caf92e..78a2b9ef20e 100644
--- a/studio/components/grid/constants.ts
+++ b/studio/components/grid/constants.ts
@@ -15,3 +15,5 @@ export const ADD_COLUMN_KEY = 'supabase-grid-add-column'
export const ERROR_PRIMARY_KEY_NOTFOUND =
'Please add a primary key column to your table to update or delete rows'
+
+export const RLS_ACKNOWLEDGED_KEY = 'supabase-acknowledge-rls-warning'
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/RLSDisableModal.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/RLSDisableModal.tsx
new file mode 100644
index 00000000000..48c2b1ebcf5
--- /dev/null
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/RLSDisableModal.tsx
@@ -0,0 +1,60 @@
+import Link from 'next/link'
+import React from 'react'
+import { Alert, Button, IconAlertOctagon, IconBookOpen, IconLock, IconShieldOff } from 'ui'
+
+export default function RLSDisableModalContent() {
+ return (
+ <div className="my-6">
+ <div className="text-sm text-scale-1100 grid gap-4">
+ <div className="grid gap-1">
+ <Alert
+ variant="warning"
+ className="!px-4 !py-3"
+ title="This table will be publicly readable and writable"
+ withIcon
+ >
+ <p>Anyone can edit or delete data in this table.</p>
+ </Alert>
+ <ul className="mt-4 space-y-5">
+ <li className="flex gap-3">
+ <IconAlertOctagon />
+ <span>All requests to this table will be accepted.</span>
+ </li>
+
+ <li className="flex gap-3">
+ <IconShieldOff />
+ <span>Auth policies will not be enforced.</span>
+ </li>
+
+ <li className="flex gap-3">
+ <IconLock w={14} className="flex-shrink-0" />
+ <div>
+ <strong>Before you turn off Row Level Security, consider:</strong>
+ <ul className="space-y-2 mt-2">
+ <li className="list-disc ml-4">
+ Any personal information in this table will be publicly accessible.
+ </li>
+ <li className="list-disc ml-4">
+ Anyone will be able to modify, add or delete any row in this table.
+ </li>
+ </ul>
+ </div>
+ </li>
+ </ul>
+ </div>
+
+ <div className="mt-3">
+ <p className="mt-2">
+ <Link href="https://supabase.com/docs/guides/auth/row-level-security">
+ <a target="_blank">
+ <Button type="default" icon={<IconBookOpen strokeWidth={1.5} />}>
+ RLS Documentation
+ </Button>
+ </a>
+ </Link>
+ </p>
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index 64015be2b58..8855532415e 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -33,6 +33,7 @@ import {
import { useForeignKeyConstraintsQuery } from 'data/database/foreign-key-constraints-query'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import ConfirmationModal from 'components/ui/ConfirmationModal'
+import RLSDisableModalContent from './RLSDisableModal'
interface Props {
table?: PostgresTable
@@ -360,60 +361,7 @@ const TableEditor: FC<Props> = ({
}}
children={
<Modal.Content>
- <div className="my-6">
- <div className="text-sm text-scale-1100 grid gap-4">
- <div className="grid gap-1">
- <Alert
- variant="warning"
- className="!px-4 !py-3"
- title="This table will be publicly readable and writable"
- withIcon
- >
- <p>Anyone can edit or delete data in this table.</p>
- </Alert>
- <ul className="mt-4 space-y-5">
- <li className="flex gap-3">
- <IconAlertOctagon />
- <span>All requests to this table will be accepted.</span>
- </li>
-
- <li className="flex gap-3">
- <IconShieldOff />
- <span>Auth policies will not be enforced.</span>
- </li>
-
- <li className="flex gap-3">
- <IconLock w={14} className="flex-shrink-0" />
- <div>
- <strong>Before you turn off Row Level Security, consider:</strong>
- <ul className="space-y-2 mt-2">
- <li className="list-disc ml-4">
- Any personal information in this table will be publicly
- accessible.
- </li>
- <li className="list-disc ml-4">
- Anyone will be able to modify, add or delete any row in this
- table.
- </li>
- </ul>
- </div>
- </li>
- </ul>
- </div>
-
- <div className="mt-3">
- <p className="mt-2">
- <Link href="https://supabase.com/docs/guides/auth/row-level-security">
- <a target="_blank">
- <Button type="default" icon={<IconBookOpen strokeWidth={1.5} />}>
- RLS Documentation
- </Button>
- </a>
- </Link>
- </p>
- </div>
- </div>
- </div>
+ <RLSDisableModalContent />
</Modal.Content>
}
/>