Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 9 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,7 @@ 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';

/**
* No dots in DB name error message.
Expand Down Expand Up @@ -402,17 +403,20 @@ 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,
});
workspaces.openCollectionWorkspace(connectionId, namespace, {
newTab: true,
initialSubtab:
connectionInfo && connectionSupports(connectionInfo, 'globalWrites')
Copy link
Collaborator

@paula-stacho paula-stacho Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connectionSupports won't be sufficient. we'll need to filter out the admin/config/local collections and also views. adding @djechlin-mongodb, we'll need to sync this with the hiding of the tab
more context: https://mongodb.slack.com/archives/C03DU5ATTB6/p1729869659313749

Copy link
Collaborator

@paula-stacho paula-stacho Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for only realising this now 🙈

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't create views through this modal and I'm pretty sure that even db users with admin roles can't create collections inside special-ish namespaces (but for anything that is defined as special-ish by mongodb-ns package we probably can add a filter here, yeah)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right, thanks @gribnoysup !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in 0d124af

? 'GlobalWrites'
: undefined,
});
dispatch(reset());
} catch (e) {
Expand Down
Loading