Skip to content

Commit 565819f

Browse files
committed
WIP
1 parent 84a3060 commit 565819f

File tree

28 files changed

+855
-18
lines changed

28 files changed

+855
-18
lines changed

package-lock.json

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/collection-model/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type CollectionMetadata = {
4545
* Aggregation pipeline view definition
4646
*/
4747
sourcePipeline?: unknown[];
48+
shardKey: unknown | null;
4849
};
4950

5051
interface Collection {
@@ -60,6 +61,7 @@ interface Collection {
6061
command: boolean;
6162
special: boolean;
6263
specialish: boolean;
64+
shardKey: unknown | null;
6365
normal: boolean;
6466
readonly: boolean;
6567
view_on: string;

packages/collection-model/lib/collection-properties.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const PROPERTIES_CLUSTERED = 'clustered';
55
const PROPERTIES_FLE2 = 'fle2';
66
const PROPERTIES_VIEW = 'view';
77
const PROPERTIES_READ_ONLY = 'read-only';
8+
const PROPERTIES_SHARDED = 'sharded';
89

910
function getProperties(coll) {
1011
const properties = [];
@@ -52,6 +53,12 @@ function getProperties(coll) {
5253
});
5354
}
5455

56+
if (coll.shardKey) {
57+
properties.push({
58+
id: PROPERTIES_SHARDED,
59+
});
60+
}
61+
5562
return properties;
5663
}
5764

packages/collection-model/lib/model.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ function pickCollectionInfo({
100100
validation,
101101
clustered,
102102
fle2,
103+
shardKey
103104
}) {
104-
return { readonly, view_on, collation, pipeline, validation, clustered, fle2 };
105+
return { readonly, view_on, collation, pipeline, validation, clustered, fle2, shardKey };
105106
}
106107

107108
/**
@@ -128,6 +129,7 @@ const CollectionModel = AmpersandModel.extend(debounceActions(['fetch']), {
128129
view_on: 'string',
129130
collation: 'object',
130131
pipeline: 'array',
132+
shardKey: 'object',
131133
validation: 'object',
132134

133135
// Normalized values from collStats command
@@ -220,7 +222,7 @@ const CollectionModel = AmpersandModel.extend(debounceActions(['fetch']), {
220222
},
221223
},
222224
properties: {
223-
deps: ['collation', 'type', 'capped', 'clustered', 'readonly', 'fle2'],
225+
deps: ['collation', 'type', 'capped', 'clustered', 'readonly', 'fle2', 'shardKey'],
224226
fn() {
225227
return getProperties(this);
226228
},
@@ -289,6 +291,7 @@ const CollectionModel = AmpersandModel.extend(debounceActions(['fetch']), {
289291
isClustered: this.clustered,
290292
isFLE: this.fle2,
291293
isSearchIndexesSupported,
294+
shardKey: this.shardKey
292295
};
293296
if (this.sourceId) {
294297
try {

packages/compass-collection/src/components/collection-header/badges.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export type CollectionBadgeType =
1010
| 'timeseries'
1111
| 'view'
1212
| 'fle'
13-
| 'clustered';
13+
| 'clustered'
14+
| 'sharded';
1415

1516
const badges: Record<
1617
CollectionBadgeType,
@@ -48,6 +49,10 @@ const badges: Record<
4849
clustered: {
4950
label: 'CLUSTERED',
5051
},
52+
sharded: {
53+
label: 'SHARDED',
54+
variant: BadgeVariant.LightGray,
55+
},
5156
};
5257

5358
export const CollectionBadge = ({ type }: { type: CollectionBadgeType }) => {

packages/compass-collection/src/components/collection-header/collection-header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ type CollectionHeaderProps = {
109109
isClustered: boolean;
110110
isFLE: boolean;
111111
isAtlas: boolean;
112+
shardKey: unknown | null;
112113
sourceName?: string;
113114
editViewName?: string;
114115
sourcePipeline?: unknown[];
@@ -218,6 +219,7 @@ class CollectionHeader extends Component<CollectionHeaderProps> {
218219
{this.props.isTimeSeries && <CollectionBadge type="timeseries" />}
219220
{this.props.isClustered && <CollectionBadge type="clustered" />}
220221
{this.props.isFLE && <CollectionBadge type="fle" />}
222+
{this.props.shardKey && <CollectionBadge type="sharded" />}
221223
{this.props.isReadonly && this.props.sourceName && (
222224
<CollectionBadge type="view" />
223225
)}

packages/compass-collection/src/modules/collection-tab.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const initialMetadata: CollectionStateMetadata = {
8585
isAtlas: false,
8686
isDataLake: false,
8787
serverVersion: '0.0.0',
88+
shardKey: null,
8889
};
8990

9091
enum CollectionActions {

packages/compass-indexes/src/utils/index-link-helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const HELP_URLS = {
2222
'https://docs.mongodb.com/master/reference/bson-type-comparison-order/#collation',
2323
COLLATION_REF: 'https://docs.mongodb.com/master/reference/collation',
2424
HIDDEN: 'https://www.mongodb.com/docs/manual/core/index-hidden/',
25+
SHARDKEY: 'https://www.mongodb.com/docs/manual/core/sharding-shard-key/',
2526
UNKNOWN: null,
2627
};
2728

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ignores:
2+
- '@mongodb-js/prettier-config-compass'
3+
- '@mongodb-js/tsconfig-compass'
4+
- '@types/chai'
5+
- '@types/sinon-chai'
6+
- 'sinon'
7+
- '@types/chai-dom'
8+
- '@types/react'
9+
- '@types/react-dom'
10+
ignore-patterns:
11+
- 'dist'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.nyc-output
2+
dist

0 commit comments

Comments
 (0)