Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(global-writes): add unsharded state COMPASS-8276 #6289

Merged
merged 43 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1342fae
setup plugin
mabaasit Sep 23, 2024
5c92d42
service and clean up
mabaasit Sep 23, 2024
8680d5d
Merge branch 'main' of https://github.com/mongodb-js/compass into COM…
mabaasit Sep 23, 2024
7b1a784
show tab only if global writes is supported
mabaasit Sep 23, 2024
17fa0dd
clean up
mabaasit Sep 23, 2024
16c5289
fix ts
mabaasit Sep 23, 2024
1dfed32
Merge branch 'main' of https://github.com/mongodb-js/compass into COM…
mabaasit Sep 23, 2024
f64ea1d
clean up
mabaasit Sep 23, 2024
3b74cf6
depcheck
mabaasit Sep 23, 2024
2c4f6ff
correct version of redux in lock file
mabaasit Sep 23, 2024
15fb5c0
depcheck again
mabaasit Sep 23, 2024
22ff79f
feedback
mabaasit Sep 25, 2024
b1f5d56
warning
mabaasit Sep 25, 2024
abf38b9
Merge branch 'main' of https://github.com/mongodb-js/compass into COM…
mabaasit Sep 25, 2024
ca0afc7
show warning
mabaasit Sep 25, 2024
1cef989
title tooltip
mabaasit Sep 25, 2024
e6788d6
unsharded view and tests
mabaasit Sep 25, 2024
e4ab4a4
sharding in progress
mabaasit Sep 25, 2024
d6790e7
small clean up
mabaasit Sep 25, 2024
6e2c893
correct nums
mabaasit Sep 25, 2024
99a5529
error toasts
mabaasit Sep 26, 2024
84fef30
fix html
mabaasit Sep 26, 2024
f644bd7
tests
mabaasit Sep 26, 2024
4f0ce46
Merge branch 'main' of https://github.com/mongodb-js/compass into COM…
mabaasit Sep 26, 2024
9e3be02
clean up
mabaasit Sep 26, 2024
3b384fc
pedantic details
mabaasit Sep 26, 2024
1c8897a
add missing header
mabaasit Sep 26, 2024
e8c55b0
check
mabaasit Sep 26, 2024
d7745cd
clean up lock file
mabaasit Sep 26, 2024
a0eb2be
clean action name
mabaasit Sep 26, 2024
5f03a49
func to component
mabaasit Sep 26, 2024
9437e07
fix check
mabaasit Sep 26, 2024
23c1361
use state when waiting for server to accept sharding
mabaasit Sep 26, 2024
c8be176
name fix
mabaasit Sep 26, 2024
0d26155
clean up
mabaasit Sep 26, 2024
efbd45f
assert as correct type
mabaasit Sep 26, 2024
59787bb
add test
mabaasit Sep 27, 2024
74ff479
remove assertion
mabaasit Sep 27, 2024
07cce5f
add back assertion
mabaasit Sep 27, 2024
eca4068
avoid cutting off radio buttons
mabaasit Sep 27, 2024
10adbef
Merge branch 'main' into COMPASS-8276-no-shard-key
mabaasit Sep 27, 2024
915e8a3
Merge remote-tracking branch 'origin' into COMPASS-8276-no-shard-key
mabaasit Sep 27, 2024
373bffe
npm i
mabaasit Sep 27, 2024
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
6 changes: 6 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions packages/compass-global-writes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@
"@mongodb-js/compass-collection": "^4.41.0",
"@mongodb-js/compass-components": "^1.29.4",
"@mongodb-js/compass-connections": "^1.42.0",
"@mongodb-js/compass-field-store": "^9.17.0",
"@mongodb-js/compass-logging": "^1.4.7",
"@mongodb-js/compass-telemetry": "^1.1.7",
"hadron-app-registry": "^9.2.6",
"mongodb-ns": "^2.4.2",
"react": "^17.0.2",
"react-redux": "^8.1.3",
"redux": "^4.2.1",
"redux-thunk": "^2.4.2"
},
Expand Down
20 changes: 15 additions & 5 deletions packages/compass-global-writes/src/components/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import React from 'react';
import { expect } from 'chai';
import { render, screen } from '@mongodb-js/testing-library-compass';
import { screen } from '@mongodb-js/testing-library-compass';
import { GlobalWrites } from './index';
import { renderWithStore } from './../../tests/create-store';

