Skip to content

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

feat: show toast if table name blank (#28172)

hallidayo789af2d53540
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
index ec127adad74..c767ee78a2c 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
@@ -12,6 +12,7 @@ import {
UpdateColumnPayload,
} from '../SidePanelEditor.types'
import type { RetrievedTableColumn, RetrieveTableResult } from 'data/tables/table-retrieve-query'
+import { toast } from 'sonner'
const isSQLExpression = (input: string) => {
if (['CURRENT_DATE'].includes(input)) return true
@@ -170,9 +171,11 @@ export const validateFields = (field: ColumnField) => {
const errors = {} as Dictionary<any>
if (field.name.length === 0) {
errors['name'] = `Please assign a name for your column`
+ toast.error(errors['name'])
}
if (field.format.length === 0) {
errors['format'] = `Please select a type for your column`
+ toast.error(errors['format'])
}
return errors
}
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
index 9c813d61bb2..dc918a77b07 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
@@ -66,6 +66,7 @@ const ColumnType = ({
description,
showRecommendation = false,
onOptionSelect = noop,
+ error,
}: ColumnTypeProps) => {
const [open, setOpen] = useState(false)
const availableTypes = POSTGRES_DATA_TYPES.concat(
@@ -167,7 +168,7 @@ const ColumnType = ({
<Popover_Shadcn_ open={open} onOpenChange={setOpen}>
<PopoverTrigger_Shadcn_ asChild>
<Button
- type="default"
+ type={error ? 'danger' : 'default'}
role="combobox"
size={'small'}
aria-expanded={open}
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index ad75a739860..1d60e546fc7 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -187,6 +187,10 @@ export const TableEditor = ({
const onSaveChanges = (resolve: any) => {
if (tableFields) {
const errors: any = validateFields(tableFields)
+ if (errors.name) {
+ toast.error(errors.name)
+ }
+
if (errors.columns) {
toast.error(errors.columns)
}