Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 156 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/compass-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@lg-chat/leafygreen-chat-provider": "^5.0.2",
"@lg-chat/message": "^8.2.0",
"@mongodb-js/compass-context-menu": "^0.3.1",
"@mongodb-js/diagramming": "^2.2.1",
"@mongodb-js/diagramming": "^2.2.2",
"@react-aria/interactions": "^3.9.1",
"@react-aria/utils": "^3.13.1",
"@react-aria/visually-hidden": "^3.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
deleteRelationship,
removeField,
renameField,
changeFieldType,
toggleCollectionExpanded,
} from '../store/diagram';
import type {
Expand Down Expand Up @@ -60,6 +61,7 @@ import {
relationshipToDiagramEdge,
} from '../utils/nodes-and-edges';
import toNS from 'mongodb-ns';
import { FIELD_TYPES } from '../utils/field-types';
import { getNamespaceRelationships } from '../utils/utils';
import { usePreference } from 'compass-preferences-model/provider';

Expand Down Expand Up @@ -185,6 +187,12 @@ const DiagramContent: React.FunctionComponent<{
newName: string;
source: 'diagram';
}) => void;
onChangeFieldType: (data: {
ns: string;
fieldPath: FieldPath;
newTypes: string[];
source: 'diagram';
}) => void;
onDiagramBackgroundClicked: () => void;
onDeleteCollection: (ns: string) => void;
onDeleteRelationship: (rId: string) => void;
Expand Down Expand Up @@ -214,6 +222,7 @@ const DiagramContent: React.FunctionComponent<{
onRelationshipSelect,
onFieldSelect,
onRenameField,
onChangeFieldType,
onDiagramBackgroundClicked,
onCreateNewRelationship,
onRelationshipDrawn,
Expand Down Expand Up @@ -414,6 +423,18 @@ const DiagramContent: React.FunctionComponent<{
[onAddFieldToObjectField]
);

const onFieldTypeChange = useCallback(
(ns: string, fieldPath: FieldPath, newTypes: string[]) => {
onChangeFieldType({
ns,
fieldPath,
newTypes,
source: 'diagram',
});
},
[onChangeFieldType]
);

const deleteItem = useCallback(() => {
switch (selectedItems?.type) {
case 'collection':
Expand Down Expand Up @@ -463,11 +484,13 @@ const DiagramContent: React.FunctionComponent<{
onFieldClick,
onFieldNameChange: (ns, field, newName) =>
onRenameField({ ns, field, newName, source: 'diagram' }),
onFieldTypeChange,
onNodeDragStop,
onConnect,
onNodeExpandToggle: isCollapseFlagEnabled
? handleNodeExpandedToggle
: undefined,
fieldTypes: FIELD_TYPES,
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new fieldTypes prop being passed to the diagram is not covered by tests. Consider adding test coverage to verify that the field types are correctly passed and rendered in the diagram component.

Copilot uses AI. Check for mistakes.
} satisfies DiagramProps),
[
isDarkMode,
Expand All @@ -481,6 +504,7 @@ const DiagramContent: React.FunctionComponent<{
onEdgeClick,
onFieldClick,
onRenameField,
onFieldTypeChange,
onNodeDragStop,
onConnect,
handleNodeExpandedToggle,
Expand Down Expand Up @@ -547,6 +571,7 @@ const ConnectedDiagramContent = connect(
onRelationshipSelect: selectRelationship,
onFieldSelect: selectField,
onRenameField: renameField,
onChangeFieldType: changeFieldType,
onDiagramBackgroundClicked: selectBackground,
onCreateNewRelationship: createNewRelationship,
onDeleteCollection: deleteCollection,
Expand Down
Loading
Loading