Skip to content

Commit f799ba0

Browse files
authored
fix: expanding an inactive connection triggers connect COMPASS-8060 (#5997)
1 parent bb41cfa commit f799ba0

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

packages/compass-connections-navigation/src/base-navigation-item.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { type NavigationItemActions } from './item-actions';
1313
type NavigationBaseItemProps = {
1414
name: string;
1515
isActive: boolean;
16-
canExpand: boolean;
16+
isExpandVisible: boolean;
17+
isExpandDisabled: boolean;
1718
isExpanded: boolean;
1819
isFocused: boolean;
1920
icon: React.ReactNode;
@@ -91,7 +92,8 @@ export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
9192
style,
9293
icon,
9394
dataAttributes,
94-
canExpand,
95+
isExpandVisible,
96+
isExpandDisabled,
9597
isExpanded,
9698
isFocused,
9799
onExpand,
@@ -106,9 +108,10 @@ export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
106108
{...dataAttributes}
107109
>
108110
<div className={cx('item-wrapper', itemWrapperStyles)} style={style}>
109-
{canExpand && (
111+
{isExpandVisible && (
110112
<ExpandButton
111113
onClick={(evt) => {
114+
if (isExpandDisabled) return;
112115
evt.stopPropagation();
113116
onExpand(!isExpanded);
114117
}}

packages/compass-connections-navigation/src/navigation-item.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ export function NavigationItem({
261261
name={item.name}
262262
style={style}
263263
dataAttributes={itemDataProps}
264-
canExpand={item.isExpandable}
264+
isExpandVisible={item.isExpandable}
265+
isExpandDisabled={
266+
item.type === 'connection' &&
267+
item.connectionStatus === 'disconnected'
268+
}
265269
onExpand={(isExpanded: boolean) => {
266270
onItemExpand(item, isExpanded);
267271
}}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,18 @@ describe('Multiple Connections Sidebar Component', function () {
619619
expect(disconnectSpy).to.be.calledWith(savedFavoriteConnection.id);
620620
});
621621

622+
it('should connect when the user tries to expand an inactive connection', async function () {
623+
const connectSpy = sinon.spy(connectionsManager, 'connect');
624+
await renderWithConnections();
625+
const connectionItem = screen.getByTestId(savedRecentConnection.id);
626+
627+
userEvent.click(
628+
within(connectionItem).getByLabelText('Caret Right Icon')
629+
);
630+
631+
expect(connectSpy).to.be.calledWith(savedRecentConnection);
632+
});
633+
622634
it('should open edit connection modal when clicked on edit connection action', function () {
623635
// note that we only click on non-connected item because for
624636
// connected item we cannot edit connection

0 commit comments

Comments
 (0)