Skip to content

Commit 1e2a63e

Browse files
committed
fix: adjust to rename and opening
1 parent da7c6bd commit 1e2a63e

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-connections-navigation/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@
4949
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
5050
},
5151
"dependencies": {
52-
"@mongodb-js/compass-connections": "^1.63.0",
5352
"@mongodb-js/compass-components": "^1.41.0",
54-
"@mongodb-js/connection-info": "^0.15.4",
55-
"@mongodb-js/connection-form": "^1.55.0",
53+
"@mongodb-js/compass-connections": "^1.63.0",
54+
"@mongodb-js/compass-context-menu": "^0.1.1",
5655
"@mongodb-js/compass-workspaces": "^0.44.0",
56+
"@mongodb-js/connection-form": "^1.55.0",
57+
"@mongodb-js/connection-info": "^0.15.4",
5758
"compass-preferences-model": "^2.43.0",
5859
"mongodb-build-info": "^1.7.2",
5960
"react": "^17.0.2",

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ButtonVariant,
2121
cx,
2222
Placeholder,
23+
useContextMenuItems,
2324
} from '@mongodb-js/compass-components';
2425
import { ConnectionsNavigationTree } from '@mongodb-js/compass-connections-navigation';
2526
import type { MapDispatchToProps, MapStateToProps } from 'react-redux';
@@ -507,6 +508,15 @@ const ConnectionsNavigation: React.FC<ConnectionsNavigationProps> = ({
507508
[onCollapseAll, onNewConnection, openConnectionImportExportModal]
508509
);
509510

511+
const contextMenuRef = useContextMenuItems(
512+
() =>
513+
connectionListTitleActions.map(({ label, action }) => ({
514+
label,
515+
onAction: () => onConnectionListTitleAction(action),
516+
})),
517+
[connectionListTitleActions, onConnectionListTitleAction]
518+
);
519+
510520
// auto-expanding on a workspace change
511521
useEffect(() => {
512522
if (
@@ -543,6 +553,7 @@ const ConnectionsNavigation: React.FC<ConnectionsNavigationProps> = ({
543553
<div
544554
className={connectionListHeaderStyles}
545555
data-testid="connections-header"
556+
ref={contextMenuRef}
546557
>
547558
<Subtitle className={connectionListHeaderTitleStyles}>
548559
{isAtlasConnectionStorage ? 'Clusters' : 'Connections'}

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,10 @@ describe('Multiple Connections Sidebar Component', function () {
358358
const favAction = screen.getByText('Unfavorite');
359359
expect(favAction).to.be.visible;
360360

361-
const duplicateAction = screen.getByText('Duplicate');
361+
const duplicateAction = screen.getByText('Duplicate connection');
362362
expect(duplicateAction).to.be.visible;
363363

364-
const removeAction = screen.getByText('Remove');
364+
const removeAction = screen.getByText('Remove connection');
365365
expect(removeAction).to.be.visible;
366366
});
367367

@@ -389,10 +389,10 @@ describe('Multiple Connections Sidebar Component', function () {
389389
const favAction = screen.getByText('Favorite');
390390
expect(favAction).to.be.visible;
391391

392-
const duplicateAction = screen.getByText('Duplicate');
392+
const duplicateAction = screen.getByText('Duplicate connection');
393393
expect(duplicateAction).to.be.visible;
394394

395-
const removeAction = screen.getByText('Remove');
395+
const removeAction = screen.getByText('Remove connection');
396396
expect(removeAction).to.be.visible;
397397
});
398398
});
@@ -438,8 +438,8 @@ describe('Multiple Connections Sidebar Component', function () {
438438
expect(screen.getByText('Copy connection string')).to.be.visible;
439439
// because it is already a favorite
440440
expect(screen.getByText('Unfavorite')).to.be.visible;
441-
expect(screen.getByText('Duplicate')).to.be.visible;
442-
expect(screen.getByText('Remove')).to.be.visible;
441+
expect(screen.getByText('Duplicate connection')).to.be.visible;
442+
expect(screen.getByText('Remove connection')).to.be.visible;
443443
});
444444

445445
it('should render the only connected connections when toggled', async () => {
@@ -511,7 +511,11 @@ describe('Multiple Connections Sidebar Component', function () {
511511

512512
expect(workspace.openShellWorkspace).to.have.been.calledWith(
513513
savedFavoriteConnection.id,
514-
{ newTab: true }
514+
{
515+
newTab: true,
516+
initialEvaluate: undefined,
517+
initialInput: undefined,
518+
}
515519
);
516520

517521
await waitFor(() => {
@@ -652,7 +656,7 @@ describe('Multiple Connections Sidebar Component', function () {
652656
within(connectionItem).getByLabelText('Show actions')
653657
);
654658

655-
userEvent.click(screen.getByText('Duplicate'));
659+
userEvent.click(screen.getByText('Duplicate connection'));
656660

657661
// We see the connect button in the form modal
658662
expect(screen.getByTestId('connect-button')).to.be.visible;
@@ -675,7 +679,7 @@ describe('Multiple Connections Sidebar Component', function () {
675679
within(connectionItem).getByLabelText('Show actions')
676680
);
677681

678-
userEvent.click(screen.getByText('Remove'));
682+
userEvent.click(screen.getByText('Remove connection'));
679683

680684
await waitFor(() => {
681685
expect(

0 commit comments

Comments
 (0)