Skip to content

Commit da7c6bd

Browse files
committed
fix: access connectionItem in a nested way
1 parent 0894ce4 commit da7c6bd

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

packages/compass-sidebar/src/components/multiple-connections/connections-navigation.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,20 @@ const ConnectionsNavigation: React.FC<ConnectionsNavigationProps> = ({
318318
const onItemAction = useCallback(
319319
(item: SidebarItem, action: Actions) => {
320320
const getConnectionInfo = (item: SidebarItem) => {
321-
if (item.type === 'connection') {
322-
return item.connectionInfo;
321+
switch (item.type) {
322+
case 'connection':
323+
return item.connectionInfo;
324+
case 'database':
325+
return item.connectionItem.connectionInfo;
326+
case 'view':
327+
case 'collection':
328+
case 'timeseries':
329+
return item.databaseItem.connectionItem.connectionInfo;
330+
default:
331+
throw new Error(
332+
`Item type does not have connection info for action ${action}`
333+
);
323334
}
324-
throw new Error(
325-
`Item type ${item.type} does not have connection info for action ${action}`
326-
);
327335
};
328336

329337
const getNamespace = (item: SidebarItem) => {
@@ -369,11 +377,7 @@ const ConnectionsNavigation: React.FC<ConnectionsNavigationProps> = ({
369377
track(
370378
'Open Shell',
371379
{ entrypoint: 'sidebar' },
372-
item.type === 'connection'
373-
? getConnectionInfo(item)
374-
: {
375-
id: connectionId,
376-
}
380+
getConnectionInfo(item)
377381
);
378382
return;
379383
}

0 commit comments

Comments
 (0)