Skip to content

Commit 32f9ae5

Browse files
committed
rename property
1 parent a387b72 commit 32f9ae5

File tree

17 files changed

+118
-138
lines changed

17 files changed

+118
-138
lines changed

packages/collection-model/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ interface CollectionProps {
8181
/** Only relevant for a view and identifies collection/view from which this view was created. */
8282
sourceName: string | null;
8383
source: Collection;
84-
properties: { id: string; options?: unknown }[];
85-
ns_source: 'provisioned' | 'privileges';
84+
properties: { id: string; options?: Record<string, unknown> }[];
85+
is_non_existant: boolean;
8686
}
8787

8888
type CollectionDataService = Pick<DataService, 'collectionStats' | 'collectionInfo' | 'listCollections' | 'isListSearchIndexesSupported'>;

packages/collection-model/lib/model.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ function pickCollectionInfo({
102102
validation,
103103
clustered,
104104
fle2,
105-
ns_source,
105+
is_non_existant,
106106
}) {
107-
return { type, readonly, view_on, collation, pipeline, validation, clustered, fle2, ns_source };
107+
return { type, readonly, view_on, collation, pipeline, validation, clustered, fle2, is_non_existant };
108108
}
109109

110110
/**
@@ -125,7 +125,7 @@ const CollectionModel = AmpersandModel.extend(debounceActions(['fetch']), {
125125
statusError: { type: 'string', default: null },
126126

127127
// Normalized values from collectionInfo command
128-
ns_source: 'string',
128+
is_non_existant: 'boolean',
129129
readonly: 'boolean',
130130
clustered: 'boolean',
131131
fle2: 'boolean',

packages/compass-connections-navigation/src/navigation-item-icon.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { GlyphName } from '@mongodb-js/compass-components';
55
import { WithStatusMarker } from './with-status-marker';
66
import { isLocalhost } from 'mongodb-build-info';
77

8-
const UNPROVISIONED_NAMESPACE_TEXT =
8+
const NON_EXISTANT_NAMESPACE_TEXT =
99
'You have privileges to this namespace, but it is not in your list of current namespaces';
1010

1111
const tooltipTriggerStyles = css({
@@ -35,26 +35,26 @@ const IconWithTooltip = ({
3535

3636
export const NavigationItemIcon = ({ item }: { item: SidebarTreeItem }) => {
3737
if (item.type === 'database') {
38-
if (item.ns_source === 'provisioned') {
39-
return <Icon glyph="Database" />;
38+
if (item.isNonExistant) {
39+
return (
40+
<IconWithTooltip
41+
text={NON_EXISTANT_NAMESPACE_TEXT}
42+
glyph="EmptyDatabase"
43+
/>
44+
);
4045
}
41-
return (
42-
<IconWithTooltip
43-
text={UNPROVISIONED_NAMESPACE_TEXT}
44-
glyph="EmptyDatabase"
45-
/>
46-
);
46+
return <Icon glyph="Database" />;
4747
}
4848
if (item.type === 'collection') {
49-
if (item.ns_source === 'provisioned') {
50-
return <Icon glyph="Folder" />;
49+
if (item.isNonExistant) {
50+
return (
51+
<IconWithTooltip
52+
text={NON_EXISTANT_NAMESPACE_TEXT}
53+
glyph="EmptyFolder"
54+
/>
55+
);
5156
}
52-
return (
53-
<IconWithTooltip
54-
text={UNPROVISIONED_NAMESPACE_TEXT}
55-
glyph="EmptyFolder"
56-
/>
57-
);
57+
return <Icon glyph="Folder" />;
5858
}
5959
if (item.type === 'view') {
6060
return <Icon glyph="Visibility" />;

packages/compass-connections-navigation/src/styled-navigation-item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export default function StyledNavigationItem({
3535
const isDisconnectedConnection =
3636
item.type === 'connection' && item.connectionStatus !== 'connected';
3737
const isNonExistantNamespace =
38-
item.type === 'database' ||
39-
(item.type === 'collection' && item.ns_source !== 'provisioned');
38+
(item.type === 'database' || item.type === 'collection') &&
39+
item.isNonExistant;
4040

4141
if (colorCode && colorCode !== DefaultColorCode) {
4242
style['--item-bg-color'] = connectionColorToHex(colorCode);

packages/compass-connections-navigation/src/tree-data.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type Database = {
5454
collectionsStatus: DatabaseOrCollectionStatus;
5555
collectionsLength: number;
5656
collections: Collection[];
57-
ns_source: 'provisioned' | 'privileges' | 'roles';
57+
isNonExistant: boolean;
5858
};
5959

6060
type PlaceholderTreeItem = VirtualPlaceholderItem & {
@@ -68,7 +68,7 @@ export type Collection = {
6868
type: 'view' | 'collection' | 'timeseries';
6969
sourceName: string | null;
7070
pipeline: unknown[];
71-
ns_source: 'provisioned' | 'privileges';
71+
isNonExistant: boolean;
7272
};
7373

7474
export type NotConnectedConnectionTreeItem = VirtualTreeItem & {
@@ -102,7 +102,7 @@ export type DatabaseTreeItem = VirtualTreeItem & {
102102
connectionId: string;
103103
dbName: string;
104104
hasWriteActionsDisabled: boolean;
105-
ns_source: Database['ns_source'];
105+
isNonExistant: boolean;
106106
};
107107

108108
export type CollectionTreeItem = VirtualTreeItem & {
@@ -113,7 +113,7 @@ export type CollectionTreeItem = VirtualTreeItem & {
113113
connectionId: string;
114114
namespace: string;
115115
hasWriteActionsDisabled: boolean;
116-
ns_source: Collection['ns_source'];
116+
isNonExistant: boolean;
117117
};
118118

119119
export type SidebarActionableItem =
@@ -249,7 +249,7 @@ const databaseToItems = ({
249249
collections,
250250
collectionsLength,
251251
collectionsStatus,
252-
ns_source,
252+
isNonExistant,
253253
},
254254
connectionId,
255255
expandedItems = {},
@@ -282,7 +282,7 @@ const databaseToItems = ({
282282
dbName: id,
283283
isExpandable: true,
284284
hasWriteActionsDisabled,
285-
ns_source,
285+
isNonExistant,
286286
};
287287

288288
const sidebarData: SidebarTreeItem[] = [databaseTI];
@@ -310,20 +310,22 @@ const databaseToItems = ({
310310
}
311311

312312
return sidebarData.concat(
313-
collections.map(({ _id: id, name, type, ns_source }, collectionIndex) => ({
314-
id: `${connectionId}.${id}`, // id is the namespace of the collection, so includes db as well
315-
level: level + 1,
316-
name,
317-
type,
318-
setSize: collectionsLength,
319-
posInSet: collectionIndex + 1,
320-
colorCode,
321-
connectionId,
322-
namespace: id,
323-
hasWriteActionsDisabled,
324-
isExpandable: false,
325-
ns_source,
326-
}))
313+
collections.map(
314+
({ _id: id, name, type, isNonExistant }, collectionIndex) => ({
315+
id: `${connectionId}.${id}`, // id is the namespace of the collection, so includes db as well
316+
level: level + 1,
317+
name,
318+
type,
319+
setSize: collectionsLength,
320+
posInSet: collectionIndex + 1,
321+
colorCode,
322+
connectionId,
323+
namespace: id,
324+
hasWriteActionsDisabled,
325+
isExpandable: false,
326+
isNonExistant,
327+
})
328+
)
327329
);
328330
};
329331

packages/compass-sidebar/src/modules/databases.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,21 @@ export type DatabasesAction =
3939
| FetchAllCollectionsAction
4040
| ExpandDatabaseAction;
4141

42-
type DatabaseRaw = MongoDBInstance['databases'][number];
42+
export type InstanceDatabase = MongoDBInstance['databases'][number];
4343

4444
export type Database = Pick<
45-
DatabaseRaw,
46-
'_id' | 'name' | 'collectionsStatus' | 'collectionsLength' | 'ns_source'
45+
InstanceDatabase,
46+
'_id' | 'name' | 'collectionsStatus' | 'collectionsLength'
4747
> & {
48-
collections: Pick<
49-
DatabaseRaw['collections'][number],
50-
'_id' | 'name' | 'type' | 'sourceName' | 'pipeline' | 'ns_source'
51-
>[];
48+
isNonExistant: boolean;
49+
collections: Array<
50+
Pick<
51+
InstanceDatabase['collections'][number],
52+
'_id' | 'name' | 'type' | 'sourceName' | 'pipeline'
53+
> & {
54+
isNonExistant: boolean;
55+
}
56+
>;
5257
};
5358
export type AllDatabasesState = Record<
5459
ConnectionInfo['id'],

packages/compass-sidebar/src/modules/instance.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { MongoDBInstance } from 'mongodb-instance-model';
22
import type { RootAction, SidebarThunkAction } from '.';
33
import { type ConnectionInfo } from '@mongodb-js/connection-info';
44
import throttle from 'lodash/throttle';
5-
import { type Database, changeDatabases } from './databases';
5+
import { type InstanceDatabase, changeDatabases } from './databases';
66
import { changeConnectionOptions } from './connection-options';
77
import { setIsPerformanceTabSupported } from './is-performance-tab-supported';
88
import type { MongoServerError } from 'mongodb';
@@ -126,24 +126,24 @@ export const setupInstance =
126126
{ leading: true, trailing: true }
127127
);
128128

129-
function getDatabaseInfo(db: Database) {
129+
function getDatabaseInfo(db: InstanceDatabase) {
130130
return {
131131
_id: db._id,
132132
name: db.name,
133133
collectionsStatus: db.collectionsStatus,
134134
collectionsLength: db.collectionsLength,
135-
ns_source: db.ns_source,
135+
isNonExistant: db.is_non_existant,
136136
};
137137
}
138138

139-
function getCollectionInfo(coll: Database['collections'][number]) {
139+
function getCollectionInfo(coll: InstanceDatabase['collections'][number]) {
140140
return {
141141
_id: coll._id,
142142
name: coll.name,
143143
type: coll.type,
144144
sourceName: coll.sourceName,
145145
pipeline: coll.pipeline,
146-
ns_source: coll.ns_source,
146+
isNonExistant: coll.is_non_existant,
147147
};
148148
}
149149

packages/compass-workspaces/src/components/workspaces.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ type CompassWorkspacesProps = {
142142
): void;
143143
};
144144

145-
const notProvisionedStyles = css({
145+
const nonExistantStyles = css({
146146
color: palette.gray.base,
147147
});
148148

@@ -232,7 +232,7 @@ const CompassWorkspaces: React.FunctionComponent<CompassWorkspacesProps> = ({
232232
getConnectionById(tab.connectionId)?.title || '';
233233
const database = tab.namespace;
234234
const namespaceId = `${tab.connectionId}.${database}`;
235-
const { ns_source } = databaseInfo[namespaceId] ?? {};
235+
const { isNonExistant } = databaseInfo[namespaceId] ?? {};
236236
return {
237237
id: tab.id,
238238
connectionName,
@@ -242,20 +242,19 @@ const CompassWorkspaces: React.FunctionComponent<CompassWorkspacesProps> = ({
242242
['Connection', connectionName || ''],
243243
['Database', database],
244244
] as Tooltip,
245-
iconGlyph:
246-
ns_source !== 'provisioned' ? 'EmptyDatabase' : 'Database',
245+
iconGlyph: isNonExistant ? 'EmptyDatabase' : 'Database',
247246
'data-namespace': tab.namespace,
248247
tabTheme: getThemeOf(tab.connectionId),
249-
...(ns_source !== 'provisioned' && {
250-
className: notProvisionedStyles,
248+
...(isNonExistant && {
249+
className: nonExistantStyles,
251250
}),
252251
} as const;
253252
}
254253
case 'Collection': {
255254
const { database, collection, ns } = toNS(tab.namespace);
256255
const namespaceId = `${tab.connectionId}.${ns}`;
257256
const info = collectionInfo[namespaceId] ?? {};
258-
const { isTimeSeries, isReadonly, sourceName, ns_source } = info;
257+
const { isTimeSeries, isReadonly, sourceName, isNonExistant } = info;
259258
const connectionName =
260259
getConnectionById(tab.connectionId)?.title || '';
261260
const collectionType = isTimeSeries
@@ -288,13 +287,13 @@ const CompassWorkspaces: React.FunctionComponent<CompassWorkspacesProps> = ({
288287
? 'Visibility'
289288
: collectionType === 'timeseries'
290289
? 'TimeSeries'
291-
: ns_source !== 'provisioned'
290+
: isNonExistant
292291
? 'EmptyFolder'
293292
: 'Folder',
294293
'data-namespace': ns,
295294
tabTheme: getThemeOf(tab.connectionId),
296-
...(ns_source !== 'provisioned' && {
297-
className: notProvisionedStyles,
295+
...(isNonExistant && {
296+
className: nonExistantStyles,
298297
}),
299298
} as const;
300299
}

packages/compass-workspaces/src/stores/workspaces.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ export type CollectionTabInfo = {
101101
isTimeSeries: boolean;
102102
isReadonly: boolean;
103103
sourceName?: string | null;
104-
ns_source: 'provisioned' | 'privileges';
104+
isNonExistant: boolean;
105105
};
106106

107107
export type DatabaseTabInfo = {
108-
ns_source: 'provisioned' | 'privileges' | 'roles';
108+
isNonExistant: boolean;
109109
};
110110

111111
export type WorkspacesState = {
@@ -726,7 +726,7 @@ const fetchCollectionInfo = (
726726
isTimeSeries: coll.isTimeSeries,
727727
isReadonly: coll.readonly ?? coll.isView,
728728
sourceName: coll.sourceName,
729-
ns_source: coll.ns_source,
729+
isNonExistant: coll.is_non_existant,
730730
},
731731
});
732732
}
@@ -772,7 +772,7 @@ const fetchDatabaseInfo = (
772772
type: WorkspacesActions.FetchDatabaseTabInfo,
773773
namespaceId,
774774
info: {
775-
ns_source: db.ns_source,
775+
isNonExistant: db.is_non_existant,
776776
},
777777
});
778778
}

0 commit comments

Comments
 (0)