Skip to content

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

Add support in row editor side panel to set nullable boolean column value to null

Joshen Lim17c367242753
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
index 508206a910b..8ce68a2e579 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
@@ -1,6 +1,6 @@
import { FC } from 'react'
import { isUndefined, includes } from 'lodash'
-import { Button, Select, Input, IconLink, IconArrowRight, IconEdit2 } from 'ui'
+import { Button, Select, Input, IconLink, IconArrowRight, IconEdit2, Toggle } from 'ui'
import { RowField } from './RowEditor.types'
import DateTimeInput from './DateTimeInput'
@@ -197,6 +197,42 @@ const InputField: FC<Props> = ({
)
}
+ if (field.format === 'bool') {
+ return (
+ <div className="text-sm grid gap-2 md:grid md:grid-cols-12">
+ <div className="flex flex-col space-y-2 col-span-4">
+ <label className="block text-scale-1100 text-sm">{field.name}</label>
+ <span className="text-scale-900 text-sm">{field.format}</span>
+ </div>
+ <div className="col-span-8 space-y-1">
+ <div className="flex items-center space-x-8">
+ <div className="flex items-center space-x-4">
+ <Toggle
+ checked={field.value === null ? false : field.value === 'true'}
+ // @ts-ignore
+ onChange={(value: boolean) =>
+ onUpdateField({ [field.name]: value ? 'true' : 'false' })
+ }
+ />
+ {field.value === null && <p className="text-sm text-scale-1000">NULL</p>}
+ </div>
+ {field.isNullable && (
+ <Button
+ type="default"
+ size="tiny"
+ disabled={field.value === null}
+ onClick={() => onUpdateField({ [field.name]: null })}
+ >
+ Set to NULL
+ </Button>
+ )}
+ </div>
+ {field.comment && <p className="text-scale-900">{field.comment}</p>}
+ </div>
+ </div>
+ )
+ }
+
return (
<Input
layout="horizontal"