Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/compass-workspaces/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export type WorkspacesService = {
options?: TabOptions &
Omit<
Extract<OpenWorkspaceOptions, { type: 'Collection' }>,
'type' | 'namespace' | 'editViewName' | 'initialSubtab' | 'connectionId'
'type' | 'namespace' | 'editViewName' | 'connectionId'
>
): void;
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-workspaces/src/stores/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const getInitialTabState = (
);

const subTab =
initialSubtab ?? isAggregationsSubtab ? 'Aggregations' : 'Documents';
initialSubtab ?? (isAggregationsSubtab ? 'Aggregations' : 'Documents');

return {
id: tabId,
Expand Down
19 changes: 14 additions & 5 deletions packages/databases-collections/src/modules/create-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down
Loading