Skip to content

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

Add tooltips to using and with check expression in policy editor modal

Joshen Limdc48dd3da717
diff --git a/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyDefinition.tsx b/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyDefinition.tsx
index b43bc9a4b56..ac4ce0bc307 100644
--- a/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyDefinition.tsx
+++ b/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyDefinition.tsx
@@ -1,6 +1,8 @@
import { FC, useEffect } from 'react'
-import { usePrevious } from 'hooks'
+import { IconHelpCircle } from '@supabase/ui'
+import * as Tooltip from '@radix-ui/react-tooltip'
+import { usePrevious } from 'hooks'
import SqlEditor from 'components/ui/SqlEditor'
interface Props {
@@ -33,9 +35,38 @@ const PolicyDefinition: FC<Props> = ({
{showUsing(operation) && (
<div className="flex space-x-12">
<div className="flex w-1/3 flex-col space-y-2">
- <label className="text-scale-1100 text-base" htmlFor="policy-name">
- USING expression
- </label>
+ <div className="flex items-center space-x-2">
+ <label className="text-scale-1100 text-base" htmlFor="policy-name">
+ USING expression
+ </label>
+ <Tooltip.Root delayDuration={0}>
+ <Tooltip.Trigger>
+ <IconHelpCircle className="text-scale-1100" size={16} strokeWidth={1.5} />
+ </Tooltip.Trigger>
+ <Tooltip.Content side="bottom">
+ <Tooltip.Arrow className="radix-tooltip-arrow" />
+ <div
+ className={[
+ 'bg-scale-100 rounded py-1 px-2 leading-none shadow',
+ 'border-scale-200 border w-[300px] space-y-2',
+ ].join(' ')}
+ >
+ <p className="text-scale-1200 text-xs">
+ This expression will be added to queries that refer to the table if row-level
+ security is enabled.
+ </p>
+ <p className="text-scale-1200 text-xs">
+ Rows for which the expression returns true will be visible. Any rows for which
+ the expression returns false or null will not be visible to the user (in a
+ SELECT), and will not be available for modification (in an UPDATE or DELETE).
+ </p>
+ <p className="text-scale-1200 text-xs">
+ Such rows are silently suppressed - no error is reported.
+ </p>
+ </div>
+ </Tooltip.Content>
+ </Tooltip.Root>
+ </div>
<p className="text-scale-900 text-sm">
Provide a SQL conditional expression that returns a boolean.
</p>
@@ -48,9 +79,39 @@ const PolicyDefinition: FC<Props> = ({
{showCheck(operation) && (
<div className="flex space-x-12">
<div className="flex w-1/3 flex-col space-y-2">
- <label className="text-scale-1100 text-base" htmlFor="policy-name">
- WITH CHECK expression
- </label>
+ <div className="flex items-center space-x-2">
+ <label className="text-scale-1100 text-base" htmlFor="policy-name">
+ WITH CHECK expression
+ </label>
+ <Tooltip.Root delayDuration={0}>
+ <Tooltip.Trigger>
+ <IconHelpCircle className="text-scale-1100" size={16} strokeWidth={1.5} />
+ </Tooltip.Trigger>
+ <Tooltip.Content side="bottom">
+ <Tooltip.Arrow className="radix-tooltip-arrow" />
+ <div
+ className={[
+ 'bg-scale-100 rounded py-1 px-2 leading-none shadow',
+ 'border-scale-200 border w-[300px] space-y-2',
+ ].join(' ')}
+ >
+ <p className="text-scale-1200 text-xs">
+ This expression will be used in INSERT and UPDATE queries against the table if
+ row-level security is enabled.
+ </p>
+ <p className="text-scale-1200 text-xs">
+ Only rows for which the expression evaluates to true will be allowed. An error
+ will be thrown if the expression evaluates to false or null for any of the
+ records inserted or any of the records that result from the update.
+ </p>
+ <p className="text-scale-1200 text-xs">
+ Note that this expression is evaluated against the proposed new contents of
+ the row, not the original contents.
+ </p>
+ </div>
+ </Tooltip.Content>
+ </Tooltip.Root>
+ </div>
<p className="text-scale-900 text-sm">
Provide a SQL conditional expression that returns a boolean.
</p>