import { Button, cn, Dialog, DialogContent, DialogDescription, DialogHeader, DialogSection, DialogSectionSeparator, DialogTitle, } from 'ui' import { Admonition } from 'ui-patterns' import { PotentialIssues } from './SQLEditor.types' import { DOCS_URL } from '@/lib/constants' interface RunQueryWarningModalProps { visible: boolean potentialIssues: PotentialIssues | undefined onCancel: () => void onConfirm: () => void onConfirmWithRLS?: () => void } export const RunQueryWarningModal = ({ visible, potentialIssues, onCancel, onConfirm, onConfirmWithRLS, }: RunQueryWarningModalProps) => { const { hasDestructiveOperations, hasUpdateWithoutWhere, hasAlterDatabasePreventConnection, createTablesMissingRLS, } = potentialIssues || {} const missingRLSTables = createTablesMissingRLS ?? [] const hasMissingRLS = missingRLSTables.length > 0 const issueCount = (hasDestructiveOperations ? 1 : 0) + (hasUpdateWithoutWhere ? 1 : 0) + (hasAlterDatabasePreventConnection ? 1 : 0) + (hasMissingRLS ? 1 : 0) return ( { if (!open) onCancel() }} > {`Potential issue${issueCount > 1 ? 's' : ''} detected with your query`} Review the warnings below before running this query. 1 ? 'The following potential issues have been detected:' : 'The following potential issue has been detected:' } description="Ensure that these are intentional before executing this query" className="border-x-0 rounded-none -mt-px" />
    {hasDestructiveOperations && (
  • Query has destructive operations Make sure you are not accidentally removing something important.
  • )} {hasUpdateWithoutWhere && (
  • Query uses update without a where clause Without a where clause, this could update all rows in the table.
  • )} {hasAlterDatabasePreventConnection && (
  • Query will prevent connections to your database The dashboard will no longer have access to your database, and you will need a direct connection to your database to reconfigure this setting
  • )} {hasMissingRLS && (
  • {missingRLSTables.length === 1 ? 'New table will not have Row Level Security enabled' : 'New tables will not have Row Level Security enabled'} Without RLS, any client using your project's anon or authenticated keys can read and write to{' '} {missingRLSTables.length === 1 ? ( {missingRLSTables[0].schema ? `${missingRLSTables[0].schema}.${missingRLSTables[0].tableName}` : missingRLSTables[0].tableName} ) : ( 'these tables' )} . Enable RLS and add policies before exposing this table via the API.{' '} Learn more .
  • )}

Please confirm that you would like to execute this query.

{hasMissingRLS && onConfirmWithRLS && ( )}
) }