Skip to content

Commit b552c5e

Browse files
authored
fix(data-modeling): handle corrupted diagrams on the list COMPASS-9945 (#7471)
1 parent 276dd38 commit b552c5e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/compass-data-modeling/src/components/saved-diagrams-list.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ const DiagramListEmptyContent: React.FunctionComponent<{
181181
);
182182
};
183183

184+
const getDatabase = (
185+
modelDescription: MongoDBDataModelDescription
186+
): string[] => {
187+
try {
188+
return selectCurrentModel(modelDescription.edits).collections.map(
189+
({ ns }) => toNS(ns).database
190+
);
191+
} catch {
192+
return [];
193+
}
194+
};
195+
184196
export const SavedDiagramsList: React.FunctionComponent<{
185197
onCreateDiagramClick: () => void;
186198
onOpenDiagramClick: (diagram: MongoDBDataModelDescription) => void;
@@ -201,11 +213,7 @@ export const SavedDiagramsList: React.FunctionComponent<{
201213
})[]
202214
>(() => {
203215
return items.map((item) => {
204-
const databases = new Set(
205-
selectCurrentModel(item.edits).collections.map(
206-
({ ns }) => toNS(ns).database
207-
)
208-
);
216+
const databases = new Set(getDatabase(item));
209217
return {
210218
...item,
211219
databases: Array.from(databases).join(', '),

0 commit comments

Comments
 (0)