File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed
packages/compass-data-modeling/src Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { getDefaultRelationshipName } from '../../utils';
2020import FieldDrawerContent from './field-drawer-content' ;
2121import type { FieldPath } from '../../services/data-model-storage' ;
2222import { getFieldFromSchema } from '../../utils/schema-traversal' ;
23+ import { isIdField } from '../../utils/utils' ;
2324
2425export const DATA_MODELING_DRAWER_ID = 'data-modeling-drawer' ;
2526
@@ -110,11 +111,15 @@ function DiagramEditorSidePanel({
110111 > </ FieldDrawerContent >
111112 ) ,
112113 actions : [
113- {
114- action : 'delete' ,
115- label : 'Delete Field' ,
116- icon : 'Trash' as const ,
117- } ,
114+ ...( ! isIdField ( selectedItems . fieldPath )
115+ ? [
116+ {
117+ action : 'delete' ,
118+ label : 'Delete Field' ,
119+ icon : 'Trash' as const ,
120+ } ,
121+ ]
122+ : [ ] ) ,
118123 ] ,
119124 handleAction : ( actionName : string ) => {
120125 if ( actionName === 'delete' ) {
Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ import {
2626import { useChangeOnBlur } from './use-change-on-blur' ;
2727import { RelationshipsSection } from './relationships-section' ;
2828import { getFieldFromSchema } from '../../utils/schema-traversal' ;
29- import { areFieldPathsEqual , isRelationshipOfAField } from '../../utils/utils' ;
29+ import {
30+ areFieldPathsEqual ,
31+ isIdField ,
32+ isRelationshipOfAField ,
33+ } from '../../utils/utils' ;
3034
3135type FieldDrawerContentProps = {
3236 namespace : string ;
@@ -138,6 +142,7 @@ const FieldDrawerContent: React.FunctionComponent<FieldDrawerContentProps> = ({
138142 < DMFormFieldContainer >
139143 < TextInput
140144 label = "Field name"
145+ disabled = { isIdField ( fieldPath ) }
141146 data-testid = "data-model-collection-drawer-name-input"
142147 sizeVariant = "small"
143148 value = { fieldName }
Original file line number Diff line number Diff line change 11import type { FieldPath , Relationship } from '../services/data-model-storage' ;
22
3+ export const isIdField = ( fieldPath : FieldPath ) : boolean =>
4+ fieldPath . length === 1 && fieldPath [ 0 ] === '_id' ;
5+
36export function areFieldPathsEqual (
47 fieldA : FieldPath ,
58 fieldB : FieldPath
You can’t perform that action at this time.
0 commit comments