Skip to content

Commit 407569c

Browse files
authored
chore(compass-aggregations): Show Merge / Save buttons when isAtlasDeployed is true COMPASS-5972 (#3279)
chore(compass-aggregations): Show Merge / Save buttons when isAtlasDeployed is true
1 parent 547c8d3 commit 407569c

File tree

6 files changed

+101
-31
lines changed

6 files changed

+101
-31
lines changed

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-builder-workspace.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class PipelineWorkspace extends PureComponent {
5555
isOverviewOn: PropTypes.bool.isRequired,
5656
projections: PropTypes.array.isRequired,
5757
projectionsChanged: PropTypes.func.isRequired,
58-
newPipelineFromPaste: PropTypes.func.isRequired
58+
newPipelineFromPaste: PropTypes.func.isRequired,
59+
isAtlasDeployed: PropTypes.bool
5960
};
6061

6162
/**
@@ -132,6 +133,7 @@ class PipelineWorkspace extends PureComponent {
132133
projections={this.props.projections}
133134
projectionsChanged={this.props.projectionsChanged}
134135
newPipelineFromPaste={this.props.newPipelineFromPaste}
136+
isAtlasDeployed={this.props.isAtlasDeployed}
135137
/>);
136138
}
137139

packages/compass-aggregations/src/components/pipeline/pipeline.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ class Pipeline extends PureComponent {
230230
projections={this.props.projections}
231231
projectionsChanged={this.props.projectionsChanged}
232232
newPipelineFromPaste={this.props.newPipelineFromPaste}
233+
isAtlasDeployed={this.props.isAtlasDeployed}
233234
/>
234235
);
235236
}

packages/compass-aggregations/src/components/stage-preview/stage-preview.jsx

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { AtlasLogoMark, Body, Link } from '@mongodb-js/compass-components';
1+
import { AtlasLogoMark, Body, Link, Button } from '@mongodb-js/compass-components';
22
import React, { Component } from 'react';
33
import PropTypes from 'prop-types';
44
import { Document } from '@mongodb-js/compass-crud';
5-
import { TextButton } from 'hadron-react-buttons';
65
import LoadingOverlay from '../loading-overlay';
76
import { OUT, MERGE } from '../../modules/pipeline';
87
import decomment from 'decomment';
@@ -29,10 +28,10 @@ class StagePreview extends Component {
2928
isComplete: PropTypes.bool.isRequired,
3029
// Can be undefined on the initial render
3130
isMissingAtlasOnlyStageSupport: PropTypes.bool,
32-
openLink: PropTypes.func.isRequired,
3331
index: PropTypes.number.isRequired,
3432
stageOperator: PropTypes.string,
35-
stage: PropTypes.string
33+
stage: PropTypes.string,
34+
isAtlasDeployed: PropTypes.bool
3635
}
3736

3837
/**
@@ -57,14 +56,6 @@ class StagePreview extends Component {
5756
this.props.runOutStage(this.props.index);
5857
}
5958

60-
/**
61-
* Called when the Atlas Signup CTA link is clicked.
62-
*/
63-
onAtlasSignupCtaClicked = () => {
64-
track('Atlas Link Clicked', { screen: 'agg_builder' });
65-
this.props.openLink('https://www.mongodb.com/cloud/atlas/lp/search-1?utm_campaign=atlas_search&utm_source=compass&utm_medium=product&utm_content=v1');
66-
}
67-
6859
/**
6960
* If the stage operator is $merge we have special behaviour.
7061
*
@@ -98,6 +89,15 @@ class StagePreview extends Component {
9889
The $merge operator will cause the pipeline to persist the results to
9990
the specified location.
10091
</div>
92+
{this.props.isAtlasDeployed && (
93+
<Button
94+
variant="primary"
95+
data-testid="save-merge-documents"
96+
onClick={this.onSaveDocuments}
97+
>
98+
Merge documents
99+
</Button>
100+
)}
101101
</div>
102102
);
103103
}
@@ -136,6 +136,15 @@ class StagePreview extends Component {
136136
the specified location (collection, S3, or Atlas). If the collection
137137
exists it will be replaced.
138138
</div>
139+
{this.props.isAtlasDeployed && (
140+
<Button
141+
variant="primary"
142+
data-testid="save-out-documents"
143+
onClick={this.onSaveDocuments}
144+
>
145+
Save documents
146+
</Button>
147+
)}
139148
</Body>
140149
);
141150
}
@@ -149,17 +158,29 @@ class StagePreview extends Component {
149158
renderAtlasOnlyStagePreviewSection() {
150159
return (
151160
<div className={styles['stage-preview-missing-search-support']}>
152-
<AtlasLogoMark size={30} className={styles['stage-preview-missing-search-support-icon']} />
153-
<div data-test-id="stage-preview-missing-search-support" className={styles['stage-preview-missing-search-support-text']}>
154-
This stage is only available with MongoDB Atlas.
155-
156-
Create a free cluster or connect to an Atlas cluster to build search indexes and use {this.props.stageOperator} aggregation stage to run fast, relevant search queries.
157-
</div>
158-
<TextButton
159-
text="Create Free Cluster"
160-
className="btn btn-xs btn-primary"
161-
clickHandler={this.onAtlasSignupCtaClicked}
161+
<AtlasLogoMark
162+
size={30}
163+
className={styles['stage-preview-missing-search-support-icon']}
162164
/>
165+
<div
166+
data-test-id="stage-preview-missing-search-support"
167+
className={styles['stage-preview-missing-search-support-text']}
168+
>
169+
This stage is only available with MongoDB Atlas. Create a free cluster
170+
or connect to an Atlas cluster to build search indexes and use{' '}
171+
{this.props.stageOperator} aggregation stage to run fast, relevant
172+
search queries.
173+
</div>
174+
<Button
175+
href="https://www.mongodb.com/cloud/atlas/lp/search-1?utm_campaign=atlas_search&utm_source=compass&utm_medium=product&utm_content=v1"
176+
target="_blank"
177+
onClick={() => {
178+
track('Atlas Link Clicked', { screen: 'agg_builder' });
179+
}}
180+
variant="primary"
181+
>
182+
Create free cluster
183+
</Button>
163184
</div>
164185
);
165186
}

packages/compass-aggregations/src/components/stage-preview/stage-preview.module.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
text-align: center;
5151
}
5252

53+
&-text:not(:last-child) {
54+
padding-bottom: 8px;
55+
}
56+
5357
&-button {
5458
margin-top: 3px;
5559
}

packages/compass-aggregations/src/components/stage-preview/stage-preview.spec.jsx

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ describe('StagePreview [Component]', function() {
1414
beforeEach(function() {
1515
component = mount(
1616
<StagePreview
17-
openLink={sinon.spy()}
1817
documents={[{ name: 'test' }]}
1918
isValid
2019
isEnabled
@@ -46,7 +45,6 @@ describe('StagePreview [Component]', function() {
4645
beforeEach(function() {
4746
component = mount(
4847
<StagePreview
49-
openLink={sinon.spy()}
5048
documents={[]}
5149
isValid
5250
isEnabled
@@ -78,7 +76,6 @@ describe('StagePreview [Component]', function() {
7876
beforeEach(function() {
7977
component = mount(
8078
<StagePreview
81-
openLink={sinon.spy()}
8279
documents={[{ name: 'test' }]}
8380
isValid
8481
isEnabled
@@ -117,7 +114,6 @@ describe('StagePreview [Component]', function() {
117114
beforeEach(function() {
118115
component = mount(
119116
<StagePreview
120-
openLink={sinon.spy()}
121117
stage="'testing'"
122118
documents={[{ name: 'test' }]}
123119
isValid
@@ -168,7 +164,6 @@ describe('StagePreview [Component]', function() {
168164
beforeEach(function() {
169165
component = mount(
170166
<StagePreview
171-
openLink={sinon.spy()}
172167
documents={[]}
173168
isValid
174169
isEnabled
@@ -199,7 +194,6 @@ describe('StagePreview [Component]', function() {
199194
beforeEach(function() {
200195
component = mount(
201196
<StagePreview
202-
openLink={sinon.spy()}
203197
documents={[]}
204198
isValid
205199
isEnabled
@@ -229,4 +223,51 @@ describe('StagePreview [Component]', function() {
229223
});
230224
});
231225
});
226+
227+
228+
context('when atlas deployed', function () {
229+
let component;
230+
231+
function render(stageOperator = '$out') {
232+
return mount(
233+
<StagePreview
234+
documents={[{ name: 'test' }]}
235+
isValid
236+
isEnabled
237+
isComplete={false}
238+
index={0}
239+
runOutStage={sinon.spy()}
240+
gotoOutResults={sinon.spy()}
241+
gotoMergeResults={sinon.spy()}
242+
isLoading={false}
243+
stage=""
244+
stageOperator={stageOperator}
245+
isAtlasDeployed
246+
/>
247+
);
248+
}
249+
250+
afterEach(function () {
251+
component.unmount();
252+
component = null;
253+
});
254+
255+
it('shows "Save documents" button for $out stage', function () {
256+
component = render('$out');
257+
expect(
258+
component
259+
.getDOMNode()
260+
.querySelector('[data-testid="save-out-documents"]')
261+
).to.exist;
262+
});
263+
264+
it('shows "Merge documents" button for $merge stage', function () {
265+
component = render('$merge');
266+
expect(
267+
component
268+
.getDOMNode()
269+
.querySelector('[data-testid="save-merge-documents"]')
270+
).to.exist;
271+
});
272+
});
232273
});

packages/compass-aggregations/src/components/stage/stage.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class Stage extends Component {
7979
setIsModified: PropTypes.func.isRequired,
8080
projections: PropTypes.array.isRequired,
8181
projectionsChanged: PropTypes.func.isRequired,
82-
newPipelineFromPaste: PropTypes.func.isRequired
82+
newPipelineFromPaste: PropTypes.func.isRequired,
83+
isAtlasDeployed: PropTypes.bool
8384
};
8485

8586
/* eslint complexity: 0 */
@@ -218,7 +219,7 @@ class Stage extends Component {
218219
runOutStage={this.props.runOutStage}
219220
gotoOutResults={this.props.gotoOutResults}
220221
gotoMergeResults={this.props.gotoMergeResults}
221-
openLink={this.props.openLink}
222+
isAtlasDeployed={this.props.isAtlasDeployed}
222223
/>
223224
)}
224225
</div>

0 commit comments

Comments
 (0)