Skip to content

Commit 5ee336c

Browse files
committed
fix: bump diagramming lib COMPASS-9935
1 parent 0a863a8 commit 5ee336c

File tree

7 files changed

+170
-146
lines changed

7 files changed

+170
-146
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
# This Node.js version matches the one required in
55
# the "engines" in the package.json.
6-
nodejs 22.21.1
6+
nodejs 22.21.1

package-lock.json

Lines changed: 156 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"@lg-chat/leafygreen-chat-provider": "^5.0.2",
8686
"@lg-chat/message": "^8.2.0",
8787
"@mongodb-js/compass-context-menu": "^0.3.1",
88-
"@mongodb-js/diagramming": "^2.2.1",
88+
"@mongodb-js/diagramming": "^2.3.0",
8989
"@react-aria/interactions": "^3.9.1",
9090
"@react-aria/utils": "^3.13.1",
9191
"@react-aria/visually-hidden": "^3.3.1",

packages/compass-data-modeling/src/components/diagram-editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ const DiagramContent: React.FunctionComponent<{
280280
!!selectedItems &&
281281
selectedItems.type === 'relationship' &&
282282
selectedItems.id === relationship.id;
283-
return relationshipToDiagramEdge(relationship, selected, nodes);
283+
return relationshipToDiagramEdge(relationship, selected);
284284
});
285-
}, [model?.relationships, selectedItems, nodes]);
285+
}, [model?.relationships, selectedItems]);
286286

287287
// Fit to view on initial mount
288288
useEffect(() => {

packages/compass-data-modeling/src/store/analysis-process.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async function getInitialLayout({
176176
});
177177
return await applyLayout({
178178
nodes,
179-
edges: relations.map((rel) => relationshipToDiagramEdge(rel, false, [])), // nodes are not important here
179+
edges: relations.map((rel) => relationshipToDiagramEdge(rel, false)),
180180
direction: hasRelations ? 'STAR' : 'RECTANGLE',
181181
});
182182
}

packages/compass-data-modeling/src/utils/nodes-and-edges.spec.ts

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
relationshipToDiagramEdge,
55
} from './nodes-and-edges';
66
import { type Relationship } from '../services/data-model-storage';
7-
import { type NodeProps } from '@mongodb-js/compass-components';
87

98
describe('getFieldsFromSchema', function () {
109
describe('flat schema', function () {
@@ -699,77 +698,24 @@ describe('relationshipToDiagramEdge', function () {
699698
note: 'Test relationship',
700699
};
701700

702-
const node: NodeProps = {
703-
id: relationship.relationship[0].ns!,
704-
title: 'Collection A',
705-
type: 'collection',
706-
position: { x: 0, y: 0 },
707-
fields: [],
708-
};
709-
710701
it('should forward basic properties', function () {
711702
const isSelected = true;
712-
const edge = relationshipToDiagramEdge(relationship, isSelected, []);
703+
const edge = relationshipToDiagramEdge(relationship, isSelected);
713704
expect(edge.id).to.equal(relationship.id);
714705
expect(edge.source).to.equal(relationship.relationship[0].ns);
715706
expect(edge.target).to.equal(relationship.relationship[1].ns);
716707
expect(edge.selected).to.equal(isSelected);
717708
});
718709

719710
it('should map cardinality to markers', function () {
720-
const edge = relationshipToDiagramEdge(relationship, false, []);
711+
const edge = relationshipToDiagramEdge(relationship, false);
721712
expect(edge.markerStart).to.equal('one');
722713
expect(edge.markerEnd).to.equal('many');
723714
});
724715

725-
it('should find field indices', function () {
726-
const nodes: NodeProps[] = [
727-
{
728-
...node,
729-
id: relationship.relationship[0].ns!,
730-
fields: [
731-
{
732-
id: ['otherPath'],
733-
name: 'fieldA', // same name but different path
734-
type: 'string',
735-
},
736-
{
737-
id: ['parent', 'otherField'], // same parent but different field
738-
name: 'otherField',
739-
type: 'string',
740-
},
741-
{
742-
id: relationship.relationship[0].fields as string[],
743-
name: 'fieldA',
744-
type: 'string',
745-
},
746-
],
747-
},
748-
{
749-
...node,
750-
id: relationship.relationship[1].ns!,
751-
fields: [
752-
{
753-
id: ['otherPath'],
754-
name: 'fieldB', // same name but different path
755-
type: 'string',
756-
},
757-
{
758-
id: relationship.relationship[1].fields as string[],
759-
name: 'fieldB',
760-
type: 'string',
761-
},
762-
{
763-
id: ['otherParent', 'otherField'], // same parent but different field
764-
name: 'otherField',
765-
type: 'string',
766-
},
767-
],
768-
},
769-
];
770-
771-
const edge = relationshipToDiagramEdge(relationship, false, nodes);
772-
expect(edge.sourceFieldIndex).to.equal(2);
773-
expect(edge.targetFieldIndex).to.equal(1);
716+
it('should map field ids', function () {
717+
const edge = relationshipToDiagramEdge(relationship, false);
718+
expect(edge.sourceFieldId).to.equal(relationship.relationship[0].fields);
719+
expect(edge.targetFieldId).to.equal(relationship.relationship[1].fields);
774720
});
775721
});

0 commit comments

Comments
 (0)