Skip to content

Commit da7eb23

Browse files
gribnoysupaddaleax
andauthored
chore(workspaces): replace workspace opening events with openWorkspace methods (#5213)
* chore(workspaces): add workspace provider; decouple sidebar from workspaces and use new hook to get state * chore(workspaces): use openWorkspace methods in sidebar, collection, and databases-collections plugins * chore(workspaces): move workspace tab definition to workspaces plugin to avoid circular dependencies * chore(workspaces): replace rest of the tab opening events with openWorkspace methods * chore(workspace): refactor workspaces provider to allow mocking in test environment * chore(workspaces): add a separate method for opening a collection in a view editing state * chore(workspaces): fix slot rendering; fix failing tests * chore(instance-store): clean up instance store and add tests * chore(home): fix dataService mock * chore(collection-model): pick type as part of the collection info * chore(workspaces): use optional chaining Co-authored-by: Anna Henningsen <[email protected]> * chore(collection): stricter collection tab provider types --------- Co-authored-by: Anna Henningsen <[email protected]>
1 parent fe55c67 commit da7eb23

File tree

92 files changed

+1396
-1160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1396
-1160
lines changed

package-lock.json

Lines changed: 35 additions & 13 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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type CollectionMetadata = {
5252

5353
interface CollectionProps {
5454
_id: string;
55-
type: string;
55+
type: 'collection' | 'view' | 'timeseries';
5656
status: 'initial' | 'fetching' | 'refreshing' | 'ready' | 'error';
5757
statusError: string | null;
5858
ns: string;
@@ -106,6 +106,11 @@ interface CollectionCollection extends Array<Collection> {
106106
toJSON(opts?: { derived: boolean }): Array<CollectionProps>;
107107
at(index: number): Collection | undefined;
108108
get(id: string, key?: '_id' | 'name'): Collection | undefined;
109+
add(props: Partial<CollectionProps>): Collection;
110+
remove(
111+
models: string | [string] | Collection | [Collection]
112+
): Collection | undefined;
113+
remove(models: string[] | Collection[]): (Collection | undefined)[];
109114
}
110115

111116
export default Collection;

packages/collection-model/lib/model.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function getParentByType(model, type) {
9393
}
9494

9595
function pickCollectionInfo({
96+
type,
9697
readonly,
9798
view_on,
9899
collation,
@@ -101,7 +102,7 @@ function pickCollectionInfo({
101102
clustered,
102103
fle2,
103104
}) {
104-
return { readonly, view_on, collation, pipeline, validation, clustered, fle2 };
105+
return { type, readonly, view_on, collation, pipeline, validation, clustered, fle2 };
105106
}
106107

107108
/**
@@ -368,10 +369,9 @@ const CollectionCollection = AmpersandCollection.extend(
368369
// refactor significantly. We can address this in COMPASS-5211
369370
return getNamespaceInfo(coll._id).system === false;
370371
})
371-
.map(({ _id, type, ...rest }) => {
372+
.map(({ _id, ...rest }) => {
372373
return {
373374
_id,
374-
type,
375375
...pickCollectionInfo(rest),
376376
};
377377
})

packages/compass-aggregations/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
"license": "SSPL",
4040
"peerDependencies": {
4141
"@mongodb-js/atlas-service": "^0.12.2",
42+
"@mongodb-js/compass-app-stores": "^7.7.4",
4243
"@mongodb-js/compass-components": "^1.20.2",
4344
"@mongodb-js/compass-crud": "^13.21.5",
4445
"@mongodb-js/compass-editor": "^0.19.2",
4546
"@mongodb-js/compass-generative-ai": "^0.6.2",
4647
"@mongodb-js/compass-logging": "^1.2.8",
4748
"@mongodb-js/compass-utils": "^0.5.7",
49+
"@mongodb-js/compass-workspaces": "^0.2.4",
4850
"@mongodb-js/explain-plan-helper": "^1.1.5",
4951
"@mongodb-js/mongodb-constants": "^0.8.7",
5052
"@mongodb-js/mongodb-redux-common": "^2.0.17",
@@ -82,6 +84,9 @@
8284
"lodash": "^4.17.21",
8385
"mocha": "^10.2.0",
8486
"mongodb": "^6.3.0",
87+
"mongodb-collection-model": "^5.16.3",
88+
"mongodb-database-model": "^2.16.3",
89+
"mongodb-instance-model": "^12.16.3",
8590
"mongodb-ns": "^2.4.0",
8691
"mongodb-query-parser": "^4.0.0",
8792
"mongodb-schema": "^12.1.0",
@@ -100,12 +105,14 @@
100105
},
101106
"dependencies": {
102107
"@mongodb-js/atlas-service": "^0.12.2",
108+
"@mongodb-js/compass-app-stores": "^7.7.4",
103109
"@mongodb-js/compass-components": "^1.20.2",
104110
"@mongodb-js/compass-crud": "^13.21.5",
105111
"@mongodb-js/compass-editor": "^0.19.2",
106112
"@mongodb-js/compass-generative-ai": "^0.6.2",
107113
"@mongodb-js/compass-logging": "^1.2.8",
108114
"@mongodb-js/compass-utils": "^0.5.7",
115+
"@mongodb-js/compass-workspaces": "^0.2.4",
109116
"@mongodb-js/explain-plan-helper": "^1.1.5",
110117
"@mongodb-js/mongodb-constants": "^0.8.7",
111118
"@mongodb-js/mongodb-redux-common": "^2.0.17",

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-builder-ui-workspace/index.spec.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { render, screen } from '@testing-library/react';
2+
import { cleanup, render, screen } from '@testing-library/react';
33
import { expect } from 'chai';
44
import { Provider } from 'react-redux';
55
import configureStore from '../../../../test/configure-store';
@@ -25,6 +25,8 @@ const renderPipelineBuilderUIWorkspace = (props = {}, options = {}) => {
2525
};
2626

2727
describe('PipelineBuilderUIWorkspace [Component]', function () {
28+
afterEach(cleanup);
29+
2830
it('renders', function () {
2931
expect(() => renderPipelineBuilderUIWorkspace()).to.not.throw;
3032
});

0 commit comments

Comments
 (0)