Skip to content

Commit 1f3eaaf

Browse files
committed
use default name for all relationships
1 parent 96757c6 commit 1f3eaaf

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

packages/compass-data-modeling/src/components/drawer/collection-drawer-content.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
updateCollectionNote,
1616
} from '../../store/diagram';
1717
import type { DataModelingState } from '../../store/reducer';
18-
import { getDefaultRelationshipName } from '../../utils';
1918
import {
2019
DMDrawerSection,
2120
DMFormFieldContainer,
@@ -141,7 +140,6 @@ const CollectionDrawerContent: React.FunctionComponent<
141140
<RelationshipsSection
142141
relationships={relationships}
143142
emptyMessage="This collection does not have any relationships yet."
144-
getRelationshipLabel={getDefaultRelationshipName}
145143
onCreateNewRelationshipClick={() => {
146144
onCreateNewRelationshipClick({ localNamespace: namespace });
147145
}}

packages/compass-data-modeling/src/components/drawer/diagram-editor-side-panel.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ describe('DiagramEditorSidePanel', function () {
350350

351351
// Open relationshipt editing form
352352
const relationshipItem = screen
353-
.getByText('airports.Country')
353+
.getByText('countries.name → airports.Country')
354354
.closest('li');
355355
expect(relationshipItem).to.be.visible;
356356
userEvent.click(
@@ -374,7 +374,7 @@ describe('DiagramEditorSidePanel', function () {
374374

375375
// Find the relationhip item
376376
const relationshipItem = screen
377-
.getByText('airports.Country')
377+
.getByText('countries.name → airports.Country')
378378
.closest('li');
379379
expect(relationshipItem).to.be.visible;
380380

packages/compass-data-modeling/src/components/drawer/field-drawer-content.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,6 @@ const FieldDrawerContent: React.FunctionComponent<FieldDrawerContentProps> = ({
164164
<RelationshipsSection
165165
relationships={relationships}
166166
emptyMessage="This field does not have any relationships yet."
167-
getRelationshipLabel={([local, foreign]) => {
168-
const labelField =
169-
local.ns === namespace &&
170-
local.fields &&
171-
areFieldPathsEqual(local.fields, fieldPath)
172-
? foreign
173-
: local;
174-
return [
175-
labelField.ns ? toNS(labelField.ns).collection : '',
176-
labelField.fields?.join('.'),
177-
].join('.');
178-
}}
179167
onCreateNewRelationshipClick={() => {
180168
onCreateNewRelationshipClick({
181169
localNamespace: namespace,

packages/compass-data-modeling/src/components/drawer/relationships-section.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
spacing,
1111
} from '@mongodb-js/compass-components';
1212
import type { Relationship } from '../../services/data-model-storage';
13+
import { getDefaultRelationshipName } from '../../utils';
1314

1415
const titleBtnStyles = css({
1516
marginLeft: 'auto',
@@ -47,7 +48,6 @@ const relationshipContentStyles = css({
4748
type RelationshipsSectionProps = {
4849
relationships: Relationship[];
4950
emptyMessage: string;
50-
getRelationshipLabel: (relationship: Relationship['relationship']) => string;
5151
onCreateNewRelationshipClick: () => void;
5252
onEditRelationshipClick: (rId: string) => void;
5353
onDeleteRelationshipClick: (rId: string) => void;
@@ -58,7 +58,6 @@ export const RelationshipsSection: React.FunctionComponent<
5858
> = ({
5959
relationships,
6060
emptyMessage,
61-
getRelationshipLabel,
6261
onCreateNewRelationshipClick,
6362
onEditRelationshipClick,
6463
onDeleteRelationshipClick,
@@ -85,7 +84,9 @@ export const RelationshipsSection: React.FunctionComponent<
8584
) : (
8685
<ul className={relationshipsListStyles}>
8786
{relationships.map((r) => {
88-
const relationshipLabel = getRelationshipLabel(r.relationship);
87+
const relationshipLabel = getDefaultRelationshipName(
88+
r.relationship
89+
);
8990

9091
return (
9192
<li

0 commit comments

Comments
 (0)