describe('Compass GlobalWrites Plugin', function () {
it('renders a Plugin', function () {
render(<GlobalWrites />);
expect(screen.getByText('This feature is currently in development.')).to
.exist;
it('renders plugin in NOT_READY state', function () {
renderWithStore(<GlobalWrites shardingStatus={'NOT_READY'} />);
expect(screen.getByText(/loading/i)).to.exist;
});

it('renders plugin in UNSHARDED state', function () {
renderWithStore(<GlobalWrites shardingStatus={'UNSHARDED'} />);
expect(screen.getByTestId('shard-collection-button')).to.exist;
});
paula-stacho marked this conversation as resolved.
Show resolved Hide resolved

it('renders plugin in SHARDING state', function () {
renderWithStore(<GlobalWrites shardingStatus={'SHARDING'} />);
expect(screen.getByText(/sharding your collection/i)).to.exist;
});
});
59 changes: 50 additions & 9 deletions packages/compass-global-writes/src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,75 @@
import React from 'react';
import { connect } from 'react-redux';
import {
css,
spacing,
WorkspaceContainer,
Body,
SpinLoaderWithLabel,
} from '@mongodb-js/compass-components';
import React from 'react';
import type { RootState, ShardingStatus } from '../store/reducer';
import { ShardingStatuses } from '../store/reducer';
import UnshardedState from './states/unsharded';
import ShardingState from './states/sharding';

const containerStyles = css({
paddingLeft: spacing[3],
paddingRight: spacing[3],
paddingLeft: spacing[400],
paddingRight: spacing[400],
display: 'flex',
width: '100%',
height: '100%',
});

const workspaceContentStyles = css({
paddingTop: spacing[400],
});

const centeredContent = css({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100%',
});

export function GlobalWrites() {
type GlobalWritesProps = {
shardingStatus: ShardingStatus;
};

function ShardingStateView({
shardingStatus,
}: {
shardingStatus: ShardingStatus;
}) {
if (shardingStatus === ShardingStatuses.NOT_READY) {
return (
<div className={centeredContent}>
<SpinLoaderWithLabel progressText="Loading …" />
</div>
);
}

if (
shardingStatus === ShardingStatuses.UNSHARDED ||
shardingStatus === ShardingStatuses.SUBMITTING_FOR_SHARDING
) {
return <UnshardedState />;
}

if (shardingStatus === ShardingStatuses.SHARDING) {
return <ShardingState />;
}

return null;
}

export function GlobalWrites({ shardingStatus }: GlobalWritesProps) {
return (
<div className={containerStyles}>
<WorkspaceContainer>
<Body className={centeredContent}>
This feature is currently in development.
</Body>
<WorkspaceContainer className={workspaceContentStyles}>
<ShardingStateView shardingStatus={shardingStatus} />
</WorkspaceContainer>
</div>
);
}
export default connect((state: RootState) => ({
shardingStatus: state.status,
}))(GlobalWrites);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { expect } from 'chai';
import { screen } from '@mongodb-js/testing-library-compass';
import { ShardingState } from './sharding';
import { renderWithStore } from '../../../tests/create-store';

function renderWithProps(
props?: Partial<React.ComponentProps<typeof ShardingState>>
) {
return renderWithStore(<ShardingState {...props} />);
}

describe('Sharding', function () {
it('renders the info banner', function () {
renderWithProps();
expect(screen.getByRole('alert')).to.exist;
});
});
42 changes: 42 additions & 0 deletions packages/compass-global-writes/src/components/states/sharding.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import {
Banner,
BannerVariant,
Body,
css,
Link,
spacing,
} from '@mongodb-js/compass-components';
import { connect } from 'react-redux';

const nbsp = '\u00a0';

const containerStyles = css({
display: 'flex',
flexDirection: 'column',
gap: spacing[400],
});

export function ShardingState() {
return (
<div className={containerStyles}>
<Banner variant={BannerVariant.Info}>
<strong>Sharding your collection …</strong>
{nbsp}this should not take too long.
</Banner>
<Body>
Once your collection is sharded, this tab will show instructions on
document ‘location’ field formatting, and provide some common command
examples.
</Body>
<Link
href="https://www.mongodb.com/docs/atlas/global-clusters/"
hideExternalIcon
>
You can read more about Global Writes in our documentation.
</Link>
</div>
);
}

export default connect()(ShardingState);
Loading
Loading