diff --git a/src/features/instance/applications/components/SchemaEditorView/FieldRow.tsx b/src/features/instance/applications/components/SchemaEditorView/FieldRow.tsx index 5a31b374e..0c52a97d5 100644 --- a/src/features/instance/applications/components/SchemaEditorView/FieldRow.tsx +++ b/src/features/instance/applications/components/SchemaEditorView/FieldRow.tsx @@ -41,12 +41,15 @@ export function FieldRow({ field, typeNames, readOnly, + disableRemove, onChange, onRemove, }: { field: FieldModel; typeNames: string[]; readOnly: boolean; + /** True when this is the table's only field: a GraphQL type needs at least one, so removal is blocked. */ + disableRemove?: boolean; onChange: (field: FieldModel) => void; onRemove: () => void; }) { @@ -107,9 +110,9 @@ export function FieldRow({ variant="destructiveGhost" size="icon" className="self-end" - disabled={readOnly} + disabled={readOnly || disableRemove} onClick={onRemove} - title="Remove field" + title={disableRemove ? 'A table needs at least one field' : 'Remove field'} > diff --git a/src/features/instance/applications/components/SchemaEditorView/TableCard.tsx b/src/features/instance/applications/components/SchemaEditorView/TableCard.tsx index bed3a4fe3..aa89fefd7 100644 --- a/src/features/instance/applications/components/SchemaEditorView/TableCard.tsx +++ b/src/features/instance/applications/components/SchemaEditorView/TableCard.tsx @@ -89,6 +89,7 @@ export function TableCard({ {fieldCount} field{fieldCount === 1 ? '' : 's'} {exported ? ' · REST' : ''} {nameError ? ' · ⚠ invalid name' : ''} + {fieldCount === 0 ? ' · ⚠ needs a field' : ''}