Skip to content

Commit e231969

Browse files
authored
chore(preferences): remove multiple connections feature flag COMPASS-7906 (#6636)
* chore(preferences): remove multiple connections feature flag * chore(connections): remove more single connection related code; remove redundant mentions of multiple connections * chore(e2e): fix connect button selector * chore(e2e): don't forget to cancel connection
1 parent 7240cb4 commit e231969

File tree

61 files changed

+338
-751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+338
-751
lines changed

configs/testing-library-compass/src/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,12 @@ export class MockDataService
109109
implements
110110
Pick<
111111
DataService,
112+
| 'getConnectionString'
113+
| 'getConnectionOptions'
114+
| 'getMongoClientConnectionOptions'
112115
| 'addReauthenticationHandler'
113116
| 'getCurrentTopologyType'
117+
| 'getLastSeenTopology'
114118
| 'getUpdatedSecrets'
115119
| 'disconnect'
116120
| 'instance'
@@ -126,6 +130,12 @@ export class MockDataService
126130
getConnectionOptions() {
127131
return this.connectionOptions;
128132
}
133+
getMongoClientConnectionOptions() {
134+
return {
135+
url: this.connectionOptions.connectionString,
136+
options: { productName: 'Test', productDocsLink: 'http://example.com' },
137+
};
138+
}
129139
addReauthenticationHandler(): void {
130140
// noop
131141
}

package-lock.json

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

packages/compass-app-stores/src/stores/instance-store.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -352,25 +352,14 @@ export function createInstancesStore(
352352
}
353353
);
354354

355-
on(
356-
globalAppRegistry,
357-
'sidebar-filter-navigation-list',
358-
({ connectionId }: { connectionId?: string } = {}) => {
359-
const connectedConnectionIds = Array.from(
360-
instancesManager.listMongoDBInstances().keys()
361-
);
362-
// connectionId will be provided by the sidebar when in single connection
363-
// mode. We don't derive that from the list of connected connections
364-
// because there is a possibility for us to be fetching all collections on
365-
// wrong connection that way
366-
const connectionIds = connectionId
367-
? [connectionId]
368-
: connectedConnectionIds;
369-
for (const id of connectionIds) {
370-
void fetchAllCollections({ connectionId: id });
371-
}
355+
on(globalAppRegistry, 'sidebar-filter-navigation-list', () => {
356+
const connectedConnectionIds = Array.from(
357+
instancesManager.listMongoDBInstances().keys()
358+
);
359+
for (const id of connectedConnectionIds) {
360+
void fetchAllCollections({ connectionId: id });
372361
}
373-
);
362+
});
374363

375364
on(
376365
globalAppRegistry,

packages/compass-collection/src/components/collection-header-actions/collection-header-actions.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,12 @@ const CollectionHeaderActions: React.FunctionComponent<
5555
const { id: connectionId, atlasMetadata } = connectionInfo;
5656
const { openCollectionWorkspace, openEditViewWorkspace, openShellWorkspace } =
5757
useOpenWorkspace();
58-
const {
59-
readOnly: preferencesReadOnly,
60-
enableShell,
61-
enableMultipleConnectionSystem,
62-
} = usePreferences([
63-
'readOnly',
64-
'enableShell',
65-
'enableMultipleConnectionSystem',
66-
]);
58+
const { readOnly: preferencesReadOnly, enableShell: showOpenShellButton } =
59+
usePreferences(['readOnly', 'enableShell']);
6760
const track = useTelemetry();
6861

6962
const { database, collection } = toNS(namespace);
7063

71-
const showOpenShellButton = enableShell && enableMultipleConnectionSystem;
72-
7364
return (
7465
<div
7566
className={collectionHeaderActionsStyles}

packages/compass-connection-import-export/src/components/import-modal.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { SelectTable } from './select-table';
1414
import type { ImportExportResult } from '../hooks/common';
1515
import { useOpenModalThroughIpc } from '../hooks/common';
1616
import { useImportConnections } from '../hooks/use-import-connections';
17-
import { usePreference } from 'compass-preferences-model/provider';
1817

1918
const TOAST_TIMEOUT_MS = 5000;
2019

@@ -38,9 +37,6 @@ export function ImportConnectionsModal({
3837
setOpen: (newOpen: boolean, trackingProps?: Record<string, unknown>) => void;
3938
trackingProps?: Record<string, unknown>;
4039
}): React.ReactElement {
41-
const multipleConnectionsEnabled = usePreference(
42-
'enableMultipleConnectionSystem'
43-
);
4440
const { openToast } = useToast('compass-connection-import-export');
4541
const finish = useCallback(
4642
(result: ImportExportResult) => {
@@ -100,16 +96,15 @@ export function ImportConnectionsModal({
10096
variant={conn.selected ? 'yellow' : 'lightgray'}
10197
data-testid={`existing-favorite-badge-${conn.id}`}
10298
>
103-
Existing{' '}
104-
{multipleConnectionsEnabled ? 'Connection' : 'Favorite'}
99+
Existing Connection
105100
</Badge>
106101
)}
107102
</>
108103
),
109104
})),
110105
connectionList.some((conn) => conn.isExistingConnection && conn.selected),
111106
];
112-
}, [connectionList, multipleConnectionsEnabled]);
107+
}, [connectionList]);
113108

