diff --git a/configs/testing-library-compass/src/index.tsx b/configs/testing-library-compass/src/index.tsx index c0b332f7016..e6983f7b1b1 100644 --- a/configs/testing-library-compass/src/index.tsx +++ b/configs/testing-library-compass/src/index.tsx @@ -109,8 +109,12 @@ export class MockDataService implements Pick< DataService, + | 'getConnectionString' + | 'getConnectionOptions' + | 'getMongoClientConnectionOptions' | 'addReauthenticationHandler' | 'getCurrentTopologyType' + | 'getLastSeenTopology' | 'getUpdatedSecrets' | 'disconnect' | 'instance' @@ -126,6 +130,12 @@ export class MockDataService getConnectionOptions() { return this.connectionOptions; } + getMongoClientConnectionOptions() { + return { + url: this.connectionOptions.connectionString, + options: { productName: 'Test', productDocsLink: 'http://example.com' }, + }; + } addReauthenticationHandler(): void { // noop } diff --git a/package-lock.json b/package-lock.json index b1a8b799593..4712df0583f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46757,7 +46757,6 @@ "@mongodb-js/compass-connections": "^1.49.1", "@mongodb-js/compass-logging": "^1.5.1", "bson": "^6.10.1", - "compass-preferences-model": "^2.32.1", "hadron-app-registry": "^9.3.1", "lodash": "^4.17.21", "mongodb-collection-model": "^5.24.1", @@ -57745,7 +57744,6 @@ "@types/sinon-chai": "^3.2.5", "bson": "^6.10.1", "chai": "^4.3.6", - "compass-preferences-model": "^2.32.1", "depcheck": "^1.4.1", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", diff --git a/packages/compass-app-stores/src/stores/instance-store.ts b/packages/compass-app-stores/src/stores/instance-store.ts index d99dbbccb68..d0d8288d103 100644 --- a/packages/compass-app-stores/src/stores/instance-store.ts +++ b/packages/compass-app-stores/src/stores/instance-store.ts @@ -352,25 +352,14 @@ export function createInstancesStore( } ); - on( - globalAppRegistry, - 'sidebar-filter-navigation-list', - ({ connectionId }: { connectionId?: string } = {}) => { - const connectedConnectionIds = Array.from( - instancesManager.listMongoDBInstances().keys() - ); - // connectionId will be provided by the sidebar when in single connection - // mode. We don't derive that from the list of connected connections - // because there is a possibility for us to be fetching all collections on - // wrong connection that way - const connectionIds = connectionId - ? [connectionId] - : connectedConnectionIds; - for (const id of connectionIds) { - void fetchAllCollections({ connectionId: id }); - } + on(globalAppRegistry, 'sidebar-filter-navigation-list', () => { + const connectedConnectionIds = Array.from( + instancesManager.listMongoDBInstances().keys() + ); + for (const id of connectedConnectionIds) { + void fetchAllCollections({ connectionId: id }); } - ); + }); on( globalAppRegistry, diff --git a/packages/compass-collection/src/components/collection-header-actions/collection-header-actions.tsx b/packages/compass-collection/src/components/collection-header-actions/collection-header-actions.tsx index d3cc4c68ff8..f5770511452 100644 --- a/packages/compass-collection/src/components/collection-header-actions/collection-header-actions.tsx +++ b/packages/compass-collection/src/components/collection-header-actions/collection-header-actions.tsx @@ -55,21 +55,12 @@ const CollectionHeaderActions: React.FunctionComponent< const { id: connectionId, atlasMetadata } = connectionInfo; const { openCollectionWorkspace, openEditViewWorkspace, openShellWorkspace } = useOpenWorkspace(); - const { - readOnly: preferencesReadOnly, - enableShell, - enableMultipleConnectionSystem, - } = usePreferences([ - 'readOnly', - 'enableShell', - 'enableMultipleConnectionSystem', - ]); + const { readOnly: preferencesReadOnly, enableShell: showOpenShellButton } = + usePreferences(['readOnly', 'enableShell']); const track = useTelemetry(); const { database, collection } = toNS(namespace); - const showOpenShellButton = enableShell && enableMultipleConnectionSystem; - return (
) => void; trackingProps?: Record; }): React.ReactElement { - const multipleConnectionsEnabled = usePreference( - 'enableMultipleConnectionSystem' - ); const { openToast } = useToast('compass-connection-import-export'); const finish = useCallback( (result: ImportExportResult) => { @@ -100,8 +96,7 @@ export function ImportConnectionsModal({ variant={conn.selected ? 'yellow' : 'lightgray'} data-testid={`existing-favorite-badge-${conn.id}`} > - Existing{' '} - {multipleConnectionsEnabled ? 'Connection' : 'Favorite'} + Existing Connection )} @@ -109,7 +104,7 @@ export function ImportConnectionsModal({ })), connectionList.some((conn) => conn.isExistingConnection && conn.selected), ]; - }, [connectionList, multipleConnectionsEnabled]); + }, [connectionList]); return ( { const preferencesShellEnabled = usePreference('enableShell'); const preferencesReadOnly = usePreference('readOnly'); - const isSingleConnection = !usePreference('enableMultipleConnectionSystem'); const isRenameCollectionEnabled = usePreference( 'enableRenameCollectionModal' ); @@ -69,18 +61,11 @@ const ConnectionsNavigationTree: React.FunctionComponent< const treeData = useMemo(() => { return getVirtualTreeItems({ connections, - isSingleConnection, expandedItems: expanded, preferencesReadOnly, preferencesShellEnabled, }); - }, [ - connections, - isSingleConnection, - expanded, - preferencesReadOnly, - preferencesShellEnabled, - ]); + }, [connections, expanded, preferencesReadOnly, preferencesShellEnabled]); const onDefaultAction: OnDefaultAction = useCallback( (item, evt) => { @@ -111,11 +96,11 @@ const ConnectionsNavigationTree: React.FunctionComponent< return `${activeWorkspace.connectionId}.${activeWorkspace.namespace}`; } // Database List (of a connection) - if (activeWorkspace.type === 'Databases' && !isSingleConnection) { + if (activeWorkspace.type === 'Databases') { return activeWorkspace.connectionId; } } - }, [activeWorkspace, isSingleConnection]); + }, [activeWorkspace]); const getCollapseAfterForConnectedItem = useCallback( (actions: NavigationItemActions) => { @@ -213,7 +198,7 @@ const ConnectionsNavigationTree: React.FunctionComponent< const isTestEnv = process.env.NODE_ENV === 'test'; return ( -
+
Databases and Collections {/* AutoSizer types does not allow both width and height to be disabled considering that to be a pointless usecase and hence the type diff --git a/packages/compass-connections-navigation/src/placeholder.tsx b/packages/compass-connections-navigation/src/placeholder.tsx index 2b6523a29ad..05719885d55 100644 --- a/packages/compass-connections-navigation/src/placeholder.tsx +++ b/packages/compass-connections-navigation/src/placeholder.tsx @@ -3,7 +3,6 @@ import type { CSSProperties } from 'react'; import { Placeholder, css } from '@mongodb-js/compass-components'; import { ROW_HEIGHT } from './constants'; import { getTreeItemStyles } from './utils'; -import { usePreference } from 'compass-preferences-model/provider'; const placeholderItem = css({ display: 'flex', @@ -13,17 +12,16 @@ const placeholderItem = css({ color: 'var(--item-color)', }); -const MULTIPLE_CONNECTION_PROPS = { +const PLACEHOLDER_PROPS = { gradientStart: 'var(--item-bg-color-active)', gradientEnd: 'var(--item-bg-color)', style: { filter: 'brightness(0.98)' }, -} as const; +}; export const PlaceholderItem: React.FunctionComponent<{ level: number; style?: CSSProperties; }> = ({ level, style }) => { - const isSingleConnection = !usePreference('enableMultipleConnectionSystem'); const itemPaddingStyles = useMemo( () => getTreeItemStyles({ level, isExpandable: false }), [level] @@ -31,7 +29,7 @@ export const PlaceholderItem: React.FunctionComponent<{ return (
- +
); }; diff --git a/packages/compass-connections-navigation/src/styled-navigation-item.tsx b/packages/compass-connections-navigation/src/styled-navigation-item.tsx index a31c978bcca..288d43ae416 100644 --- a/packages/compass-connections-navigation/src/styled-navigation-item.tsx +++ b/packages/compass-connections-navigation/src/styled-navigation-item.tsx @@ -3,7 +3,6 @@ import { useConnectionColor, DefaultColorCode, } from '@mongodb-js/connection-form'; -import { usePreference } from 'compass-preferences-model/provider'; import { palette, useDarkMode } from '@mongodb-js/compass-components'; import type { SidebarTreeItem } from './tree-data'; import { ConnectionStatus } from '@mongodb-js/compass-connections/provider'; @@ -25,7 +24,6 @@ export default function StyledNavigationItem({ const isDarkMode = useDarkMode(); const { connectionColorToHex, connectionColorToHexActive } = useConnectionColor(); - const isSingleConnection = !usePreference('enableMultipleConnectionSystem'); const { colorCode } = item; const isDisconnectedConnection = item.type === 'connection' && @@ -34,23 +32,20 @@ export default function StyledNavigationItem({ const style: React.CSSProperties & AcceptedStyles = useMemo(() => { const style: AcceptedStyles = {}; - if (!isSingleConnection) { - if (colorCode && colorCode !== DefaultColorCode) { - style['--item-bg-color'] = connectionColorToHex(colorCode); - style['--item-bg-color-hover'] = connectionColorToHexActive(colorCode); - style['--item-bg-color-active'] = connectionColorToHexActive(colorCode); - } + if (colorCode && colorCode !== DefaultColorCode) { + style['--item-bg-color'] = connectionColorToHex(colorCode); + style['--item-bg-color-hover'] = connectionColorToHexActive(colorCode); + style['--item-bg-color-active'] = connectionColorToHexActive(colorCode); + } - if (isDisconnectedConnection) { - style['--item-color'] = isDarkMode - ? palette.gray.light1 - : palette.gray.dark1; - } + if (isDisconnectedConnection) { + style['--item-color'] = isDarkMode + ? palette.gray.light1 + : palette.gray.dark1; } return style; }, [ isDarkMode, - isSingleConnection, isDisconnectedConnection, colorCode, connectionColorToHex, diff --git a/packages/compass-connections-navigation/src/tree-data.ts b/packages/compass-connections-navigation/src/tree-data.ts index b7b6d58f9f5..6da458cc352 100644 --- a/packages/compass-connections-navigation/src/tree-data.ts +++ b/packages/compass-connections-navigation/src/tree-data.ts @@ -323,68 +323,39 @@ const databaseToItems = ({ /** * Converts a list connections to virtual tree items. * - * When isSingleConnection is true, the connections are treated as a single connection mode - * and only two levels of items are shown: databases and collections. - * * The IDs of the items are just to be used by the tree to correctly identify the items and * do not represent the actual IDs of the items. * * @param connections - The connections. - * @param isSingleConnection - Whether the connections are a single connection. * @param expandedItems - The expanded items. */ export function getVirtualTreeItems({ connections, - isSingleConnection, expandedItems = {}, preferencesReadOnly, preferencesShellEnabled, }: { connections: (NotConnectedConnection | ConnectedConnection)[]; - isSingleConnection: boolean; expandedItems: Record>; preferencesReadOnly: boolean; preferencesShellEnabled: boolean; }): SidebarTreeItem[] { - if (!isSingleConnection) { - return connections.flatMap((connection, connectionIndex) => { - if (connection.connectionStatus === ConnectionStatus.Connected) { - return connectedConnectionToItems({ - connection, - expandedItems, - connectionIndex, - connectionsLength: connections.length, - preferencesReadOnly, - preferencesShellEnabled, - }); - } else { - return notConnectedConnectionToItems({ - connection, - connectionsLength: connections.length, - connectionIndex, - }); - } - }); - } - - const connection = connections[0]; - // In single connection mode we expect the only connection to be connected - if (connection.connectionStatus !== ConnectionStatus.Connected) { - return []; - } - - const dbExpandedItems = expandedItems[connection.connectionInfo.id] || {}; - const hasWriteActionsDisabled = - preferencesReadOnly || connection.isDataLake || !connection.isWritable; - return connection.databases.flatMap((database, databaseIndex) => { - return databaseToItems({ - connectionId: connection.connectionInfo.id, - database, - expandedItems: dbExpandedItems, - level: 1, - databasesLength: connection.databasesLength, - databaseIndex, - hasWriteActionsDisabled, - }); + return connections.flatMap((connection, connectionIndex) => { + if (connection.connectionStatus === ConnectionStatus.Connected) { + return connectedConnectionToItems({ + connection, + expandedItems, + connectionIndex, + connectionsLength: connections.length, + preferencesReadOnly, + preferencesShellEnabled, + }); + } else { + return notConnectedConnectionToItems({ + connection, + connectionsLength: connections.length, + connectionIndex, + }); + } }); } diff --git a/packages/compass-connections/src/components/connection-status-notifications.tsx b/packages/compass-connections/src/components/connection-status-notifications.tsx index 8ddc9a95d53..ddb838e88d6 100644 --- a/packages/compass-connections/src/components/connection-status-notifications.tsx +++ b/packages/compass-connections/src/components/connection-status-notifications.tsx @@ -11,7 +11,6 @@ import { } from '@mongodb-js/compass-components'; import type { ConnectionInfo } from '@mongodb-js/connection-info'; import { getConnectionTitle } from '@mongodb-js/connection-info'; -import { usePreference } from 'compass-preferences-model/provider'; import ConnectionString from 'mongodb-connection-string-url'; import { isCancelError } from '@mongodb-js/compass-utils'; @@ -84,8 +83,6 @@ function ConnectionErrorToastBody({ ); } -const noop = () => undefined; - const deviceAuthModalContentStyles = css({ textAlign: 'center', '& > *:not(:last-child)': { @@ -211,46 +208,24 @@ const openNotifyDeviceAuthModal = ( ); }; -export function getNotificationTriggers( - enableMultipleConnectionSystem: boolean -) { - return enableMultipleConnectionSystem - ? { - openNotifyDeviceAuthModal, - openConnectionStartedToast, - openConnectionSucceededToast, - openConnectionFailedToast, - openMaximumConnectionsReachedToast, - closeConnectionStatusToast: (connectionId: string) => { - return closeToast(`connection-status--${connectionId}`); - }, - } - : { - openNotifyDeviceAuthModal: noop, - openConnectionStartedToast: noop, - openConnectionSucceededToast: noop, - openConnectionFailedToast: noop, - openMaximumConnectionsReachedToast: noop, - closeConnectionStatusToast: noop, - }; +export function getNotificationTriggers() { + return { + openNotifyDeviceAuthModal, + openConnectionStartedToast, + openConnectionSucceededToast, + openConnectionFailedToast, + openMaximumConnectionsReachedToast, + closeConnectionStatusToast: (connectionId: string) => { + return closeToast(`connection-status--${connectionId}`); + }, + }; } /** * Returns triggers for various notifications (toasts and modals) that are * supposed to be displayed every time connection flow is happening in the * application. - * - * All toasts and modals are only applicable in multiple connections mode. Right - * now it's gated by the feature flag, the flag check can be removed when this - * is the default behavior */ export function useConnectionStatusNotifications() { - const enableMultipleConnectionSystem = usePreference( - 'enableMultipleConnectionSystem' - ); - - // Gated by the feature flag: if flag is on, we return trigger functions, if - // flag is off, we return noop functions so that we can call them - // unconditionally in the actual flow - return getNotificationTriggers(enableMultipleConnectionSystem); + return getNotificationTriggers(); } diff --git a/packages/compass-connections/src/hooks/use-tab-connection-theme.spec.ts b/packages/compass-connections/src/hooks/use-tab-connection-theme.spec.ts index b72ce52f8c5..d5ea984f035 100644 --- a/packages/compass-connections/src/hooks/use-tab-connection-theme.spec.ts +++ b/packages/compass-connections/src/hooks/use-tab-connection-theme.spec.ts @@ -37,9 +37,7 @@ const CONNECTION_INFO_INVALID_COLOR = { describe('useTabConnectionTheme', function () { describe('when a connection does not exist', function () { it('should not return a theme', function () { - const { result } = renderHookWithConnections(useTabConnectionTheme, { - preferences: { enableMultipleConnectionSystem: true }, - }); + const { result } = renderHookWithConnections(useTabConnectionTheme); expect(result.current.getThemeOf('NON_EXISTING')).to.be.undefined; }); @@ -48,7 +46,6 @@ describe('useTabConnectionTheme', function () { describe('when a connection exists', function () { it('should return the theme with the connection colors', function () { const { result } = renderHookWithConnections(useTabConnectionTheme, { - preferences: { enableMultipleConnectionSystem: true }, connections: [CONNECTION_INFO], }); @@ -69,7 +66,6 @@ describe('useTabConnectionTheme', function () { it('should not return a theme when there is no color', function () { const { result } = renderHookWithConnections(useTabConnectionTheme, { - preferences: { enableMultipleConnectionSystem: true }, connections: [CONNECTION_INFO_NO_COLOR], }); @@ -80,7 +76,6 @@ describe('useTabConnectionTheme', function () { it('should not return a theme when the color is invalid', function () { const { result } = renderHookWithConnections(useTabConnectionTheme, { - preferences: { enableMultipleConnectionSystem: true }, connections: [CONNECTION_INFO_INVALID_COLOR], }); @@ -94,7 +89,6 @@ describe('useTabConnectionTheme', function () { const { result, connectionsStore } = renderHookWithConnections( useTabConnectionTheme, { - preferences: { enableMultipleConnectionSystem: true }, connections: [CONNECTION_INFO], } ); diff --git a/packages/compass-connections/src/hooks/use-tab-connection-theme.ts b/packages/compass-connections/src/hooks/use-tab-connection-theme.ts index dbfed847ba6..8a26cf71bfb 100644 --- a/packages/compass-connections/src/hooks/use-tab-connection-theme.ts +++ b/packages/compass-connections/src/hooks/use-tab-connection-theme.ts @@ -3,7 +3,6 @@ import { useConnectionColor } from '@mongodb-js/connection-form'; import { useDarkMode, type TabTheme } from '@mongodb-js/compass-components'; import { palette } from '@mongodb-js/compass-components'; import { useCallback } from 'react'; -import { usePreference } from 'compass-preferences-model/provider'; import { useConnectionsColorList } from '../stores/store-context'; type ThemeProvider = { @@ -18,9 +17,6 @@ export function useTabConnectionTheme(): ThemeProvider { useConnectionColor(); const connectionColorsList = useConnectionsColorList(); const darkTheme = useDarkMode(); - const isMultipleConnectionsEnabled = usePreference( - 'enableMultipleConnectionSystem' - ); const getThemeOf = useCallback( (connectionId: ConnectionInfo['id']) => { @@ -30,12 +26,7 @@ export function useTabConnectionTheme(): ThemeProvider { const bgColor = connectionColorToHex(color); const activeBgColor = connectionColorToHexActive(color); - if ( - !color || - !bgColor || - !activeBgColor || - !isMultipleConnectionsEnabled - ) { + if (!color || !bgColor || !activeBgColor) { return; } @@ -71,7 +62,6 @@ export function useTabConnectionTheme(): ThemeProvider { connectionColorToHex, connectionColorToHexActive, darkTheme, - isMultipleConnectionsEnabled, ] ); diff --git a/packages/compass-connections/src/stores/connections-store-redux.ts b/packages/compass-connections/src/stores/connections-store-redux.ts index 7626587fba7..1f622f0ca69 100644 --- a/packages/compass-connections/src/stores/connections-store-redux.ts +++ b/packages/compass-connections/src/stores/connections-store-redux.ts @@ -186,24 +186,8 @@ export type State = { | { status: 'error'; error: Error } ); - // Device auth flow info, stored in state so that it can be appended to the - // "Connecting..." modal. Only required for single connection mode and can be - // cleaned-up when multiple connections is the only mode of the app - oidcDeviceAuthInfo: Record< - ConnectionId, - { - verificationUrl: string; - userCode: string; - } - >; - editingConnectionInfoId: ConnectionId | null; isEditingConnectionInfoModalOpen: boolean; - - // State related to connection favorite fields editing modal form (right now - // only relevant for single connection mode, this might change) - editingConnectionFavoriteInfoId: ConnectionId | null; - isEditingConnectionFavoriteInfoModalOpen: boolean; }; type ThunkExtraArg = { @@ -372,13 +356,6 @@ type DisconnectAction = { connectionId: ConnectionId; }; -type OidcNotifyDeviceAuthAction = { - type: ActionTypes.OidcNotifyDeviceAuth; - connectionId: ConnectionId; - verificationUrl: string; - userCode: string; -}; - type CreateNewConnectionAction = { type: ActionTypes.CreateNewConnection; }; @@ -423,11 +400,6 @@ type RemoveAllRecentConnectionsActions = { type: ActionTypes.RemoveAllRecentConnections; }; -type EditConnectionFavoriteInfoAction = { - type: ActionTypes.EditConnectionFavoriteInfo; - connectionId: ConnectionId; -}; - function isAction( action: AnyAction, type: A['type'] @@ -492,11 +464,8 @@ const INITIAL_STATE: State = { status: 'initial', error: null, }, - oidcDeviceAuthInfo: {}, editingConnectionInfoId: null, isEditingConnectionInfoModalOpen: false, - editingConnectionFavoriteInfoId: null, - isEditingConnectionFavoriteInfoModalOpen: false, }; export function getInitialConnectionsStateForConnectionInfos( @@ -823,10 +792,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { isAutoconnectInfo: true, } ), - // Single connection mode special case: when autoconnecting set - // autoconnect info as editing so that the always-visible connection form - // is populated correctly and the error is mapped to it if it happend - editingConnectionInfoId: connectionState.info.id, }; } if ( @@ -835,12 +800,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { ActionTypes.ConnectionAttemptStart ) ) { - // Clean-up existing device auth info before starting new connection so that - // we don't show anything until driver actually provides it. Can be removed - // when this state is not in the store anymore - const oidcDeviceAuthInfo = { ...state.oidcDeviceAuthInfo }; - delete oidcDeviceAuthInfo[action.connectionInfo.id]; - return { ...state, connections: mergeConnectionStateById( @@ -871,7 +830,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { error: null, } ), - oidcDeviceAuthInfo, isEditingConnectionInfoModalOpen: // Close the modal when connection starts for edited connection state.editingConnectionInfoId === action.connectionInfo.id @@ -944,27 +902,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { ), }; } - if ( - isAction( - action, - ActionTypes.OidcNotifyDeviceAuth - ) - ) { - if (!hasConnectionForId(state, action.connectionId)) { - return state; - } - - return { - ...state, - oidcDeviceAuthInfo: { - ...state.oidcDeviceAuthInfo, - [action.connectionId]: { - userCode: action.userCode, - verificationUrl: action.verificationUrl, - }, - }, - }; - } if ( isAction(action, ActionTypes.CreateNewConnection) ) { @@ -1072,9 +1009,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { ...(state.editingConnectionInfoId === action.connectionId && { isEditingConnectionInfoModalOpen: false, }), - ...(state.editingConnectionFavoriteInfoId === action.connectionId && { - isEditingConnectionFavoriteInfoModalOpen: false, - }), }; } if ( @@ -1092,9 +1026,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { ...(state.editingConnectionInfoId === action.connectionId && { isEditingConnectionInfoModalOpen: false, }), - ...(state.editingConnectionFavoriteInfoId === action.connectionId && { - isEditingConnectionFavoriteInfoModalOpen: false, - }), }; } if ( @@ -1163,10 +1094,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { newConnection?.info.id ?? state.editingConnectionInfoId, isEditingConnectionInfoModalOpen: false, }), - ...(state.editingConnectionFavoriteInfoId === action.connectionId && { - editingConnectionFavoriteInfoId: null, - isEditingConnectionFavoriteInfoModalOpen: false, - }), }; } if ( @@ -1205,12 +1132,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { return id === state.editingConnectionInfoId; }); - const isEditingFavoriteRemoveConnections = - !!state.editingConnectionFavoriteInfoId && - idsToRemove.some((id) => { - return id === state.editingConnectionFavoriteInfoId; - }); - const newConnection = isEditingRemovedConnection ? createDefaultConnectionState() : undefined; @@ -1237,26 +1158,6 @@ const reducer: Reducer = (state = INITIAL_STATE, action) => { newConnection?.info.id ?? state.editingConnectionInfoId, isEditingConnectionInfoModalOpen: false, }), - ...(isEditingFavoriteRemoveConnections && { - editingConnectionFavoriteInfoId: null, - isEditingConnectionFavoriteInfoModalOpen: false, - }), - }; - } - if ( - isAction( - action, - ActionTypes.EditConnectionFavoriteInfo - ) - ) { - if (!hasConnectionForId(state, action.connectionId)) { - return state; - } - - return { - ...state, - editingConnectionFavoriteInfoId: action.connectionId, - isEditingConnectionFavoriteInfoModalOpen: true, }; } return state; @@ -1317,14 +1218,8 @@ const connectionAttemptError = ( connectionInfo: ConnectionInfo | null, err: any ): ConnectionsThunkAction => { - return ( - dispatch, - _getState, - { preferences, track, getExtraConnectionData } - ) => { - const { openConnectionFailedToast } = getNotificationTriggers( - preferences.getPreferences().enableMultipleConnectionSystem - ); + return (dispatch, _getState, { track, getExtraConnectionData }) => { + const { openConnectionFailedToast } = getNotificationTriggers(); const showReviewButton = !!connectionInfo && !connectionInfo.atlasMetadata; @@ -1525,7 +1420,6 @@ export const connect = ( | ConnectionAttemptErrorAction | ConnectionAttemptSuccessAction | ConnectionAttemptCancelledAction - | OidcNotifyDeviceAuthAction > => { return connectWithOptions(connectionInfo, { forceSave: false }); }; @@ -1538,7 +1432,6 @@ export const saveAndConnect = ( | ConnectionAttemptErrorAction | ConnectionAttemptSuccessAction | ConnectionAttemptCancelledAction - | OidcNotifyDeviceAuthAction > => { return connectWithOptions(connectionInfo, { forceSave: true }); }; @@ -1554,7 +1447,6 @@ const connectWithOptions = ( | ConnectionAttemptErrorAction | ConnectionAttemptSuccessAction | ConnectionAttemptCancelledAction - | OidcNotifyDeviceAuthAction > => { return async ( dispatch, @@ -1586,12 +1478,9 @@ const connectWithOptions = ( forceConnectionOptions, browserCommandForOIDCAuth, maximumNumberOfActiveConnections, - enableMultipleConnectionSystem, } = preferences.getPreferences(); - const connectionProgress = getNotificationTriggers( - enableMultipleConnectionSystem - ); + const connectionProgress = getNotificationTriggers(); if ( typeof maximumNumberOfActiveConnections !== 'undefined' && @@ -1656,12 +1545,6 @@ const connectWithOptions = ( browserCommandForOIDCAuth, }, notifyDeviceFlow: (deviceFlowInfo) => { - dispatch({ - type: ActionTypes.OidcNotifyDeviceAuth, - connectionId: connectionInfo.id, - ...deviceFlowInfo, - }); - connectionProgress.openNotifyDeviceAuthModal( connectionInfo, deviceFlowInfo.verificationUrl, @@ -1960,13 +1843,9 @@ export const createNewConnection = (): ConnectionsThunkAction< void, CreateNewConnectionAction > => { - return (dispatch, getState, { preferences }) => { - // In multiple connections mode we don't allow another edit to start while - // there is one in progress - if ( - preferences.getPreferences().enableMultipleConnectionSystem && - getState().isEditingConnectionInfoModalOpen - ) { + return (dispatch, getState) => { + // We don't allow another edit to start while there is one in progress + if (getState().isEditingConnectionInfoModalOpen) { return; } dispatch({ type: ActionTypes.CreateNewConnection }); @@ -1976,13 +1855,9 @@ export const createNewConnection = (): ConnectionsThunkAction< export const editConnection = ( connectionId: ConnectionId ): ConnectionsThunkAction => { - return (dispatch, getState, { preferences }) => { - // In multiple connections mode we don't allow another edit to start while - // there is one in progress - if ( - preferences.getPreferences().enableMultipleConnectionSystem && - getState().isEditingConnectionInfoModalOpen - ) { + return (dispatch, getState) => { + // We don't allow another edit to start while there is one in progress + if (getState().isEditingConnectionInfoModalOpen) { return; } dispatch({ type: ActionTypes.EditConnection, connectionId }); @@ -1993,13 +1868,9 @@ export const duplicateConnection = ( connectionId: ConnectionId, { autoDuplicate }: { autoDuplicate: boolean } = { autoDuplicate: false } ): ConnectionsThunkAction => { - return (dispatch, getState, { preferences }) => { - // In multiple connections mode we don't allow another edit to start while - // there is one in progress - if ( - preferences.getPreferences().enableMultipleConnectionSystem && - getState().isEditingConnectionInfoModalOpen - ) { + return (dispatch, getState) => { + // We don't allow another edit to start while there is one in progress + if (getState().isEditingConnectionInfoModalOpen) { return; } @@ -2043,7 +1914,7 @@ const cleanupConnection = ( return ( _dispatch, getState, - { preferences, logger: { log, debug, mongoLogId }, track } + { logger: { log, debug, mongoLogId }, track } ) => { log.info( mongoLogId(1_001_000_313), @@ -2067,9 +1938,7 @@ const cleanupConnection = ( ); } - const { closeConnectionStatusToast } = getNotificationTriggers( - preferences.getPreferences().enableMultipleConnectionSystem - ); + const { closeConnectionStatusToast } = getNotificationTriggers(); const connectionInfo = getCurrentConnectionInfo(getState(), connectionId); diff --git a/packages/compass-e2e-tests/helpers/commands/close-connect-modal.ts b/packages/compass-e2e-tests/helpers/commands/close-connect-modal.ts deleted file mode 100644 index d2c2291404e..00000000000 --- a/packages/compass-e2e-tests/helpers/commands/close-connect-modal.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { CompassBrowser } from '../compass-browser'; -import * as Selectors from '../selectors'; - -export async function closeConnectModal( - browser: CompassBrowser -): Promise { - await browser.clickVisible(Selectors.CancelConnectionButton); - const connectionModalContentElement = browser.$( - Selectors.ConnectionStatusModalContent - ); - await connectionModalContentElement.waitForExist({ - reverse: true, - }); -} diff --git a/packages/compass-e2e-tests/helpers/commands/connect-form.ts b/packages/compass-e2e-tests/helpers/commands/connect-form.ts index 2407a787262..1dcd2866f63 100644 --- a/packages/compass-e2e-tests/helpers/commands/connect-form.ts +++ b/packages/compass-e2e-tests/helpers/commands/connect-form.ts @@ -13,8 +13,6 @@ import { getConnectionTitle } from '@mongodb-js/connection-info'; const debug = Debug('compass-e2e-tests'); export async function resetConnectForm(browser: CompassBrowser): Promise { - const Sidebar = Selectors.Multiple; - if (await browser.$(Selectors.ConnectionModal).isDisplayed()) { await browser.clickVisible(Selectors.ConnectionModalCloseButton); await browser @@ -22,7 +20,7 @@ export async function resetConnectForm(browser: CompassBrowser): Promise { .waitForDisplayed({ reverse: true }); } - await browser.clickVisible(Sidebar.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); const connectionTitleSelector = Selectors.ConnectionModalTitle; diff --git a/packages/compass-e2e-tests/helpers/commands/connect.ts b/packages/compass-e2e-tests/helpers/commands/connect.ts index c8a4d787159..6ad7fb1e910 100644 --- a/packages/compass-e2e-tests/helpers/commands/connect.ts +++ b/packages/compass-e2e-tests/helpers/commands/connect.ts @@ -76,7 +76,7 @@ export async function connectWithConnectionString( }); } - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); await browser.$(Selectors.ConnectionModal).waitForDisplayed(); await browser.setValueVisible( @@ -123,7 +123,7 @@ export async function doConnect( connectionName: string, options: ConnectionResultOptions = {} ) { - await browser.clickVisible(Selectors.ConnectButton); + await browser.clickVisible(Selectors.ConnectionFormConnectButton); await browser.waitForConnectionResult(connectionName, options); } @@ -143,12 +143,9 @@ export async function waitForConnectionResult( if (connectionStatus === 'either') { // For the very rare cases where we don't care whether it fails or succeeds. // Usually because the exact result is a race condition. - const successSelector = Selectors.Multiple.connectionItemByName( - connectionName, - { - connected: true, - } - ); + const successSelector = Selectors.connectionItemByName(connectionName, { + connected: true, + }); const failureSelector = Selectors.ConnectionToastErrorText; await browser .$(`${successSelector},${failureSelector}`) @@ -159,7 +156,7 @@ export async function waitForConnectionResult( // server await browser .$( - Selectors.Multiple.connectionItemByName(connectionName, { + Selectors.connectionItemByName(connectionName, { connected: true, }) ) diff --git a/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts b/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts index 4b11cbce633..9a0e24d3231 100644 --- a/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts +++ b/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts @@ -12,7 +12,7 @@ export async function navigateToConnectionTab( } else { await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.ViewPerformanceItem + Selectors.ViewPerformanceItem ); } diff --git a/packages/compass-e2e-tests/helpers/commands/disconnect.ts b/packages/compass-e2e-tests/helpers/commands/disconnect.ts index a0389d174f2..c68859907b8 100644 --- a/packages/compass-e2e-tests/helpers/commands/disconnect.ts +++ b/packages/compass-e2e-tests/helpers/commands/disconnect.ts @@ -45,9 +45,7 @@ export async function disconnectAll( // The potential problem here is that the list is virtual, so it is possible // that not every connection is rendered. Collapsing them all helps a little // bit, though. - const connectionItems = browser.$$( - Selectors.Multiple.ConnectedConnectionItems - ); + const connectionItems = browser.$$(Selectors.ConnectedConnectionItems); for await (const connectionItem of connectionItems) { const connectionName = await connectionItem.getAttribute( 'data-connection-name' @@ -63,10 +61,9 @@ export async function disconnectAll( await browser.hideAllVisibleToasts(); } - // NOTE: unlike the single connection flow this doesn't make sure the New - // Connection modal is open after disconnecting. - // This also doesn't remove all connections from the sidebar so the - // connection will still be there, just disconnected. + // NOTE: This doesn't make sure the New Connection modal is open after + // disconnecting. This also doesn't remove all connections from the sidebar so + // the connection will still be there, just disconnected. } export async function disconnectByName( @@ -77,12 +74,12 @@ export async function disconnectByName( await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.DisconnectConnectionItem + Selectors.DisconnectConnectionItem ); await browser .$( - Selectors.Multiple.connectionItemByName(connectionName, { + Selectors.connectionItemByName(connectionName, { connected: false, }) ) diff --git a/packages/compass-e2e-tests/helpers/commands/index.ts b/packages/compass-e2e-tests/helpers/commands/index.ts index a686c300720..376e62d5fa2 100644 --- a/packages/compass-e2e-tests/helpers/commands/index.ts +++ b/packages/compass-e2e-tests/helpers/commands/index.ts @@ -1,7 +1,6 @@ export * from './exists-eventually'; export * from './click-visible'; export * from './set-value-visible'; -export * from './close-connect-modal'; export * from './close-settings-modal'; export * from './close-welcome-modal'; export * from './connect'; diff --git a/packages/compass-e2e-tests/helpers/commands/open-shell.ts b/packages/compass-e2e-tests/helpers/commands/open-shell.ts index 74ffed497f0..c592ae324d3 100644 --- a/packages/compass-e2e-tests/helpers/commands/open-shell.ts +++ b/packages/compass-e2e-tests/helpers/commands/open-shell.ts @@ -7,7 +7,7 @@ export async function openShell( ): Promise { await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.OpenShellItem, + Selectors.OpenShellItem, false // the item is not contained in the three-dot menu ); diff --git a/packages/compass-e2e-tests/helpers/commands/remove-connections.ts b/packages/compass-e2e-tests/helpers/commands/remove-connections.ts index 2d98c0026da..f9b6940d0cf 100644 --- a/packages/compass-e2e-tests/helpers/commands/remove-connections.ts +++ b/packages/compass-e2e-tests/helpers/commands/remove-connections.ts @@ -29,7 +29,7 @@ export async function removeAllConnections( // The potential problem here is that the list is virtual, so it is possible // that not every connection is rendered. Collapsing them all helps a little // bit, though. - const connectionItems = browser.$$(Selectors.Multiple.ConnectionItems); + const connectionItems = browser.$$(Selectors.ConnectionItems); for await (const connectionItem of connectionItems) { console.log(connectionItem); const connectionName = await connectionItem.getAttribute( @@ -47,10 +47,10 @@ export async function removeConnectionByName( await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.RemoveConnectionItem + Selectors.RemoveConnectionItem ); await browser - .$(Selectors.Multiple.connectionItemByName(connectionName)) + .$(Selectors.connectionItemByName(connectionName)) .waitForDisplayed({ reverse: true }); } diff --git a/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts b/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts index be2f93a1acb..9fc756d8b13 100644 --- a/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts +++ b/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts @@ -11,7 +11,7 @@ export async function saveConnectionStringAsFavorite( color = 'Green' ): Promise { // open the connection modal so we can fill in the connection string - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); favoriteName ??= new UUID().toHexString(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, diff --git a/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts b/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts index 9fe30669298..9f8f8d724e4 100644 --- a/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts +++ b/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts @@ -5,8 +5,7 @@ export async function selectConnectionsMenuItem( browser: CompassBrowser, itemSelector: string ) { - const Sidebar = Selectors.Multiple; - await browser.clickVisible(Sidebar.ConnectionsMenuButton); - await browser.$(Sidebar.ConnectionsMenu).waitForDisplayed(); + await browser.clickVisible(Selectors.ConnectionsMenuButton); + await browser.$(Selectors.ConnectionsMenu).waitForDisplayed(); await browser.clickVisible(itemSelector); } diff --git a/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts b/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts index d523aec852d..444e2f08cf0 100644 --- a/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts +++ b/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts @@ -4,7 +4,7 @@ import * as Selectors from '../selectors'; export async function getConnectionIdByName( browser: CompassBrowser, connectionName: string -): Promise { +): Promise { const connections = browser.$$(Selectors.sidebarConnection(connectionName)); const numConnections = await connections.length; @@ -15,9 +15,17 @@ export async function getConnectionIdByName( ); } - return await browser + const connectionId = await browser .$(Selectors.sidebarConnection(connectionName)) .getAttribute('data-connection-id'); + + if (!connectionId) { + throw new Error( + `Could not find connection id for connection ${connectionName}` + ); + } + + return connectionId; } export async function selectConnection( @@ -26,7 +34,7 @@ export async function selectConnection( ): Promise { await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.EditConnectionItem + Selectors.EditConnectionItem ); await browser.waitUntil(async () => { @@ -43,8 +51,6 @@ export async function selectConnectionMenuItem( itemSelector: string, openMenu = true ) { - const Sidebar = Selectors.Multiple; - const selector = Selectors.sidebarConnection(connectionName); await browser.waitUntil(async () => { @@ -60,7 +66,7 @@ export async function selectConnectionMenuItem( await browser.$(selector).waitForDisplayed(); // workaround for weirdness in the ItemActionControls menu opener icon - await browser.clickVisible(Sidebar.ConnectionsTitle); + await browser.clickVisible(Selectors.ConnectionsTitle); // Hover over an arbitrary other element to ensure that the second hover will // actually be a fresh one. This otherwise breaks if this function is called @@ -76,7 +82,7 @@ export async function selectConnectionMenuItem( await browser.clickVisible( Selectors.sidebarConnectionMenuButton(connectionName) ); - await browser.$(Sidebar.ConnectionMenu).waitForDisplayed(); + await browser.$(Selectors.ConnectionMenu).waitForDisplayed(); } await browser.clickVisible(itemSelector); @@ -100,7 +106,7 @@ export async function removeConnection( if (await browser.$(selector).isExisting()) { await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.RemoveConnectionItem + Selectors.RemoveConnectionItem ); await browser.$(selector).waitForExist({ reverse: true }); return true; @@ -129,12 +135,12 @@ export async function hasConnectionMenuItem( await browser.$(selector).waitForDisplayed(); // workaround for weirdness in the ItemActionControls menu opener icon - await browser.clickVisible(Selectors.Multiple.ConnectionsTitle); + await browser.clickVisible(Selectors.ConnectionsTitle); // Hover over an arbitrary other element to ensure that the second hover will // actually be a fresh one. This otherwise breaks if this function is called // twice in a row. - await browser.hover(Selectors.Multiple.ConnectionsTitle); + await browser.hover(Selectors.ConnectionsTitle); await browser.hover(selector); return false; @@ -145,7 +151,7 @@ export async function hasConnectionMenuItem( await browser.clickVisible( Selectors.sidebarConnectionMenuButton(connectionName) ); - await browser.$(Selectors.Multiple.ConnectionMenu).waitForDisplayed(); + await browser.$(Selectors.ConnectionMenu).waitForDisplayed(); } return await browser.$(itemSelector).isExisting(); diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index 8dab150319a..449bf6590f3 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -33,17 +33,7 @@ export const WelcomeModal = '[data-testid="welcome-modal"]'; export const CloseWelcomeModalButton = '[data-testid="welcome-modal"] [aria-label="Close modal"]'; -// Connection screen (single connection only) -export const ConnectSection = '[data-testid="connections-wrapper"]'; -export const ConnectButton = '[data-testid="connect-button"]'; -export const SaveAndConnectButton = '[data-testid="save-and-connect-button"]'; -export const CancelConnectionButton = - '[data-testid="cancel-connection-button"]'; -export const ConnectionTitle = '[data-testid="connection-form"] h3'; -export const ConnectionEditFavouriteButton = - '[data-testid="edit-favorite-icon-button"]'; - -// Connection form (shared by single and multiple connection) +// Connection form export const ConnectionForm = '[data-testid="connection-form"]'; export const ConnectionFormStringInput = 'textarea[data-testid="connectionString"]'; @@ -69,6 +59,15 @@ export const ConnectionFormInputPassword = '[data-testid="connection-password-input"]'; export const ConnectionFormErrorMessage = '[data-testid="connection-error-summary"]'; +export const ConnectionFormConnectionName = + '[data-testid="personalization-name-input"]'; +export const ConnectionFormConnectionColor = + '[data-testid="personalization-color-input"]'; +export const ConnectionFormFavoriteCheckbox = + '[data-testid="personalization-favorite-checkbox"]'; +export const ConnectionFormConnectButton = '[data-testid="connect-button"]'; +export const ConnectionFormSaveAndConnectButton = + '[data-testid="save-and-connect-button"]'; export const AdvancedOptionsTabs = '[aria-label="Advanced Options Tabs"]'; export const SelectedAdvancedOptionsTab = `${AdvancedOptionsTabs} [aria-selected="true"]`; @@ -225,116 +224,77 @@ export const connectionFormUrlOptionValueInput = (index: number): string => { return `[data-testid="url-options"] [data-testid="url-option-entry-${index}"] input`; }; -// Connection status modal (single connection only) -export const ConnectionStatusModalContent = - '[data-testid="connecting-modal-content"]'; - -// Multiple Connections Modal +// Connections modal export const ConnectionModal = '[data-testid="connection-form-modal"]'; export const ConnectionModalTitle = `${ConnectionModal} h3`; export const ConnectionModalCloseButton = `${ConnectionModal} [aria-label="Close modal"]`; export const ConnectionModalConnectButton = '[data-testid="connect-button"]'; export const ConnectionModalSaveButton = '[data-testid="save-button"]'; -export const ConnectionFormConnectionName = - '[data-testid="personalization-name-input"]'; -export const ConnectionFormConnectionColor = - '[data-testid="personalization-color-input"]'; -export const ConnectionFormFavoriteCheckbox = - '[data-testid="personalization-favorite-checkbox"]'; + +// Connection process toast export const connectionToastById = (connectionId: string) => { return `[data-testid="toast-connection-status--${connectionId}"]`; }; export const ConnectionToastErrorText = '[data-testid="connection-error-text"]'; export const ConnectionToastErrorReviewButton = '[data-testid="connection-error-review"]'; +export const ConenctionToastCancelConnectionButton = + '[data-testid="cancel-connection-button"]'; -// Single Connection sidebar -export const Single = { - ConnectionsTitle: '[data-testid="connections-title"]', - SidebarNewConnectionButton: '[data-testid="new-connection-button"]', - FavoriteConnections: '[data-testid="favorite-connection"]', - FavoriteConnectionsHeader: '[data-testid="favorite-connections-list-header"]', - ConnectionMenu: '[data-testid="connection-menu"]', - CopyConnectionStringItem: `[data-testid="connection-menu-copy-connection-string-action"]`, - EditConnectionItem: `[data-testid="connection-menu-edit-connection-action"]`, - DuplicateConnectionItem: `[data-testid="connection-menu-duplicate-connection-action"]`, - RemoveConnectionItem: `[data-testid="connection-menu-remove-connection-action"]`, - RecentConnections: '[data-testid="recent-connection"]', - CreateDatabaseButton: - '[data-testid="sidebar-navigation-item-actions-open-create-database-action"]', - // for single connections refresh is a button next to add, not a menu item - RefreshDatabasesButton: - '[data-testid="sidebar-navigation-item-actions-refresh-databases-action"]', - ShowTitleActionsButton: '[data-testid="sidebar-title-actions-show-actions"]', - ClusterInfoItem: - '[data-testid="sidebar-title-actions-open-connection-info-action"]', - ConnectionsMenuButton: `[data-testid="favorite-connections-list-header"] button[title="Show actions"]`, - ConnectionsMenu: '[data-testid="favorites-menu"]', - ExportConnectionsModalOpen: - '[data-testid="favorites-menu-export-saved-connections-action"]', - ImportConnectionsModalOpen: - '[data-testid="favorites-menu-import-saved-connections-action"]', - - InUseEncryptionMarker: '[data-testid="fle-connection-configuration"]', -}; - -// Multiple Connections sidebar -export const Multiple = { - ConnectionsTitle: '[data-testid="connections-header"]', - ConnectButton: '[data-action="connection-connect"]', - SidebarNewConnectionButton: '[data-action="add-new-connection"]', - ConnectionMenu: '[data-testid="sidebar-navigation-item-actions"]', - CreateDatabaseButton: - '[data-testid="sidebar-navigation-item-actions-create-database-action"]', - OpenShellItem: - '[data-testid="sidebar-navigation-item-actions-open-shell-action"]', - ViewPerformanceItem: - '[data-testid="sidebar-navigation-item-actions-connection-performance-metrics-action"]', - ShowConnectionInfoItem: - '[data-testid="sidebar-navigation-item-actions-open-connection-info-action"]', - DisconnectConnectionItem: - '[data-testid="sidebar-navigation-item-actions-connection-disconnect-action"]', - EditConnectionItem: - '[data-testid="sidebar-navigation-item-actions-edit-connection-action"]', - CopyConnectionStringItem: - '[data-testid="sidebar-navigation-item-actions-copy-connection-string-action"]', - UnfavoriteConnectionItem: - '[data-testid="sidebar-navigation-item-actions-connection-toggle-favorite-action"]', - DuplicateConnectionItem: `[data-testid="sidebar-navigation-item-actions-duplicate-connection-action"]`, - RemoveConnectionItem: `[data-testid="sidebar-navigation-item-actions-remove-connection-action"]`, - - // for multiple connections refresh is a menu item, not a button next to add database - RefreshDatabasesItem: - '[data-testid="sidebar-navigation-item-actions-refresh-databases-action"]', - ClusterInfoItem: - '[data-testid="sidebar-navigation-item-actions-open-connection-info-action"]', - ConnectionsMenuButton: - '[data-testid="connections-list-title-actions-show-actions"]', - ConnectionsMenu: '[data-testid="connections-list-title-actions"]', - ExportConnectionsModalOpen: - '[data-testid="connections-list-title-actions-export-saved-connections-action"]', - ImportConnectionsModalOpen: - '[data-testid="connections-list-title-actions-import-saved-connections-action"]', - - InUseEncryptionMarker: '[data-action="open-csfle-modal"]', - - ConnectionItems: '[role="treeitem"][aria-level="1"] [data-is-connected]', - ConnectedConnectionItems: - '[role="treeitem"][aria-level="1"] [data-is-connected=true]', - - NoDeploymentsText: '[data-testid="no-deployments-text"]', - AddNewConnectionButton: '[data-testid="add-new-connection-button"]', - - connectionItemByName: ( - connectionName: string, - { connected }: { connected?: boolean } = {} - ) => { - const connectedFilter = - connected !== undefined - ? `[data-is-connected="${connected.toString()}"]` - : ''; - return `[role="treeitem"][aria-level="1"] [data-connection-name="${connectionName}"]${connectedFilter}`; - }, +// Connections sidebar +export const ConnectionsTitle = '[data-testid="connections-header"]'; +export const SidebarNewConnectionButton = '[data-action="add-new-connection"]'; +export const ConnectionMenu = '[data-testid="sidebar-navigation-item-actions"]'; +export const CreateDatabaseButton = + '[data-testid="sidebar-navigation-item-actions-create-database-action"]'; +export const OpenShellItem = + '[data-testid="sidebar-navigation-item-actions-open-shell-action"]'; +export const ViewPerformanceItem = + '[data-testid="sidebar-navigation-item-actions-connection-performance-metrics-action"]'; +export const ShowConnectionInfoItem = + '[data-testid="sidebar-navigation-item-actions-open-connection-info-action"]'; +export const DisconnectConnectionItem = + '[data-testid="sidebar-navigation-item-actions-connection-disconnect-action"]'; +export const EditConnectionItem = + '[data-testid="sidebar-navigation-item-actions-edit-connection-action"]'; +export const CopyConnectionStringItem = + '[data-testid="sidebar-navigation-item-actions-copy-connection-string-action"]'; +export const UnfavoriteConnectionItem = + '[data-testid="sidebar-navigation-item-actions-connection-toggle-favorite-action"]'; +export const DuplicateConnectionItem = `[data-testid="sidebar-navigation-item-actions-duplicate-connection-action"]`; +export const RemoveConnectionItem = `[data-testid="sidebar-navigation-item-actions-remove-connection-action"]`; +export const RefreshDatabasesItem = + '[data-testid="sidebar-navigation-item-actions-refresh-databases-action"]'; +export const ClusterInfoItem = + '[data-testid="sidebar-navigation-item-actions-open-connection-info-action"]'; +export const ConnectionsMenuButton = + '[data-testid="connections-list-title-actions-show-actions"]'; +export const ConnectionsMenu = '[data-testid="connections-list-title-actions"]'; +export const ExportConnectionsModalOpen = + '[data-testid="connections-list-title-actions-export-saved-connections-action"]'; +export const ImportConnectionsModalOpen = + '[data-testid="connections-list-title-actions-import-saved-connections-action"]'; + +export const InUseEncryptionMarker = '[data-action="open-csfle-modal"]'; + +export const ConnectionItems = + '[role="treeitem"][aria-level="1"] [data-is-connected]'; +export const ConnectedConnectionItems = + '[role="treeitem"][aria-level="1"] [data-is-connected=true]'; + +export const NoDeploymentsText = '[data-testid="no-deployments-text"]'; +export const AddNewConnectionButton = + '[data-testid="add-new-connection-button"]'; + +export const connectionItemByName = ( + connectionName: string, + { connected }: { connected?: boolean } = {} +) => { + const connectedFilter = + connected !== undefined + ? `[data-is-connected="${connected.toString()}"]` + : ''; + return `[role="treeitem"][aria-level="1"] [data-connection-name="${connectionName}"]${connectedFilter}`; }; // Rename Collection Modal @@ -368,8 +328,7 @@ export const CollapseConnectionsButton = '[data-testid="connections-list-title-actions-collapse-all-connections-action"]'; export const sidebarDatabase = ( - // TODO(COMPASS-7906): don't allow undefined connectionId - connectionId: string | undefined, + connectionId: string, dbName: string ): string => { if (connectionId) { @@ -379,16 +338,14 @@ export const sidebarDatabase = ( }; export const sidebarDatabaseToggle = ( - // TODO(COMPASS-7906): don't allow undefined connectionId - connectionId: string | undefined, + connectionId: string, dbName: string ): string => { return `${sidebarDatabase(connectionId, dbName)} button[type=button]`; }; export const sidebarCollection = ( - // TODO(COMPASS-7906): don't allow undefined connectionId - connectionId: string | undefined, + connectionId: string, dbName: string, collectionName: string ): string => { @@ -403,7 +360,9 @@ export const sidebarConnection = (connectionName: string): string => { }; export const sidebarConnectionButton = (connectionName: string): string => { - return `${sidebarConnection(connectionName)} ${Multiple.ConnectButton}`; + return `${sidebarConnection( + connectionName + )} [data-action="connection-connect"]`; }; export const sidebarConnectionActionButton = ( @@ -417,11 +376,6 @@ export const sidebarConnectionMenuButton = (connectionName: string): string => { return `${sidebarConnection(connectionName)} button[title="Show actions"]`; }; -export const sidebarFavorite = (favoriteName: string): string => { - // single connection only - return `${Single.FavoriteConnections}[data-id="favorite-connection-${favoriteName}"]`; -}; - // CSFLE modal export const SetCSFLEEnabledLabel = '[id="set-csfle-enabled"]'; export const CSFLEConnectionModal = '[data-testid="csfle-connection-modal"]'; diff --git a/packages/compass-e2e-tests/multiple-connections.yaml b/packages/compass-e2e-tests/multiple-connections.yaml deleted file mode 100644 index 704c8b375db..00000000000 --- a/packages/compass-e2e-tests/multiple-connections.yaml +++ /dev/null @@ -1 +0,0 @@ -enableMultipleConnectionSystem: true diff --git a/packages/compass-e2e-tests/tests/auto-connect.test.ts b/packages/compass-e2e-tests/tests/auto-connect.test.ts index b599ac819a0..42d9d0ae24f 100644 --- a/packages/compass-e2e-tests/tests/auto-connect.test.ts +++ b/packages/compass-e2e-tests/tests/auto-connect.test.ts @@ -303,7 +303,7 @@ describe('Automatically connecting from the command line', function () { // no active connections const numConnectionItems = await browser.$$( - Selectors.Multiple.ConnectedConnectionItems + Selectors.ConnectedConnectionItems ).length; expect(numConnectionItems).to.equal(0); } finally { @@ -337,15 +337,12 @@ describe('Automatically connecting from the command line', function () { browser = compass.browser; // there should be no connection items - const numConnectionItems = await browser.$$( - Selectors.Multiple.ConnectionItems - ).length; + const numConnectionItems = await browser.$$(Selectors.ConnectionItems) + .length; expect(numConnectionItems).to.equal(0); - await browser.$(Selectors.Multiple.NoDeploymentsText).waitForDisplayed(); - await browser - .$(Selectors.Multiple.AddNewConnectionButton) - .waitForDisplayed(); + await browser.$(Selectors.NoDeploymentsText).waitForDisplayed(); + await browser.$(Selectors.AddNewConnectionButton).waitForDisplayed(); } finally { await cleanup(compass); } diff --git a/packages/compass-e2e-tests/tests/collection-rename.test.ts b/packages/compass-e2e-tests/tests/collection-rename.test.ts index 577a387f858..6a796c60f62 100644 --- a/packages/compass-e2e-tests/tests/collection-rename.test.ts +++ b/packages/compass-e2e-tests/tests/collection-rename.test.ts @@ -79,7 +79,7 @@ async function renameCollectionSuccessFlow( describe('Collection Rename Modal', () => { let compass: Compass; let browser: CompassBrowser; - let connectionId: string | undefined; + let connectionId: string; before(async function () { compass = await init(this.test?.fullTitle()); @@ -92,6 +92,7 @@ describe('Collection Rename Modal', () => { await browser.disconnectAll(); await browser.connectToDefaults(); + connectionId = await browser.getConnectionIdByName( DEFAULT_CONNECTION_NAME_1 ); diff --git a/packages/compass-e2e-tests/tests/connection-form.test.ts b/packages/compass-e2e-tests/tests/connection-form.test.ts index d0ef29b2b42..750f5b60cc2 100644 --- a/packages/compass-e2e-tests/tests/connection-form.test.ts +++ b/packages/compass-e2e-tests/tests/connection-form.test.ts @@ -614,8 +614,6 @@ describe('Connection form', function () { const favoriteName = 'My Favorite'; const newFavoriteName = 'My Favorite (edited)'; - const Sidebar = Selectors.Multiple; - // save await browser.saveFavorite(favoriteName, 'Green'); @@ -623,7 +621,7 @@ describe('Connection form', function () { // copy the connection string await browser.selectConnectionMenuItem( favoriteName, - Sidebar.CopyConnectionStringItem + Selectors.CopyConnectionStringItem ); await browser.waitUntil( async () => { @@ -638,16 +636,16 @@ describe('Connection form', function () { // duplicate await browser.selectConnectionMenuItem( favoriteName, - Sidebar.DuplicateConnectionItem + Selectors.DuplicateConnectionItem ); - // duplicating opens the modal, in multiple connections you have to save + // duplicating opens the modal you have to save await browser.clickVisible(Selectors.ConnectionModalSaveButton); // delete the duplicate await browser.selectConnectionMenuItem( `${favoriteName} (1)`, - Sidebar.RemoveConnectionItem + Selectors.RemoveConnectionItem ); // edit the original diff --git a/packages/compass-e2e-tests/tests/connection.test.ts b/packages/compass-e2e-tests/tests/connection.test.ts index cac595f00b7..6a20d52304e 100644 --- a/packages/compass-e2e-tests/tests/connection.test.ts +++ b/packages/compass-e2e-tests/tests/connection.test.ts @@ -196,8 +196,6 @@ async function assertCannotCreateDb( dbName: string, collectionName: string ): Promise { - const Sidebar = Selectors.Multiple; - // navigate to the databases tab so that the connection is // active/highlighted and then the add button and three dot menu will // display without needing to hover @@ -206,7 +204,7 @@ async function assertCannotCreateDb( // open the create database modal from the sidebar await browser.selectConnectionMenuItem( connectionName, - Sidebar.CreateDatabaseButton, + Selectors.CreateDatabaseButton, false ); @@ -332,7 +330,7 @@ describe('Connection string', function () { 'There was a problem connecting to 127.0.0.1:27091' ); - // for multiple connections click the review button in the toast + // click the review button in the toast await browser.clickVisible(Selectors.ConnectionToastErrorReviewButton); await browser.$(Selectors.ConnectionModal).waitForDisplayed(); const errorText = await browser diff --git a/packages/compass-e2e-tests/tests/force-connection-options.test.ts b/packages/compass-e2e-tests/tests/force-connection-options.test.ts index 228cef005b3..776c8c85bec 100644 --- a/packages/compass-e2e-tests/tests/force-connection-options.test.ts +++ b/packages/compass-e2e-tests/tests/force-connection-options.test.ts @@ -42,7 +42,7 @@ describe('forceConnectionOptions', function () { it('forces the value of a specific connection option', async function () { // open the connection modal because that's where the warnings will be displayed - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); await browser.waitUntil( async () => { diff --git a/packages/compass-e2e-tests/tests/global-preferences.test.ts b/packages/compass-e2e-tests/tests/global-preferences.test.ts index d2fa45ef72f..3e2ce215522 100644 --- a/packages/compass-e2e-tests/tests/global-preferences.test.ts +++ b/packages/compass-e2e-tests/tests/global-preferences.test.ts @@ -201,13 +201,6 @@ describe('Global preferences', function () { 'This setting cannot be modified as it has been set in the global Compass configuration file.' ); } - // TODO(COMPASS-8071): This just passes for multiple connections because - // the shell section is never there. - { - const shellSection = browser.$(Selectors.ShellSection); - const isShellSectionExisting = await shellSection.isExisting(); - expect(isShellSectionExisting).to.be.equal(false); - } } finally { await cleanup(compass); } diff --git a/packages/compass-e2e-tests/tests/import-export-connections.test.ts b/packages/compass-e2e-tests/tests/import-export-connections.test.ts index 9848f290f77..b862afe6d89 100644 --- a/packages/compass-e2e-tests/tests/import-export-connections.test.ts +++ b/packages/compass-e2e-tests/tests/import-export-connections.test.ts @@ -118,7 +118,7 @@ describe('Connection Import / Export', function () { await browser.selectConnectionMenuItem( favoriteName, - Selectors.Multiple.RemoveConnectionItem + Selectors.RemoveConnectionItem ); await waitForConnections(); @@ -148,9 +148,7 @@ describe('Connection Import / Export', function () { const { browser } = compass; // open the connection modal so we can fill in the connection string - await browser.clickVisible( - Selectors.Multiple.SidebarNewConnectionButton - ); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); await browser.setValueVisible( Selectors.ConnectionFormStringInput, @@ -197,7 +195,7 @@ describe('Connection Import / Export', function () { const { browser } = compass; await browser.selectConnectionMenuItem( favoriteName, - Selectors.Multiple.RemoveConnectionItem + Selectors.RemoveConnectionItem ); await waitForConnections(); } finally { @@ -251,7 +249,7 @@ describe('Connection Import / Export', function () { browser = compass.browser; // open the connection modal so we can fill in the connection string - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); await browser.setValueVisible( Selectors.ConnectionFormStringInput, @@ -276,8 +274,6 @@ describe('Connection Import / Export', function () { for (const variant of variants) { it(`supports exporting and importing connections in ${variant} mode`, async function () { - const Sidebar = Selectors.Multiple; - { // Make sure file exists so that the file picker works. We could also do work // similar to what we do for collection data export, where we add special listeners @@ -290,7 +286,7 @@ describe('Connection Import / Export', function () { // Open export modal { await browser.selectConnectionsMenuItem( - Sidebar.ExportConnectionsModalOpen + Selectors.ExportConnectionsModalOpen ); await browser.$(Selectors.ExportConnectionsModal).waitForDisplayed(); } @@ -352,7 +348,7 @@ describe('Connection Import / Export', function () { // Open import modal { await browser.selectConnectionsMenuItem( - Sidebar.ImportConnectionsModalOpen + Selectors.ImportConnectionsModalOpen ); await browser.$(Selectors.ImportConnectionsModal).waitForDisplayed(); } diff --git a/packages/compass-e2e-tests/tests/in-use-encryption.test.ts b/packages/compass-e2e-tests/tests/in-use-encryption.test.ts index 4e3213964e7..dd63d1181a7 100644 --- a/packages/compass-e2e-tests/tests/in-use-encryption.test.ts +++ b/packages/compass-e2e-tests/tests/in-use-encryption.test.ts @@ -25,7 +25,7 @@ async function refresh(browser: CompassBrowser, connectionName: string) { await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); } @@ -147,7 +147,7 @@ describe('CSFLE / QE', function () { // edit from the menu. await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.EditConnectionItem + Selectors.EditConnectionItem ); // The modal should appear and the title of the modal should be the favorite name @@ -866,7 +866,7 @@ describe('CSFLE / QE', function () { await browser.clickVisible( Selectors.sidebarConnectionActionButton( connectionName, - Selectors.Multiple.InUseEncryptionMarker + Selectors.InUseEncryptionMarker ) ); @@ -892,7 +892,7 @@ describe('CSFLE / QE', function () { await browser.clickVisible( Selectors.sidebarConnectionActionButton( connectionName, - Selectors.Multiple.InUseEncryptionMarker + Selectors.InUseEncryptionMarker ) ); diff --git a/packages/compass-e2e-tests/tests/instance-sidebar.test.ts b/packages/compass-e2e-tests/tests/instance-sidebar.test.ts index d9f67f6940f..6e3f50833c3 100644 --- a/packages/compass-e2e-tests/tests/instance-sidebar.test.ts +++ b/packages/compass-e2e-tests/tests/instance-sidebar.test.ts @@ -18,7 +18,7 @@ const { expect } = chai; describe('Instance sidebar', function () { let compass: Compass; let browser: CompassBrowser; - let connectionId: string | undefined; + let connectionId: string; before(async function () { compass = await init(this.test?.fullTitle()); @@ -48,7 +48,7 @@ describe('Instance sidebar', function () { await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.ClusterInfoItem + Selectors.ClusterInfoItem ); const modal = browser.$(Selectors.ConnectionInfoModal); @@ -109,8 +109,8 @@ describe('Instance sidebar', function () { await browser.waitUntil(async () => { const numTreeItems = await browser.$$(Selectors.SidebarTreeItems).length; - // connection, database, collection for multiple connections (twice - // because there are two connections) + // connection, database, collection (twice because there are two + // connections) return numTreeItems === 6; }); @@ -147,8 +147,6 @@ describe('Instance sidebar', function () { // TODO(COMPASS-7086): flaky test this.retries(5); - const Sidebar = Selectors.Multiple; - const dbName = `my-sidebar-database-${Date.now()}`; const collectionName = 'my-collection'; @@ -163,7 +161,7 @@ describe('Instance sidebar', function () { // open the create database modal from the sidebar await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Sidebar.CreateDatabaseButton, + Selectors.CreateDatabaseButton, false ); @@ -242,7 +240,7 @@ describe('Instance sidebar', function () { await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); // wait for the new collection we added via the driver to appear. diff --git a/packages/compass-e2e-tests/tests/my-queries-tab.test.ts b/packages/compass-e2e-tests/tests/my-queries-tab.test.ts index b449d41e502..71709dc09d2 100644 --- a/packages/compass-e2e-tests/tests/my-queries-tab.test.ts +++ b/packages/compass-e2e-tests/tests/my-queries-tab.test.ts @@ -258,10 +258,10 @@ describe('My Queries tab', function () { await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); - // go to My Queries because for multiple connections it is not the default tab + // go to My Queries await browser.navigateToMyQueries(); // browse to the query @@ -389,7 +389,7 @@ describe('My Queries tab', function () { await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); await browser.navigateToMyQueries(); @@ -449,7 +449,7 @@ describe('My Queries tab', function () { await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); await browser.navigateToMyQueries(); @@ -495,11 +495,11 @@ describe('My Queries tab', function () { await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_2, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); await browser.navigateToMyQueries(); @@ -557,11 +557,11 @@ describe('My Queries tab', function () { await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); await browser.selectConnectionMenuItem( DEFAULT_CONNECTION_NAME_2, - Selectors.Multiple.RefreshDatabasesItem + Selectors.RefreshDatabasesItem ); await browser.navigateToMyQueries(); diff --git a/packages/compass-e2e-tests/tests/oidc.test.ts b/packages/compass-e2e-tests/tests/oidc.test.ts index 4f568795aeb..baba5ba92a4 100644 --- a/packages/compass-e2e-tests/tests/oidc.test.ts +++ b/packages/compass-e2e-tests/tests/oidc.test.ts @@ -257,17 +257,17 @@ describe('OIDC integration', function () { }; await browser.removeConnection(connectionName); - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); await browser.$(Selectors.ConnectionModal).waitForDisplayed(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString ); - await browser.clickVisible(Selectors.ConnectButton); + await browser.clickVisible(Selectors.ConnectionFormConnectButton); await once(emitter, 'authorizeEndpointCalled'); - await browser.closeConnectModal(); + await browser.clickVisible(Selectors.ConenctionToastCancelConnectionButton); overrideRequestHandler = () => {}; await browser.connectWithConnectionString(connectionString); @@ -315,13 +315,13 @@ describe('OIDC integration', function () { }; await browser.removeConnection(connectionName); - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); await browser.$(Selectors.ConnectionModal).waitForDisplayed(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString ); - await browser.clickVisible(Selectors.ConnectButton); + await browser.clickVisible(Selectors.ConnectionFormConnectButton); // wait for the token to expire (see expires_in above) await browser.pause(10_000); @@ -331,7 +331,7 @@ describe('OIDC integration', function () { // auth and then that will trigger the confirmation modal we expect. await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.OpenShellItem, + Selectors.OpenShellItem, false ); @@ -360,13 +360,13 @@ describe('OIDC integration', function () { }; await browser.removeConnection(connectionName); - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.clickVisible(Selectors.SidebarNewConnectionButton); await browser.$(Selectors.ConnectionModal).waitForDisplayed(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString ); - await browser.clickVisible(Selectors.ConnectButton); + await browser.clickVisible(Selectors.ConnectionFormConnectButton); // wait for the token to expire (see expires_in above) await browser.pause(10_000); @@ -376,7 +376,7 @@ describe('OIDC integration', function () { // auth and then that will trigger the confirmation modal we expect await browser.selectConnectionMenuItem( connectionName, - Selectors.Multiple.OpenShellItem, + Selectors.OpenShellItem, false ); diff --git a/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts b/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts index 69197382d29..e0ee4a9ed84 100644 --- a/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts +++ b/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts @@ -17,11 +17,10 @@ async function expectCopyConnectionStringToClipboard( favoriteName: string, expected: string ): Promise { - const Sidebar = Selectors.Multiple; if (!context.disableClipboardUsage) { await browser.selectConnectionMenuItem( favoriteName, - Sidebar.CopyConnectionStringItem + Selectors.CopyConnectionStringItem ); let actual = ''; await browser.waitUntil( diff --git a/packages/compass-e2e-tests/tests/read-only.test.ts b/packages/compass-e2e-tests/tests/read-only.test.ts index fcb2a96a4e7..69a444c78fd 100644 --- a/packages/compass-e2e-tests/tests/read-only.test.ts +++ b/packages/compass-e2e-tests/tests/read-only.test.ts @@ -35,7 +35,6 @@ describe('readOnly: true / Read-Only Edition', function () { }); it('hides and shows the plus icon on the sidebar to create a database', async function () { - const Sidebar = Selectors.Multiple; await browser.setFeature('readOnly', true); await browser.connectToDefaults(); @@ -50,7 +49,7 @@ describe('readOnly: true / Read-Only Edition', function () { expect( await browser.hasConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Sidebar.CreateDatabaseButton, + Selectors.CreateDatabaseButton, false ) ).to.be.equal(false); @@ -73,7 +72,7 @@ describe('readOnly: true / Read-Only Edition', function () { expect( await browser.hasConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Sidebar.CreateDatabaseButton, + Selectors.CreateDatabaseButton, false ) ).to.be.equal(true); diff --git a/packages/compass-e2e-tests/tests/shell.test.ts b/packages/compass-e2e-tests/tests/shell.test.ts index ea5ed6bfb94..4704c7bd5ae 100644 --- a/packages/compass-e2e-tests/tests/shell.test.ts +++ b/packages/compass-e2e-tests/tests/shell.test.ts @@ -68,7 +68,7 @@ describe('Shell', function () { expect( await browser.hasConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.OpenShellItem + Selectors.OpenShellItem ) ).to.be.equal(true); @@ -86,7 +86,7 @@ describe('Shell', function () { expect( await browser.hasConnectionMenuItem( DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.OpenShellItem + Selectors.OpenShellItem ) ).to.be.equal(false); }); diff --git a/packages/compass-preferences-model/src/preferences-schema.ts b/packages/compass-preferences-model/src/preferences-schema.ts index 7ff745b9a20..4e64d527446 100644 --- a/packages/compass-preferences-model/src/preferences-schema.ts +++ b/packages/compass-preferences-model/src/preferences-schema.ts @@ -70,7 +70,6 @@ export type UserConfigurablePreferences = PermanentFeatureFlags & enablePerformanceAdvisorBanner: boolean; maximumNumberOfActiveConnections?: number; enableShowDialogOnQuit: boolean; - enableMultipleConnectionSystem: boolean; enableCreatingNewConnections: boolean; enableProxySupport: boolean; proxy: string; @@ -809,18 +808,6 @@ export const storedUserPreferencesProps: Required<{ type: 'boolean', }, - enableMultipleConnectionSystem: { - ui: true, - cli: true, - global: true, - description: { - short: 'Enables support for multiple connections.', - long: 'Allows users to open multiple connections in the same window.', - }, - validator: z.boolean().default(true), - type: 'boolean', - }, - proxy: { ui: true, cli: true, diff --git a/packages/compass-saved-aggregations-queries/src/components/saved-item-card.test.tsx b/packages/compass-saved-aggregations-queries/src/components/saved-item-card.test.tsx index 48345609305..5af70e05bc9 100644 --- a/packages/compass-saved-aggregations-queries/src/components/saved-item-card.test.tsx +++ b/packages/compass-saved-aggregations-queries/src/components/saved-item-card.test.tsx @@ -122,41 +122,36 @@ describe('SavedItemCard', function () { ]); }); - context('when multi connections is enabled', function () { - it('should render an "Open in" action', async function () { - const preferences = await createSandboxFromDefaultPreferences(); - await preferences.savePreferences({ - enableMultipleConnectionSystem: true, - }); - const onAction = Sinon.spy(); - - render( - - - - ); - - userEvent.hover(screen.getByText('My Awesome Query')); - userEvent.click( - screen.getByRole('button', { - name: /show actions/i, - }) - ); - userEvent.click(screen.getByText('Open in')); - - expect(onAction).to.have.callCount(1); - expect(onAction.getCalls().map((call) => call.args)).to.deep.eq([ - ['123', 'open-in'], - ]); - }); + it('should render an "Open in" action', async function () { + const preferences = await createSandboxFromDefaultPreferences(); + const onAction = Sinon.spy(); + + render( + + + + ); + + userEvent.hover(screen.getByText('My Awesome Query')); + userEvent.click( + screen.getByRole('button', { + name: /show actions/i, + }) + ); + userEvent.click(screen.getByText('Open in')); + + expect(onAction).to.have.callCount(1); + expect(onAction.getCalls().map((call) => call.args)).to.deep.eq([ + ['123', 'open-in'], + ]); }); }); diff --git a/packages/compass-saved-aggregations-queries/src/components/saved-item-card.tsx b/packages/compass-saved-aggregations-queries/src/components/saved-item-card.tsx index 4ae3d90d164..c14c9364d69 100644 --- a/packages/compass-saved-aggregations-queries/src/components/saved-item-card.tsx +++ b/packages/compass-saved-aggregations-queries/src/components/saved-item-card.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useMemo } from 'react'; +import React, { useCallback } from 'react'; import type { MenuAction } from '@mongodb-js/compass-components'; import { cx, useDarkMode } from '@mongodb-js/compass-components'; import { @@ -18,7 +18,6 @@ import { useFormattedDate, } from '@mongodb-js/compass-components'; import type { Item } from '../stores/aggregations-queries-items'; -import { usePreference } from 'compass-preferences-model/provider'; export type Action = 'open' | SavedItemAction; @@ -132,10 +131,12 @@ const lastModifiedLabel = css({ }); type SavedItemAction = 'copy' | 'rename' | 'delete' | 'open-in'; + const savedItemActions: MenuAction[] = [ { action: 'copy', label: 'Copy' }, { action: 'rename', label: 'Rename' }, { action: 'delete', label: 'Delete' }, + { action: 'open-in', label: 'Open in' }, ]; const CardActions: React.FunctionComponent<{ @@ -143,15 +144,6 @@ const CardActions: React.FunctionComponent<{ isVisible: boolean; onAction: SavedItemCardProps['onAction']; }> = ({ itemId, isVisible, onAction }) => { - const multiConnectionsEnabled = usePreference( - 'enableMultipleConnectionSystem' - ); - const actions: MenuAction[] = useMemo(() => { - return multiConnectionsEnabled - ? [...savedItemActions, { action: 'open-in', label: 'Open in' }] - : [...savedItemActions]; - }, [multiConnectionsEnabled]); - const onMenuItemClick = useCallback( (action: SavedItemAction) => { onAction(itemId, action); @@ -163,7 +155,7 @@ const CardActions: React.FunctionComponent<{ data-testid="saved-item-actions" isVisible={isVisible} - actions={actions} + actions={savedItemActions} onAction={onMenuItemClick} > ); diff --git a/packages/compass-saved-aggregations-queries/src/index.spec.tsx b/packages/compass-saved-aggregations-queries/src/index.spec.tsx index 8cf1cd97947..2547dd18d96 100644 --- a/packages/compass-saved-aggregations-queries/src/index.spec.tsx +++ b/packages/compass-saved-aggregations-queries/src/index.spec.tsx @@ -85,9 +85,6 @@ describe('AggregationsQueriesList', function () { }); const result = renderWithConnections(, { connections: [connectionOne.connectionInfo, connectionTwo.connectionInfo], - preferences: { - enableMultipleConnectionSystem: true, - }, }); connectionsStore = result.connectionsStore; }; diff --git a/packages/compass-shell/src/plugin.spec.tsx b/packages/compass-shell/src/plugin.spec.tsx index 9179731d68e..3aee5e1a8fd 100644 --- a/packages/compass-shell/src/plugin.spec.tsx +++ b/packages/compass-shell/src/plugin.spec.tsx @@ -1,29 +1,22 @@ import React from 'react'; import { expect } from 'chai'; +import { EventEmitter } from 'events'; import { CompassShellPlugin } from './index'; import { - cleanup, renderWithActiveConnection, screen, waitFor, } from '@mongodb-js/testing-library-compass'; +import { RuntimeMap } from './stores/store'; describe('CompassShellPlugin', function () { - afterEach(() => { - cleanup(); - }); + it('returns a renderable plugin', async function () { + RuntimeMap.set('test', { + eventEmitter: new EventEmitter(), + terminate() {}, + } as any); - // TODO(COMPASS-7906): remove - it.skip('returns a renderable plugin', async function () { - await renderWithActiveConnection(, undefined, { - connectFn() { - return { - getMongoClientConnectionOptions() { - return { url: '', options: {} }; - }, - }; - }, - }); + await renderWithActiveConnection(); await waitFor(() => { expect(screen.getByTestId('shell-section')).to.exist; diff --git a/packages/compass-shell/src/plugin.tsx b/packages/compass-shell/src/plugin.tsx index 1d70cf9ddc5..797997d5513 100644 --- a/packages/compass-shell/src/plugin.tsx +++ b/packages/compass-shell/src/plugin.tsx @@ -22,6 +22,7 @@ import { Theme, ThemeProvider } from '@mongodb-js/compass-components'; const SHELL_THEME = { theme: Theme.Dark, enabled: true }; type ShellPluginProps = { + runtimeId?: string; initialEvaluate?: string | string[]; initialInput?: string; }; @@ -47,7 +48,7 @@ export type ShellPluginExtraArgs = ShellPluginServices & { }; export function onActivated( - _initialProps: ShellPluginProps, + initialProps: ShellPluginProps, services: ShellPluginServices, { addCleanup, cleanup }: ActivateHelpers ) { @@ -57,7 +58,8 @@ export function onActivated( reducer, { runtimeId: preferences.getPreferences().enableShell - ? createAndStoreRuntime(dataService, logger, track, connectionInfo).id + ? initialProps.runtimeId ?? + createAndStoreRuntime(dataService, logger, track, connectionInfo).id : null, history: null, }, diff --git a/packages/compass-shell/src/stores/store.ts b/packages/compass-shell/src/stores/store.ts index 63482a4f239..9eafd29d12d 100644 --- a/packages/compass-shell/src/stores/store.ts +++ b/packages/compass-shell/src/stores/store.ts @@ -6,7 +6,10 @@ import { ObjectId } from 'bson'; import { createWorkerRuntime } from '../modules/worker-runtime'; import type { ShellPluginExtraArgs } from '../plugin'; -const RuntimeMap = new Map(); +/** + * @internal exported for testing purposes + */ +export const RuntimeMap = new Map(); type State = { // Reference to the shell runtime stored by id diff --git a/packages/compass-sidebar/src/components/multiple-connections/sidebar.spec.tsx b/packages/compass-sidebar/src/components/multiple-connections/sidebar.spec.tsx index e0f388a0e2e..46c733c58dc 100644 --- a/packages/compass-sidebar/src/components/multiple-connections/sidebar.spec.tsx +++ b/packages/compass-sidebar/src/components/multiple-connections/sidebar.spec.tsx @@ -131,7 +131,6 @@ describe('Multiple Connections Sidebar Component', function () { } const result = renderWithConnections(component, { - preferences: { enableMultipleConnectionSystem: true }, connections, connectFn() { return { diff --git a/packages/compass-web/src/preferences.tsx b/packages/compass-web/src/preferences.tsx index 0714a4ee1ed..4bfe0cd6232 100644 --- a/packages/compass-web/src/preferences.tsx +++ b/packages/compass-web/src/preferences.tsx @@ -47,7 +47,6 @@ export function useCompassWebPreferences( enableGenAIFeaturesAtlasProject: false, enableGenAISampleDocumentPassingOnAtlasProject: false, enableGenAIFeaturesAtlasOrg: false, - enableMultipleConnectionSystem: true, enablePerformanceAdvisorBanner: true, cloudFeatureRolloutAccess: { GEN_AI_COMPASS: false, diff --git a/packages/compass-workspaces/package.json b/packages/compass-workspaces/package.json index 1bd913b85c9..c3f77033aee 100644 --- a/packages/compass-workspaces/package.json +++ b/packages/compass-workspaces/package.json @@ -56,7 +56,6 @@ "@mongodb-js/compass-connections": "^1.49.1", "@mongodb-js/compass-logging": "^1.5.1", "bson": "^6.10.1", - "compass-preferences-model": "^2.32.1", "hadron-app-registry": "^9.3.1", "lodash": "^4.17.21", "mongodb-collection-model": "^5.24.1", diff --git a/packages/compass-workspaces/src/components/workspaces.tsx b/packages/compass-workspaces/src/components/workspaces.tsx index 8f1bd7ebcf1..5e6be8be8b0 100644 --- a/packages/compass-workspaces/src/components/workspaces.tsx +++ b/packages/compass-workspaces/src/components/workspaces.tsx @@ -40,7 +40,6 @@ import { ConnectionInfoProvider, useTabConnectionTheme, } from '@mongodb-js/compass-connections/provider'; -import { usePreference } from 'compass-preferences-model/provider'; import { useConnectionsListRef } from '@mongodb-js/compass-connections/provider'; type Tooltip = [string, string][]; @@ -157,9 +156,6 @@ const CompassWorkspaces: React.FunctionComponent = ({ const { getWorkspacePluginByName } = useWorkspacePlugins(); const { getThemeOf } = useTabConnectionTheme(); const { getConnectionById } = useConnectionsListRef(); - const multipleConnectionsEnabled = usePreference( - 'enableMultipleConnectionSystem' - ); const tabDescriptions = useMemo(() => { return tabs.map((tab) => { @@ -204,7 +200,7 @@ const CompassWorkspaces: React.FunctionComponent = ({ id: tab.id, connectionName, type: tab.type, - title: multipleConnectionsEnabled ? connectionName : tab.type, + title: connectionName, tooltip: [['Connection', connectionName || '']] as Tooltip, iconGlyph: 'Server', tabTheme: getThemeOf(tab.connectionId), @@ -217,9 +213,7 @@ const CompassWorkspaces: React.FunctionComponent = ({ id: tab.id, connectionName, type: tab.type, - title: multipleConnectionsEnabled - ? `Performance: ${connectionName}` - : tab.type, + title: `Performance: ${connectionName}`, tooltip: [['Performance', connectionName || '']] as Tooltip, iconGlyph: 'Gauge', tabTheme: getThemeOf(tab.connectionId), @@ -286,13 +280,7 @@ const CompassWorkspaces: React.FunctionComponent = ({ } } }); - }, [ - tabs, - collectionInfo, - getThemeOf, - getConnectionById, - multipleConnectionsEnabled, - ]); + }, [tabs, collectionInfo, getThemeOf, getConnectionById]); const activeTabIndex = tabs.findIndex((tab) => tab === activeTab); diff --git a/packages/compass-workspaces/src/index.spec.tsx b/packages/compass-workspaces/src/index.spec.tsx index e243a11dad0..7ee10abb955 100644 --- a/packages/compass-workspaces/src/index.spec.tsx +++ b/packages/compass-workspaces/src/index.spec.tsx @@ -67,9 +67,6 @@ describe('WorkspacesPlugin', function () { > , { - preferences: { - enableMultipleConnectionSystem: true, - }, connections: [TEST_CONNECTION_INFO], connectFn() { return { diff --git a/packages/compass/src/app/components/home.spec.tsx b/packages/compass/src/app/components/home.spec.tsx index c9ef7487ae3..683afe968a8 100644 --- a/packages/compass/src/app/components/home.spec.tsx +++ b/packages/compass/src/app/components/home.spec.tsx @@ -6,7 +6,6 @@ import type { DataService } from 'mongodb-data-service'; import { WithAtlasProviders } from './entrypoint'; import { renderWithConnections, - cleanup, screen, waitFor, within, @@ -67,7 +66,6 @@ describe('Home [Component]', function () { preferences: { showedNetworkOptIn: true, networkTraffic: true, - enableMultipleConnectionSystem: false, ...preferences, }, connectFn: () => { @@ -80,7 +78,6 @@ describe('Home [Component]', function () { } afterEach(() => { - cleanup(); sinon.restore(); }); @@ -110,14 +107,10 @@ describe('Home [Component]', function () { expect(showSettingsSpy.callCount).to.equal(1); }); - describe('and multi connections is enabled', function () { - it('renders only the workspaces', function () { - renderHome({}, [], createDataService(), { - enableMultipleConnectionSystem: true, - }); - expect(screen.getByTestId('home')).to.be.displayed; - expect(() => screen.getByTestId('connections-wrapper')).to.throw; - }); + it('renders only the workspaces', function () { + renderHome({}, [], createDataService()); + expect(screen.getByTestId('home')).to.be.displayed; + expect(() => screen.getByTestId('connections-wrapper')).to.throw(); }); }); }); diff --git a/packages/compass/src/app/components/home.tsx b/packages/compass/src/app/components/home.tsx index e018b09abd7..f4ef1537823 100644 --- a/packages/compass/src/app/components/home.tsx +++ b/packages/compass/src/app/components/home.tsx @@ -108,7 +108,7 @@ function Home({
- + ['onActiveWorkspaceTabChange']; }): React.ReactElement { - const multiConnectionsEnabled = usePreference( - 'enableMultipleConnectionSystem' - ); - const { getConnectionById } = useConnectionsListRef(); const onWorkspaceTabChange = useCallback( @@ -106,9 +101,7 @@ export default function Workspace({ ]} > } renderModals={() => ( diff --git a/packages/compass/src/main/menu.spec.ts b/packages/compass/src/main/menu.spec.ts index c216cc3199f..0b12470abd5 100644 --- a/packages/compass/src/main/menu.spec.ts +++ b/packages/compass/src/main/menu.spec.ts @@ -287,10 +287,7 @@ describe('CompassMenu', function () { } }); - it('should generate a menu template for darwin', async function () { - await App.preferences.savePreferences({ - enableMultipleConnectionSystem: true, - }); + it('should generate a menu template for darwin', function () { sinon.stub(process, 'platform').value('darwin'); expect(serializable(CompassMenu.getTemplate(0))).to.deep.equal([ { diff --git a/packages/compass/src/main/menu.ts b/packages/compass/src/main/menu.ts index 88e4563f5d7..535ed2ea4f2 100644 --- a/packages/compass/src/main/menu.ts +++ b/packages/compass/src/main/menu.ts @@ -132,18 +132,6 @@ function darwinCompassSubMenu( }; } -function newWindowItem( - app: typeof CompassApplication -): MenuItemConstructorOptions { - return { - label: 'New &Window', - accelerator: 'CmdOrCtrl+N', - click() { - app.emit('show-connect-window'); - }, - }; -} - function connectSubMenu( nonDarwin: boolean, app: typeof CompassApplication @@ -427,10 +415,14 @@ function viewSubMenu( function windowSubMenu( app: typeof CompassApplication ): MenuItemConstructorOptions { - const { enableMultipleConnectionSystem: isMultiConnectionsEnabled } = - app.preferences.getPreferences(); - const submenu: MenuTemplate = [ + { + label: 'New &Window', + accelerator: 'CmdOrCtrl+N', + click() { + app.emit('show-connect-window'); + }, + }, { label: 'Minimize', accelerator: 'Command+M', @@ -448,8 +440,6 @@ function windowSubMenu( }, ]; - if (isMultiConnectionsEnabled) submenu.unshift(newWindowItem(app)); - return { label: 'Window', submenu, diff --git a/packages/databases-collections-list/src/items-grid.tsx b/packages/databases-collections-list/src/items-grid.tsx index 704cd98165a..a1a383b4bf3 100644 --- a/packages/databases-collections-list/src/items-grid.tsx +++ b/packages/databases-collections-list/src/items-grid.tsx @@ -160,12 +160,7 @@ const GridControls: React.FunctionComponent<{ openShellWorkspace, } = useOpenWorkspace(); const track = useTelemetry(); - const { enableShell, enableMultipleConnectionSystem } = usePreferences([ - 'enableShell', - 'enableMultipleConnectionSystem', - ]); - - const showOpenShellButton = enableShell && enableMultipleConnectionSystem; + const { enableShell: showOpenShellButton } = usePreferences(['enableShell']); const breadcrumbs = useMemo(() => { const { database } = toNS(namespace ?? '');