diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx index a6168620d14..ea89ce6b8ae 100644 --- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx +++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx @@ -19,7 +19,16 @@ import { ExternalLink, Plus } from 'lucide-react' import Link from 'next/link' import { useEffect, useState } from 'react' import type { Dictionary } from 'types' -import { Button, Checkbox, Input, SidePanel, Toggle } from 'ui' +import { + Button, + Checkbox, + Input, + SidePanel, + Toggle, + Tooltip, + TooltipContent, + TooltipTrigger, +} from 'ui' import { ActionBar } from '../ActionBar' import type { ForeignKey } from '../ForeignKeySelector/ForeignKeySelector.types' @@ -378,20 +387,49 @@ export const ColumnEditor = ({ label="Is Primary Key" descriptionText="A primary key indicates that a column or group of columns can be used as a unique identifier for rows in the table" checked={columnFields?.isPrimaryKey ?? false} - onChange={() => onUpdateField({ isPrimaryKey: !columnFields?.isPrimaryKey })} - /> - onUpdateField({ isNullable: !columnFields.isNullable })} - /> - onUpdateField({ isUnique: !columnFields.isUnique })} + onChange={() => + onUpdateField({ + isPrimaryKey: !columnFields?.isPrimaryKey, + isUnique: false, + isNullable: false, + }) + } /> + + + +
+ onUpdateField({ isNullable: !columnFields.isNullable })} + /> +
+
+ + Column is a primary key and hence cannot be NULL + +
+ + + +
+ onUpdateField({ isUnique: !columnFields.isUnique })} + /> +
+
+ + Column is a primary key and hence already unique + +
+ ) => void onRemoveColumn: () => void onEditForeignKey: (relation?: ForeignKey) => void } -const Column = ({ +export const Column = ({ column = EMPTY_OBJ as ColumnField, relations = EMPTY_ARR as ForeignKey[], enumTypes = EMPTY_ARR as EnumeratedType[], isNewRecord = false, hasForeignKeys = false, hasImportContent = false, - dragHandleProps = EMPTY_OBJ, + dragHandleProps, onUpdateColumn, onRemoveColumn, onEditForeignKey, @@ -125,7 +128,7 @@ const Column = ({ '[&>div>div>div>input]:py-1.5 [&>div>div>div>input]:border-r-transparent [&>div>div>div>input]:rounded-r-none', hasImportContent ? 'opacity-50' : '' )} - onChange={(event: any) => onUpdateColumn({ name: event.target.value })} + onChange={(event) => onUpdateColumn({ name: event.target.value })} /> {relations.filter((r) => !r.toRemove).length === 0 ? (