Skip to content

Commit eb46cd5

Browse files
committed
chore(preferences): remove multiple connections feature flag
1 parent ea4869a commit eb46cd5

File tree

36 files changed

+129
-326
lines changed

36 files changed

+129
-326
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
}

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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ describe('useExportConnections', function () {
248248
const { result } = renderUseExportConnectionsHook(
249249
{},
250250
{
251-
preferences: { enableMultipleConnectionSystem: true },
252251
connections: [
253252
{
254253
id: 'id1',

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
};

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
useConnectionColor,
44
DefaultColorCode,
55
} from '@mongodb-js/connection-form';
6-
import { usePreference } from 'compass-preferences-model/provider';
76
import { palette, useDarkMode } from '@mongodb-js/compass-components';
87
import type { SidebarTreeItem } from './tree-data';
98
import { ConnectionStatus } from '@mongodb-js/compass-connections/provider';
@@ -25,7 +24,6 @@ export default function StyledNavigationItem({
2524
const isDarkMode = useDarkMode();
2625
const { connectionColorToHex, connectionColorToHexActive } =
2726
useConnectionColor();
28-
const isSingleConnection = !usePreference('enableMultipleConnectionSystem');
2927
const { colorCode } = item;
3028
const isDisconnectedConnection =
3129
item.type === 'connection' &&
@@ -34,23 +32,20 @@ export default function StyledNavigationItem({
3432
const style: React.CSSProperties & AcceptedStyles = useMemo(() => {
3533
const style: AcceptedStyles = {};
3634

37-
if (!isSingleConnection) {
38-
if (colorCode && colorCode !== DefaultColorCode) {
39-
style['--item-bg-color'] = connectionColorToHex(colorCode);
40-
style['--item-bg-color-hover'] = connectionColorToHexActive(colorCode);
41-
style['--item-bg-color-active'] = connectionColorToHexActive(colorCode);
42-
}
35+
if (colorCode && colorCode !== DefaultColorCode) {
36+
style['--item-bg-color'] = connectionColorToHex(colorCode);
37+
style['--item-bg-color-hover'] = connectionColorToHexActive(colorCode);
38+
style['--item-bg-color-active'] = connectionColorToHexActive(colorCode);
39+
}
4340

44-
if (isDisconnectedConnection) {
45-
style['--item-color'] = isDarkMode
46-
? palette.gray.light1
47-
: palette.gray.dark1;
48-
}
41+
if (isDisconnectedConnection) {
42+
style['--item-color'] = isDarkMode
43+
? palette.gray.light1
44+
: palette.gray.dark1;
4945
}
5046
return style;
5147
}, [
5248
isDarkMode,
53-
isSingleConnection,
5449
isDisconnectedConnection,
5550
colorCode,
5651
connectionColorToHex,

packages/compass-connections-navigation/src/tree-data.ts

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -323,68 +323,39 @@ const databaseToItems = ({
323323
/**
324324
* Converts a list connections to virtual tree items.
325325
*
326-
* When isSingleConnection is true, the connections are treated as a single connection mode
327-
* and only two levels of items are shown: databases and collections.
328-
*
329326
* The IDs of the items are just to be used by the tree to correctly identify the items and
330327
* do not represent the actual IDs of the items.
331328
*
332329
* @param connections - The connections.
333-
* @param isSingleConnection - Whether the connections are a single connection.
334330
* @param expandedItems - The expanded items.
335331
*/
336332
export function getVirtualTreeItems({
337333
connections,
338-
isSingleConnection,
339334
expandedItems = {},
340335
preferencesReadOnly,
341336
preferencesShellEnabled,
342337
}: {
343338
connections: (NotConnectedConnection | ConnectedConnection)[];
344-
isSingleConnection: boolean;
345339
expandedItems: Record<string, false | Record<string, boolean>>;
346340
preferencesReadOnly: boolean;
347341
preferencesShellEnabled: boolean;
348342
}): SidebarTreeItem[] {
349-
if (!isSingleConnection) {
350-
return connections.flatMap((connection, connectionIndex) => {
351-
if (connection.connectionStatus === ConnectionStatus.Connected) {
352-
return connectedConnectionToItems({
353-
connection,
354-
expandedItems,
355-
connectionIndex,
356-
connectionsLength: connections.length,
357-
preferencesReadOnly,
358-
preferencesShellEnabled,
359-
});
360-
} else {
361-
return notConnectedConnectionToItems({
362-
connection,
363-
connectionsLength: connections.length,
364-
connectionIndex,
365-
});
366-
}
367-
});
368-
}
369-
370-
const connection = connections[0];
371-
// In single connection mode we expect the only connection to be connected
372-
if (connection.connectionStatus !== ConnectionStatus.Connected) {
373-
return [];
374-
}
375-
376-
const dbExpandedItems = expandedItems[connection.connectionInfo.id] || {};
377-
const hasWriteActionsDisabled =
378-
preferencesReadOnly || connection.isDataLake || !connection.isWritable;
379-
return connection.databases.flatMap((database, databaseIndex) => {
380-
return databaseToItems({
381-
connectionId: connection.connectionInfo.id,
382-
database,
383-
expandedItems: dbExpandedItems,
384-
level: 1,
385-
databasesLength: connection.databasesLength,
386-
databaseIndex,
387-
hasWriteActionsDisabled,
388-
});
343+
return connections.flatMap((connection, connectionIndex) => {
344+
if (connection.connectionStatus === ConnectionStatus.Connected) {
345+
return connectedConnectionToItems({
346+
connection,
347+
expandedItems,
348+
connectionIndex,
349+
connectionsLength: connections.length,
350+
preferencesReadOnly,
351+
preferencesShellEnabled,
352+
});
353+
} else {
354+
return notConnectedConnectionToItems({
355+
connection,
356+
connectionsLength: connections.length,
357+
connectionIndex,
358+
});
359+
}
389360
});
390361
}

0 commit comments

Comments
 (0)