114109
return (
115110
<FormModal

packages/compass-connection-import-export/src/hooks/use-export-connections.spec.tsx

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -243,31 +243,28 @@ describe('useExportConnections', function () {
243243
expect(result.current.state.error).to.equal('');
244244
});
245245

246-
context('when multiple connections is enabled', function () {
247-
it('includes also the non-favorites connections in the export list', function () {
248-
const { result } = renderUseExportConnectionsHook(
249-
{},
250-
{
251-
preferences: { enableMultipleConnectionSystem: true },
252-
connections: [
253-
{
254-
id: 'id1',
255-
connectionOptions: {
256-
connectionString: 'mongodb://localhost:2020',
257-
},
258-
favorite: {
259-
name: 'name1',
260-
},
261-
// expecting to include the non-favorite connections as well
262-
savedConnectionType: 'recent',
246+
it('includes also the non-favorites connections in the export list', function () {
247+
const { result } = renderUseExportConnectionsHook(
248+
{},
249+
{
250+
connections: [
251+
{
252+
id: 'id1',
253+
connectionOptions: {
254+
connectionString: 'mongodb://localhost:2020',
263255
},
264-
],
265-
}
266-
);
256+
favorite: {
257+
name: 'name1',
258+
},
259+
// expecting to include the non-favorite connections as well
260+
savedConnectionType: 'recent',
261+
},
262+
],
263+
}
264+
);
267265

268-
expect(result.current.state.connectionList).to.deep.equal([
269-
{ id: 'id1', name: 'name1', selected: true },
270-
]);
271-
});
266+
expect(result.current.state.connectionList).to.deep.equal([
267+
{ id: 'id1', name: 'name1', selected: true },
268+
]);
272269
});
273270
});

packages/compass-connection-import-export/src/hooks/use-import-connections.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ describe('useImportConnections', function () {
304304
const { result, connectionStorage } = renderUseImportConnectionsHook(
305305
{},
306306
{
307-
preferences: { enableMultipleConnectionSystem: true },
308307
connections: [
309308
{
310309
id: 'id1',

packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ describe('ConnectionsNavigationTree', function () {
142142
preferences = await createSandboxFromDefaultPreferences();
143143
await preferences.savePreferences({
144144
enableRenameCollectionModal: true,
145-
enableMultipleConnectionSystem: true,
146145
...preferencesOverrides,
147146
});
148147
return render(
@@ -661,7 +660,6 @@ describe('ConnectionsNavigationTree', function () {
661660
preferences = await createSandboxFromDefaultPreferences();
662661
await preferences.savePreferences({
663662
enableRenameCollectionModal: true,
664-
enableMultipleConnectionSystem: true,
665663
});
666664
});
667665

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

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,11 @@ import {
2828
notConnectedConnectionItemActions,
2929
} from './item-actions';
3030

31-
const MCContainer = css({
31+
const ConnectionsNavigationContainerStyles = css({
3232
display: 'flex',
3333
flex: '1 0 auto',
3434
height: `calc(100% - ${spacing[1600]}px - ${spacing[200]}px)`,
3535
});
36-
37-
const SCContainer = css({
38-
display: 'flex',
39-
flex: '1 0 auto',
40-
height: 0,
41-
});
42-
4336
export interface ConnectionsNavigationTreeProps {
4437
connections: Connection[];
4538
activeWorkspace: WorkspaceTab | null;
@@ -59,7 +52,6 @@ const ConnectionsNavigationTree: React.FunctionComponent<
5952
}) => {
6053
const preferencesShellEnabled = usePreference('enableShell');
6154
const preferencesReadOnly = usePreference('readOnly');
62-
const isSingleConnection = !usePreference('enableMultipleConnectionSystem');
6355
const isRenameCollectionEnabled = usePreference(
6456
'enableRenameCollectionModal'
6557
);
@@ -69,18 +61,11 @@ const ConnectionsNavigationTree: React.FunctionComponent<
6961
const treeData = useMemo(() => {
7062
return getVirtualTreeItems({
7163
connections,
72-
isSingleConnection,
7364
expandedItems: expanded,
7465
preferencesReadOnly,
7566
preferencesShellEnabled,
7667
});
77-
}, [
78-
connections,
79-
isSingleConnection,
80-
expanded,
81-
preferencesReadOnly,
82-
preferencesShellEnabled,
83-
]);
68+
}, [connections, expanded, preferencesReadOnly, preferencesShellEnabled]);
8469

8570
const onDefaultAction: OnDefaultAction<SidebarActionableItem> = useCallback(
8671
(item, evt) => {
@@ -111,11 +96,11 @@ const ConnectionsNavigationTree: React.FunctionComponent<
11196
return `${activeWorkspace.connectionId}.${activeWorkspace.namespace}`;
11297
}
11398
// Database List (of a connection)
114-
if (activeWorkspace.type === 'Databases' && !isSingleConnection) {
99+
if (activeWorkspace.type === 'Databases') {
115100
return activeWorkspace.connectionId;
116101
}
117102
}
118-
}, [activeWorkspace, isSingleConnection]);
103+
}, [activeWorkspace]);
119104

120105
const getCollapseAfterForConnectedItem = useCallback(
121106
(actions: NavigationItemActions) => {
@@ -213,7 +198,7 @@ const ConnectionsNavigationTree: React.FunctionComponent<
213198
const isTestEnv = process.env.NODE_ENV === 'test';
214199

215200
return (
216-
<div className={isSingleConnection ? SCContainer : MCContainer}>
201+
<div className={ConnectionsNavigationContainerStyles}>
217202
<VisuallyHidden id={id}>Databases and Collections</VisuallyHidden>
218203
{/* AutoSizer types does not allow both width and height to be disabled
219204
considering that to be a pointless usecase and hence the type

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { CSSProperties } from 'react';
33
import { Placeholder, css } from '@mongodb-js/compass-components';
44
import { ROW_HEIGHT } from './constants';
55
import { getTreeItemStyles } from './utils';
6-
import { usePreference } from 'compass-preferences-model/provider';
76

87
const placeholderItem = css({
98
display: 'flex',
@@ -13,25 +12,24 @@ const placeholderItem = css({
1312
color: 'var(--item-color)',
1413
});
1514

16-
const MULTIPLE_CONNECTION_PROPS = {
15+
const PLACEHOLDER_PROPS = {
1716
gradientStart: 'var(--item-bg-color-active)',
1817
gradientEnd: 'var(--item-bg-color)',
1918
style: { filter: 'brightness(0.98)' },
20-
} as const;
19+
};
2120

2221
export const PlaceholderItem: React.FunctionComponent<{
2322
level: number;
2423
style?: CSSProperties;
2524
}> = ({ level, style }) => {
26-
const isSingleConnection = !usePreference('enableMultipleConnectionSystem');
2725
const itemPaddingStyles = useMemo(
2826
() => getTreeItemStyles({ level, isExpandable: false }),
2927
[level]
3028
);
3129

3230
return (
3331
<div className={placeholderItem} style={{ ...style, ...itemPaddingStyles }}>
34-
<Placeholder {...(isSingleConnection ? {} : MULTIPLE_CONNECTION_PROPS)} />
32+
<Placeholder {...PLACEHOLDER_PROPS} />
3533
</div>
3634
);
3735
};

0 commit comments

Comments
 (0)