Skip to content

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

Pull master and resolve conflicts

Joshen Limcf18386cf141
diff --cc studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
index ce96a02b2f0,699e8e99ae0..74e3874d749
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
@@@ -26,59 -24,26 +26,59 @@@ const InputField: FC<Props> = (
onViewForeignKey = () => {},
}) => {
if (field.enums.length > 0) {
- return (
- <Select
- size="medium"
- layout="horizontal"
- value={field.value ?? ''}
- label={field.name}
- labelOptional={field.format}
- descriptionText={field.comment}
- disabled={!isEditable}
- error={errors[field.name]}
- onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}
- >
- <Select.Option value="">---</Select.Option>
- {field.enums.map((value: string) => (
- <Select.Option key={value} value={value}>
- {value}
- </Select.Option>
- ))}
- </Select>
- )
+ const isArray = field.format[0] === '_'
+
+ if (isArray) {
- const formattedValue = convertPgArrayToJsArray(field.value)
++ const formattedValue = convertPgArrayToJsArray(field?.value ?? '')
+ const options = field.enums.map((value: string) => {
+ return { id: uuidv4(), value, name: value, disabled: false }
+ })
+ return (
+ <div className="grid gap-x-2 md:grid-cols-12 md:gap-x-4">
+ <div className="col-span-4">
+ <label className="block text-scale-1100 text-sm break-all">{field.name}</label>
+ <span className="text-scale-900 text-sm" id="-optional">
+ {field.format}
+ </span>
+ </div>
+ <div className="col-span-8">
+ <MultiSelect
+ allowDuplicateSelection
+ options={options}
+ value={formattedValue}
+ searchPlaceholder="Search for a value"
+ placeholder="NULL"
+ error={errors[field.name]}
+ onChange={(values) => {
+ const formattedValues = convertJsArraytoPgArray(values)
+ onUpdateField({ [field.name]: formattedValues })
+ }}
+ />
+ </div>
+ </div>
+ )
+ } else {
+ return (
+ <Select
+ size="medium"
+ layout="horizontal"
- value={field.value}
++ value={field.value ?? ''}
+ label={field.name}
+ labelOptional={field.format}
+ descriptionText={field.comment}
+ disabled={!isEditable}
+ error={errors[field.name]}
+ onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}
+ >
+ <Select.Option value="">---</Select.Option>
+ {field.enums.map((value: string) => (
+ <Select.Option key={value} value={value}>
+ {value}
+ </Select.Option>
+ ))}
+ </Select>
+ )
+ }
}
if (!isUndefined(field.foreignKey)) {
diff --cc studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts
index cd8cb9f3bce,942be27d3d3..565bdf89b14
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts
@@@ -60,11 -60,18 +60,11 @@@ export const generateRowFields =
export const validateFields = (fields: RowField[]) => {
const errors = {} as any
fields.forEach((field) => {
- if (field.format.includes('json') && field.value?.length > 0) {
- if (field.format.startsWith('_') && (field.value?.length ?? 0) > 0) {
- try {
- minifyJSON(field.value ?? '')
- } catch {
- errors[field.name] = 'Invalid array'
- }
- }
+ if (field.format.includes('json') && (field.value?.length ?? 0) > 0) {
try {
- minifyJSON(field.value)
+ minifyJSON(field.value ?? '')
} catch {
- errors[field.name] = 'Invalid JSON'
+ errors[field.name] = 'Value is an invalid JSON'
}
}
if (field.isIdentity || field.defaultValue) return