@@ -9,7 +9,6 @@ import { connect } from 'react-redux';
99import type { MongoDBJSONSchema } from 'mongodb-schema' ;
1010import type { DataModelingState } from '../store/reducer' ;
1111import {
12- applyEdit ,
1312 applyInitialLayout ,
1413 moveCollection ,
1514 getCurrentDiagramFromState ,
@@ -24,11 +23,8 @@ import {
2423 css ,
2524 spacing ,
2625 Button ,
27- palette ,
28- ErrorSummary ,
2926 useDarkMode ,
3027} from '@mongodb-js/compass-components' ;
31- import { CodemirrorMultilineEditor } from '@mongodb-js/compass-editor' ;
3228import { cancelAnalysis , retryAnalysis } from '../store/analysis-process' ;
3329import {
3430 Diagram ,
@@ -37,8 +33,7 @@ import {
3733 useDiagram ,
3834 applyLayout ,
3935} from '@mongodb-js/diagramming' ;
40- import type { Edit , StaticModel } from '../services/data-model-storage' ;
41- import { UUID } from 'bson' ;
36+ import type { StaticModel } from '../services/data-model-storage' ;
4237import DiagramEditorToolbar from './diagram-editor-toolbar' ;
4338import ExportDiagramModal from './export-diagram-modal' ;
4439import { useLogger } from '@mongodb-js/compass-logging/provider' ;
@@ -120,31 +115,6 @@ const modelPreviewStyles = css({
120115 minHeight : 0 ,
121116} ) ;
122117
123- const editorContainerStyles = css ( {
124- display : 'flex' ,
125- flexDirection : 'column' ,
126- gap : 8 ,
127- boxShadow : `0 0 0 2px ${ palette . gray . light2 } ` ,
128- } ) ;
129-
130- const editorContainerApplyContainerStyles = css ( {
131- padding : spacing [ 200 ] ,
132- justifyContent : 'flex-end' ,
133- gap : spacing [ 200 ] ,
134- display : 'flex' ,
135- width : '100%' ,
136- alignItems : 'center' ,
137- } ) ;
138-
139- const editorContainerPlaceholderButtonStyles = css ( {
140- paddingLeft : 8 ,
141- paddingRight : 8 ,
142- alignSelf : 'flex-start' ,
143- display : 'flex' ,
144- gap : spacing [ 200 ] ,
145- paddingTop : spacing [ 200 ] ,
146- } ) ;
147-
148118const DiagramEditor : React . FunctionComponent < {
149119 diagramLabel : string ;
150120 step : DataModelingState [ 'step' ] ;
@@ -180,54 +150,6 @@ const DiagramEditor: React.FunctionComponent<{
180150 [ diagram ]
181151 ) ;
182152
183- const [ applyInput , setApplyInput ] = useState ( '{}' ) ;
184-
185- const isEditValid = useMemo ( ( ) => {
186- try {
187- JSON . parse ( applyInput ) ;
188- return true ;
189- } catch {
190- return false ;
191- }
192- } , [ applyInput ] ) ;
193-
194- const applyPlaceholder =
195- ( type : 'AddRelationship' | 'RemoveRelationship' ) => ( ) => {
196- let placeholder = { } ;
197- switch ( type ) {
198- case 'AddRelationship' :
199- placeholder = {
200- type : 'AddRelationship' ,
201- relationship : {
202- id : new UUID ( ) . toString ( ) ,
203- relationship : [
204- {
205- ns : 'db.sourceCollection' ,
206- cardinality : 1 ,
207- fields : [ 'field1' ] ,
208- } ,
209- {
210- ns : 'db.targetCollection' ,
211- cardinality : 1 ,
212- fields : [ 'field2' ] ,
213- } ,
214- ] ,
215- isInferred : false ,
216- } ,
217- } ;
218- break ;
219- case 'RemoveRelationship' :
220- placeholder = {
221- type : 'RemoveRelationship' ,
222- relationshipId : new UUID ( ) . toString ( ) ,
223- } ;
224- break ;
225- default :
226- throw new Error ( `Unknown placeholder ${ type } ` ) ;
227- }
228- setApplyInput ( JSON . stringify ( placeholder , null , 2 ) ) ;
229- } ;
230-
231153 const edges = useMemo ( ( ) => {
232154 return ( model ?. relationships ?? [ ] ) . map ( ( relationship ) : EdgeProps => {
233155 const [ source , target ] = relationship . relationship ;
@@ -357,29 +279,9 @@ const DiagramEditor: React.FunctionComponent<{
357279 maxZoom : 1 ,
358280 minZoom : 0.25 ,
359281 } }
360- onSelectionChange = { ( { nodes } ) => {
361- console . log ( 'SELECTION CHANGE' , nodes ) ;
362- } }
363- onNodeDrag = { ( evt , node ) => {
364- console . log ( 'NODE DRAG' , node ) ;
365- // onMoveCollection(node.id, [node.position.x, node.position.y]);
366- } }
367282 onNodeDragStop = { ( evt , node ) => {
368- console . log ( 'NODE DRAG STOP' , node ) ;
369283 onMoveCollection ( node . id , [ node . position . x , node . position . y ] ) ;
370284 } }
371- onEdgeClick = { ( evt , edge ) => {
372- setApplyInput (
373- JSON . stringify (
374- {
375- type : 'RemoveRelationship' ,
376- relationshipId : edge . id ,
377- } ,
378- null ,
379- 2
380- )
381- ) ;
382- } }
383285 />
384286 </ div >
385287 </ div >
0 commit comments