The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/null setting (#27443)
Terry Sutton55acb7214fb0
diff --git a/apps/studio/components/grid/components/common/BlockKeys.tsx b/apps/studio/components/grid/components/common/BlockKeys.tsxindex 72f5d84a0c0..aa7c9e48b7c 100644--- a/apps/studio/components/grid/components/common/BlockKeys.tsx+++ b/apps/studio/components/grid/components/common/BlockKeys.tsx@@ -6,6 +6,7 @@ interface BlockKeysProps {children: ReactNodeonEscape?: (value: string | null) => voidonEnter?: (value: string | null) => void+ ignoreOutsideClicks?: boolean}/**@@ -13,7 +14,13 @@ interface BlockKeysProps {* We use this with cell editor to allow editor component to handle keys.* Example: press enter to add newline on textEditor*/-export const BlockKeys = ({ value, children, onEscape, onEnter }: BlockKeysProps) => {+export const BlockKeys = ({+ value,+ children,+ onEscape,+ onEnter,+ ignoreOutsideClicks = false,+}: BlockKeysProps) => {const ref = useRef(null)const isClickedOutside = useClickedOutside(ref)@@ -37,6 +44,7 @@ export const BlockKeys = ({ value, children, onEscape, onEnter }: BlockKeysProps)useEffect(() => {+ if (ignoreOutsideClicks) returnif (isClickedOutside && onEnter !== undefined) onEnter(value)}, [isClickedOutside])diff --git a/apps/studio/components/grid/components/editor/TextEditor.tsx b/apps/studio/components/grid/components/editor/TextEditor.tsxindex 5d81fd3a40c..12547ecc864 100644--- a/apps/studio/components/grid/components/editor/TextEditor.tsx+++ b/apps/studio/components/grid/components/editor/TextEditor.tsx@@ -22,6 +22,7 @@ import { EmptyValue } from '../common/EmptyValue'import { MonacoEditor } from '../common/MonacoEditor'import { NullValue } from '../common/NullValue'import { TruncatedWarningOverlay } from './TruncatedWarningOverlay'+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'export const TextEditor = <TRow, TSummaryRow = unknown>({row,@@ -45,6 +46,7 @@ export const TextEditor = <TRow, TSummaryRow = unknown>({const initialValue = row[column.key as keyof TRow] as unknown as stringconst [isPopoverOpen, setIsPopoverOpen] = useState(true)const [value, setValue] = useState<string | null>(initialValue)+ const [isConfirmNextModalOpen, setIsConfirmNextModalOpen] = useState(false)const { mutate: getCellValue, isLoading, isSuccess } = useGetCellValueMutation()@@ -105,89 +107,108 @@ export const TextEditor = <TRow, TSummaryRow = unknown>({}return (- <Popover- open={isPopoverOpen}- side="bottom"- align="start"- sideOffset={-35}- className="rounded-none"- overlay={- isTruncated && !isSuccess ? (- <div- style={{ width: `${gridColumn?.width || column.width}px` }}- className="flex items-center justify-center flex-col relative"- >- <MonacoEditor- readOnly- onChange={() => {}}- width={`${gridColumn?.width || column.width}px`}- value={value ?? ''}- language="markdown"- />- <TruncatedWarningOverlay isLoading={isLoading} loadFullValue={loadFullValue} />- </div>- ) : (- <BlockKeys value={value} onEscape={cancelChanges} onEnter={saveChanges}>- <MonacoEditor- width={`${gridColumn?.width || column.width}px`}- value={value ?? ''}- readOnly={!isEditable}- onChange={onChange}- />- {isEditable && (- <div className="flex items-start justify-between p-2 bg-surface-200 space-x-2">- <div className="space-y-1">- <div className="flex items-center space-x-2">- <div className="px-1.5 py-[2.5px] rounded bg-surface-300 border border-strong flex items-center justify-center">- <span className="text-[10px]">⏎</span>+ <>+ <Popover+ open={isPopoverOpen}+ side="bottom"+ align="start"+ sideOffset={-35}+ className="rounded-none"+ overlay={+ isTruncated && !isSuccess ? (+ <div+ style={{ width: `${gridColumn?.width || column.width}px` }}+ className="flex items-center justify-center flex-col relative"+ >+ <MonacoEditor+ readOnly+ onChange={() => {}}+ width={`${gridColumn?.width || column.width}px`}+ value={value ?? ''}+ language="markdown"+ />+ <TruncatedWarningOverlay isLoading={isLoading} loadFullValue={loadFullValue} />+ </div>+ ) : (+ <BlockKeys+ value={value}+ onEscape={cancelChanges}+ onEnter={saveChanges}+ ignoreOutsideClicks={isConfirmNextModalOpen}+ >+ <MonacoEditor+ width={`${gridColumn?.width || column.width}px`}+ value={value ?? ''}+ readOnly={!isEditable}+ onChange={onChange}+ />+ {isEditable && (+ <div className="flex items-start justify-between p-2 bg-surface-200 space-x-2">+ <div className="space-y-1">+ <div className="flex items-center space-x-2">+ <div className="px-1.5 py-[2.5px] rounded bg-surface-300 border border-strong flex items-center justify-center">+ <span className="text-[10px]">⏎</span>+ </div>+ <p className="text-xs text-foreground-light">Save changes</p></div>- <p className="text-xs text-foreground-light">Save changes</p>- </div>- <div className="flex items-center space-x-2">- <div className="px-1 py-[2.5px] rounded bg-surface-300 border border-strong flex items-center justify-center">- <span className="text-[10px]">Esc</span>+ <div className="flex items-center space-x-2">+ <div className="px-1 py-[2.5px] rounded bg-surface-300 border border-strong flex items-center justify-center">+ <span className="text-[10px]">Esc</span>+ </div>+ <p className="text-xs text-foreground-light">Cancel changes</p></div>- <p className="text-xs text-foreground-light">Cancel changes</p></div>- </div>- <div className="flex flex-col items-end gap-y-1">- <Tooltip_Shadcn_>- <TooltipTrigger_Shadcn_ asChild>+ <div className="flex flex-col items-end gap-y-1">+ <Tooltip_Shadcn_>+ <TooltipTrigger_Shadcn_ asChild>+ <Button+ type="default"+ className="px-1"+ onClick={() => onSelectExpand()}+ icon={<Maximize size={12} strokeWidth={2} />}+ />+ </TooltipTrigger_Shadcn_>+ <TooltipContent_Shadcn_ side="bottom">Expand editor</TooltipContent_Shadcn_>+ </Tooltip_Shadcn_>+ {isNullable && (<Button+ size="tiny"type="default"- className="px-1"- onClick={() => onSelectExpand()}- icon={<Maximize size={12} strokeWidth={2} />}- />- </TooltipTrigger_Shadcn_>- <TooltipContent_Shadcn_ side="bottom">Expand editor</TooltipContent_Shadcn_>- </Tooltip_Shadcn_>- {isNullable && (- <Button- asChild- htmlType="button"- type="default"- size="tiny"- onClick={() => saveChanges(null)}- >- <div>Set to NULL</div>- </Button>- )}+ htmlType="button"+ onClick={() => setIsConfirmNextModalOpen(true)}+ >+ Set to NULL+ </Button>+ )}+ </div></div>- </div>- )}- </BlockKeys>- )- }- >- <div- className={`${- !!value && value.trim().length == 0 ? 'sb-grid-fill-container' : ''- } sb-grid-text-editor__trigger`}- onClick={() => setIsPopoverOpen(!isPopoverOpen)}+ )}+ </BlockKeys>+ )+ }+ >+ <div+ className={`${+ !!value && value.trim().length == 0 ? 'sb-grid-fill-container' : ''+ } sb-grid-text-editor__trigger`}+ onClick={() => setIsPopoverOpen(!isPopoverOpen)}+ >+ {value === null ? <NullValue /> : value === '' ? <EmptyValue /> : value}+ </div>+ </Popover>+ <ConfirmationModal+ visible={isConfirmNextModalOpen}+ title="Confirm setting value to NULL"+ confirmLabel="Confirm"+ onCancel={() => setIsConfirmNextModalOpen(false)}+ onConfirm={() => {+ saveChanges(null)+ }}>- {value === null ? <NullValue /> : value === '' ? <EmptyValue /> : value}- </div>- </Popover>+ <p className="text-sm text-foreground-light">+ Are you sure you wish to set this value to NULL? This action cannot be undone.+ </p>+ </ConfirmationModal>+ </>)}diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.tsindex a7f1b8c5456..f6e5fe4ae6d 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts@@ -74,7 +74,7 @@ export const validateFields = (fields: RowField[]) => {try {minifyJSON(field.value ?? '')} catch {- errors[field.name] = 'Value is an invalid JSON'+ errors[field.name] = 'Value is invalid JSON'}}if (field.isIdentity || field.defaultValue) return