Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/collection-model/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ interface CollectionProps {
sourceName: string | null;
source: Collection;
properties: { id: string; options?: Record<string, unknown> }[];
is_non_existent: boolean;
is_ghost_namespace: boolean;
}

type CollectionDataService = Pick<
Expand Down
18 changes: 12 additions & 6 deletions packages/collection-model/lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function pickCollectionInfo({
validation,
clustered,
fle2,
is_non_existent,
is_ghost_namespace,
}) {
return {
type,
Expand All @@ -113,7 +113,7 @@ function pickCollectionInfo({
validation,
clustered,
fle2,
is_non_existent,
is_ghost_namespace,
};
}

Expand All @@ -135,7 +135,7 @@ const CollectionModel = AmpersandModel.extend(debounceActions(['fetch']), {
statusError: { type: 'string', default: null },

// Normalized values from collectionInfo command
is_non_existent: 'boolean',
is_ghost_namespace: 'boolean',
readonly: 'boolean',
clustered: 'boolean',
fle2: 'boolean',
Expand Down Expand Up @@ -286,14 +286,14 @@ const CollectionModel = AmpersandModel.extend(debounceActions(['fetch']), {
...collStats,
...(collectionInfo && pickCollectionInfo(collectionInfo)),
});
// If the collection is not unprovisioned `is_non_existent` anymore,
// If the collection is not unprovisioned `is_ghost_namespace` anymore,
// let's update the parent database model to reflect the change.
// This happens when a user tries to insert first document into a
// collection that doesn't exist yet or creates a new collection
// for an unprovisioned database.
if (!this.is_non_existent) {
if (!this.is_ghost_namespace) {
getParentByType(this, 'Database').set({
is_non_existent: false,
is_ghost_namespace: false,
});
}
} catch (err) {
Expand Down Expand Up @@ -385,6 +385,11 @@ const CollectionCollection = AmpersandCollection.extend(
async fetch({ dataService }) {
const databaseName = getParentByType(this, 'Database')?.getId();

const shouldFetchNamespacesFromPrivileges = getParentByType(
this,
'Instance'
).shouldFetchNamespacesFromPrivileges;

if (!databaseName) {
throw new Error(
`Trying to fetch ${this.modelType} that doesn't have the Database parent model`
Expand All @@ -405,6 +410,7 @@ const CollectionCollection = AmpersandCollection.extend(
{
// Always fetch collections with info
nameOnly: false,
fetchNamespacesFromPrivileges: shouldFetchNamespacesFromPrivileges,
privileges: instanceModel.auth.privileges,
}
);
Expand Down
10 changes: 10 additions & 0 deletions packages/compass-app-stores/src/stores/instance-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ export function createInstancesStore(
}
);

preferences.onPreferenceValueChanged('inferNamespacesFromPrivileges', () => {
const connectedConnectionIds = Array.from(
instancesManager.listMongoDBInstances().keys()
);

for (const connectionId of connectedConnectionIds) {
void refreshDatabases({ connectionId });
}
});

on(connections, 'disconnected', function (connectionInfoId: string) {
try {
const instance =
Expand Down
6 changes: 3 additions & 3 deletions packages/compass-collection/src/plugin-tab-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type PluginTitleProps = {

function PluginTitle({
editViewName,
isNonExistent,
isGhostNamespace,
isReadonly,
isTimeSeries,
sourceName,
Expand Down Expand Up @@ -68,12 +68,12 @@ function PluginTitle({
? 'Visibility'
: collectionType === 'timeseries'
? 'TimeSeries'
: isNonExistent
: isGhostNamespace
? 'EmptyFolder'
: 'Folder'
}
data-namespace={ns}
isNonExistent={isNonExistent}
isGhostNamespace={isGhostNamespace}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export type WorkspaceTabPluginProps = {
connectionName?: string;
type: string;
title: React.ReactNode;
isNonExistent?: boolean;
isGhostNamespace?: boolean;
iconGlyph: GlyphName | 'Logo' | 'Server';
tooltip?: [string, string][];
};
Expand All @@ -206,7 +206,7 @@ function Tab({
type,
title,
tooltip,
isNonExistent,
isGhostNamespace,
isSelected,
isDragging,
onSelect,
Expand Down Expand Up @@ -271,7 +271,7 @@ function Tab({
className={cx(
tabStyles,
themeClass,
isNonExistent && nonExistentStyles,
isGhostNamespace && nonExistentStyles,
isSelected && selectedTabStyles,
isSelected && tabTheme && selectedThemedTabStyles,
isDragging && draggingTabStyles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const connections: Connection[] = [
collectionsStatus: 'initial',
collectionsLength: 5,
collections: [],
isNonExistent: false,
isGhostNamespace: false,
},
{
_id: 'db_ready',
Expand All @@ -57,26 +57,26 @@ const connections: Connection[] = [
type: 'collection',
sourceName: '',
pipeline: [],
isNonExistent: false,
isGhostNamespace: false,
},
{
_id: 'db_ready.woof',
name: 'woof',
type: 'timeseries',
sourceName: '',
pipeline: [],
isNonExistent: false,
isGhostNamespace: false,
},
{
_id: 'db_ready.bwok',
name: 'bwok',
type: 'view',
sourceName: '',
pipeline: [],
isNonExistent: false,
isGhostNamespace: false,
},
],
isNonExistent: false,
isGhostNamespace: false,
},
],
isReady: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const IconWithTooltip = ({

export const NavigationItemIcon = ({ item }: { item: SidebarTreeItem }) => {
if (item.type === 'database') {
if (item.isNonExistent) {
if (item.isGhostNamespace) {
return (
<IconWithTooltip
text={NON_EXISTANT_NAMESPACE_TEXT}
Expand All @@ -46,7 +46,7 @@ export const NavigationItemIcon = ({ item }: { item: SidebarTreeItem }) => {
return <Icon glyph="Database" />;
}
if (item.type === 'collection') {
if (item.isNonExistent) {
if (item.isGhostNamespace) {
return (
<IconWithTooltip
text={NON_EXISTANT_NAMESPACE_TEXT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,26 @@ export default function StyledNavigationItem({
!showDisabledConnections || getConnectable(connectionId);
const isDisconnectedConnection =
item.type === 'connection' && item.connectionStatus !== 'connected';
const isNonExistentNamespace =
const isGhostNamespaceNamespace =
(item.type === 'database' || item.type === 'collection') &&
item.isNonExistent;
item.isGhostNamespace;

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 || isNonExistentNamespace || !isConnectable) {
if (
isDisconnectedConnection ||
isGhostNamespaceNamespace ||
!isConnectable
) {
style['--item-color'] = inactiveColor;
}

// We always show these as inactive
if (isNonExistentNamespace || !isConnectable) {
if (isGhostNamespaceNamespace || !isConnectable) {
style['--item-color-active'] = inactiveColor;
}
return style;
Expand Down
Loading
Loading