@@ -8,7 +8,6 @@ import React, {
88import { connect } from 'react-redux' ;
99import type { DataModelingState } from '../store/reducer' ;
1010import {
11- applyEdit ,
1211 applyInitialLayout ,
1312 moveCollection ,
1413 getCurrentDiagramFromState ,
@@ -21,11 +20,8 @@ import {
2120 css ,
2221 spacing ,
2322 Button ,
24- palette ,
25- ErrorSummary ,
2623 useDarkMode ,
2724} from '@mongodb-js/compass-components' ;
28- import { CodemirrorMultilineEditor } from '@mongodb-js/compass-editor' ;
2925import { cancelAnalysis , retryAnalysis } from '../store/analysis-process' ;
3026import {
3127 Diagram ,
@@ -34,8 +30,7 @@ import {
3430 useDiagram ,
3531 applyLayout ,
3632} from '@mongodb-js/diagramming' ;
37- import type { Edit , StaticModel } from '../services/data-model-storage' ;
38- import { UUID } from 'bson' ;
33+ import type { StaticModel } from '../services/data-model-storage' ;
3934import DiagramEditorToolbar from './diagram-editor-toolbar' ;
4035import ExportDiagramModal from './export-diagram-modal' ;
4136import { useLogger } from '@mongodb-js/compass-logging/provider' ;
@@ -90,31 +85,6 @@ const modelPreviewStyles = css({
9085 minHeight : 0 ,
9186} ) ;
9287
93- const editorContainerStyles = css ( {
94- display : 'flex' ,
95- flexDirection : 'column' ,
96- gap : 8 ,
97- boxShadow : `0 0 0 2px ${ palette . gray . light2 } ` ,
98- } ) ;
99-
100- const editorContainerApplyContainerStyles = css ( {
101- padding : spacing [ 200 ] ,
102- justifyContent : 'flex-end' ,
103- gap : spacing [ 200 ] ,
104- display : 'flex' ,
105- width : '100%' ,
106- alignItems : 'center' ,
107- } ) ;
108-
109- const editorContainerPlaceholderButtonStyles = css ( {
110- paddingLeft : 8 ,
111- paddingRight : 8 ,
112- alignSelf : 'flex-start' ,
113- display : 'flex' ,
114- gap : spacing [ 200 ] ,
115- paddingTop : spacing [ 200 ] ,
116- } ) ;
117-
11888const DiagramEditor : React . FunctionComponent < {
11989 diagramLabel : string ;
12090 step : DataModelingState [ 'step' ] ;
@@ -150,54 +120,6 @@ const DiagramEditor: React.FunctionComponent<{
150120 [ diagram ]
151121 ) ;
152122
153- const [ applyInput , setApplyInput ] = useState ( '{}' ) ;
154-
155- const isEditValid = useMemo ( ( ) => {
156- try {
157- JSON . parse ( applyInput ) ;
158- return true ;
159- } catch {
160- return false ;
161- }
162- } , [ applyInput ] ) ;
163-
164- const applyPlaceholder =
165- ( type : 'AddRelationship' | 'RemoveRelationship' ) => ( ) => {
166- let placeholder = { } ;
167- switch ( type ) {
168- case 'AddRelationship' :
169- placeholder = {
170- type : 'AddRelationship' ,
171- relationship : {
172- id : new UUID ( ) . toString ( ) ,
173- relationship : [
174- {
175- ns : 'db.sourceCollection' ,
176- cardinality : 1 ,
177- fields : [ 'field1' ] ,
178- } ,
179- {
180- ns : 'db.targetCollection' ,
181- cardinality : 1 ,
182- fields : [ 'field2' ] ,
183- } ,
184- ] ,
185- isInferred : false ,
186- } ,
187- } ;
188- break ;
189- case 'RemoveRelationship' :
190- placeholder = {
191- type : 'RemoveRelationship' ,
192- relationshipId : new UUID ( ) . toString ( ) ,
193- } ;
194- break ;
195- default :
196- throw new Error ( `Unknown placeholder ${ type } ` ) ;
197- }
198- setApplyInput ( JSON . stringify ( placeholder , null , 2 ) ) ;
199- } ;
200-
201123 const edges = useMemo ( ( ) => {
202124 return ( model ?. relationships ?? [ ] ) . map ( ( relationship ) : EdgeProps => {
203125 const [ source , target ] = relationship . relationship ;
@@ -333,29 +255,9 @@ const DiagramEditor: React.FunctionComponent<{
333255 maxZoom : 1 ,
334256 minZoom : 0.25 ,
335257 } }
336- onSelectionChange = { ( { nodes } ) => {
337- console . log ( 'SELECTION CHANGE' , nodes ) ;
338- } }
339- onNodeDrag = { ( evt , node ) => {
340- console . log ( 'NODE DRAG' , node ) ;
341- // onMoveCollection(node.id, [node.position.x, node.position.y]);
342- } }
343258 onNodeDragStop = { ( evt , node ) => {
344- console . log ( 'NODE DRAG STOP' , node ) ;
345259 onMoveCollection ( node . id , [ node . position . x , node . position . y ] ) ;
346260 } }
347- onEdgeClick = { ( evt , edge ) => {
348- setApplyInput (
349- JSON . stringify (
350- {
351- type : 'RemoveRelationship' ,
352- relationshipId : edge . id ,
353- } ,
354- null ,
355- 2
356- )
357- ) ;
358- } }
359261 />
360262 </ div >
361263 </ div >
0 commit comments