diff --git a/packages/compass-workspaces/src/provider.tsx b/packages/compass-workspaces/src/provider.tsx index fb9bcca6211..d9c6f5bae6a 100644 --- a/packages/compass-workspaces/src/provider.tsx +++ b/packages/compass-workspaces/src/provider.tsx @@ -92,7 +92,7 @@ export type WorkspacesService = { options?: TabOptions & Omit< Extract, - 'type' | 'namespace' | 'editViewName' | 'initialSubtab' | 'connectionId' + 'type' | 'namespace' | 'editViewName' | 'connectionId' > ): void; /** diff --git a/packages/compass-workspaces/src/stores/workspaces.ts b/packages/compass-workspaces/src/stores/workspaces.ts index 924e2a14240..8d9a208141c 100644 --- a/packages/compass-workspaces/src/stores/workspaces.ts +++ b/packages/compass-workspaces/src/stores/workspaces.ts @@ -220,7 +220,7 @@ export const getInitialTabState = ( ); const subTab = - initialSubtab ?? isAggregationsSubtab ? 'Aggregations' : 'Documents'; + initialSubtab ?? (isAggregationsSubtab ? 'Aggregations' : 'Documents'); return { id: tabId, diff --git a/packages/databases-collections/src/modules/create-namespace.ts b/packages/databases-collections/src/modules/create-namespace.ts index e3aa5aa2a0e..b3691509d10 100644 --- a/packages/databases-collections/src/modules/create-namespace.ts +++ b/packages/databases-collections/src/modules/create-namespace.ts @@ -2,6 +2,8 @@ import type { Action, AnyAction, Reducer } from 'redux'; import { parseFilter } from 'mongodb-query-parser'; import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { CreateNamespaceThunkAction } from '../stores/create-namespace'; +import { connectionSupports } from '@mongodb-js/compass-connections'; +import toNS from 'mongodb-ns'; /** * No dots in DB name error message. @@ -402,17 +404,24 @@ export const createNamespace = ( expires: !!data.options.expireAfterSeconds, }; - track( - `${kind} Created`, - trackEvent, - connectionRepository.getConnectionInfoById(connectionId) - ); + const connectionInfo = + connectionRepository.getConnectionInfoById(connectionId); + + track(`${kind} Created`, trackEvent, connectionInfo); globalAppRegistry.emit('collection-created', namespace, { connectionId, }); + + // For special namespaces (admin, local, config), we do not want + // to navigate user to the global-writes tab if it's supported. + const isSpecialNS = toNS(namespace).isSpecial; + const isGlobalWritesSupported = + connectionInfo && connectionSupports(connectionInfo, 'globalWrites'); workspaces.openCollectionWorkspace(connectionId, namespace, { newTab: true, + initialSubtab: + !isSpecialNS && isGlobalWritesSupported ? 'GlobalWrites' : undefined, }); dispatch(reset()); } catch (e) {