Skip to content

Commit e29ef4e

Browse files
committed
updated spacing and the brackets
1 parent c22684e commit e29ef4e

File tree

2 files changed

+53
-42
lines changed

2 files changed

+53
-42
lines changed

packages/compass-indexes/src/components/create-index-form/index-flow-section.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('IndexFlowSection', () => {
109109
);
110110
expect(optimalQueriesExamples).to.exist;
111111
expect(optimalQueriesExamples).to.contain.text(
112-
`{"field1":1,"field2":2,"field4":{"$gt":3}}.sort("field3": 1})`
112+
`{"field1":1,"field2":2,"field4":{"$gt":3}}.sort({"field3": 1})`
113113
);
114114
});
115115

@@ -156,7 +156,7 @@ describe('IndexFlowSection', () => {
156156
);
157157
expect(optimalQueriesExamples).to.exist;
158158
expect(optimalQueriesExamples).to.contain.text(
159-
`{"field1":1,"field3":{"$gt":2}}.sort("field2": 1})`
159+
`{"field1":1,"field3":{"$gt":2}}.sort({"field2": 1})`
160160
);
161161
});
162162

@@ -195,7 +195,7 @@ describe('IndexFlowSection', () => {
195195
);
196196
expect(optimalQueriesExamples).to.exist;
197197
expect(optimalQueriesExamples).to.contain.text(
198-
`{"field1":1,"field2":{"$gt":2}}}`
198+
`{"field1":1,"field2":{"$gt":2}}`
199199
);
200200
expect(optimalQueriesExamples).to.contain.text(
201201
`{"field1":1}.sort({"field2":2})`

packages/compass-indexes/src/components/create-index-form/index-flow-section.tsx

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ const coveredQueriesHeaderStyles = css({
9292
marginRight: spacing[200],
9393
});
9494

95+
const coveredQueriesLinkStyles = css({
96+
marginTop: spacing[200],
97+
});
98+
99+
const optimalQueriesStyles = css({
100+
marginTop: spacing[400],
101+
});
102+
95103
export type IndexFlowSectionProps = {
96104
fields: Field[];
97105
createIndexFieldsComponent: JSX.Element | null;
@@ -148,7 +156,7 @@ const generateOptimalQueries = (
148156

149157
return (
150158
<>
151-
{`{"${firstFieldKey}":1,"${lastFieldKey}":{"$gt":2}}}`}
159+
{`{"${firstFieldKey}":1,"${lastFieldKey}":{"$gt":2}}`}
152160
<br />
153161
{`{"${firstFieldKey}":1}.sort({"${lastFieldKey}":2})`}
154162
</>
@@ -175,7 +183,7 @@ const generateOptimalQueries = (
175183
// Put last field in range and second to last field in sort
176184
optimalQueries[lastFieldKey] = { $gt: coveredQueriesArr.length - 1 };
177185
return (
178-
JSON.stringify(optimalQueries) + `.sort("${secondToLastFieldKey}": 1})`
186+
JSON.stringify(optimalQueries) + `.sort({"${secondToLastFieldKey}": 1})`
179187
);
180188
};
181189

@@ -358,51 +366,54 @@ const IndexFlowSection = ({
358366
)}
359367
>
360368
{/* Covered Queries */}
361-
<Body
362-
className={codeStyles}
363-
data-testid="index-flow-section-covered-queries-examples"
364-
>
365-
{coveredQueries}
366-
</Body>
367-
<p>
368-
<Link
369-
href="https://www.mongodb.com/docs/manual/core/query-optimization/"
370-
onClick={() => {
371-
track('Covered Queries Learn More Clicked', {
372-
context: 'Create Index Modal',
373-
});
374-
}}
375-
>
376-
Learn about covered queries
377-
</Link>
378-
</p>
379369

380-
{!!optimalQueries && (
381-
<>
382-
<p>
383-
<span className={underlineStyles}>
384-
Follow the Equality, Sort, Range (ESR) Rule. This index is
385-
great for queries that have this pattern:
386-
</span>
387-
{/* Optimal queries */}
388-
<Body
389-
className={codeStyles}
390-
data-testid="index-flow-section-optimal-queries-examples"
391-
>
392-
{optimalQueries}
393-
</Body>
394-
</p>
370+
<div>
371+
<Body
372+
className={codeStyles}
373+
data-testid="index-flow-section-covered-queries-examples"
374+
>
375+
{coveredQueries}
376+
</Body>
377+
<div className={coveredQueriesLinkStyles}>
395378
<Link
396-
href="https://www.mongodb.com/docs/manual/tutorial/equality-sort-range-guideline/"
379+
href="https://www.mongodb.com/docs/manual/core/query-optimization/"
397380
onClick={() => {
398-
track('ESR Learn More Clicked', {
381+
track('Covered Queries Learn More Clicked', {
399382
context: 'Create Index Modal',
400383
});
401384
}}
402385
>
403-
Learn about ESR
386+
Learn about covered queries
404387
</Link>
405-
</>
388+
</div>
389+
</div>
390+
391+
{!!optimalQueries && (
392+
<div className={optimalQueriesStyles}>
393+
<span className={underlineStyles}>
394+
Follow the Equality, Sort, Range (ESR) Rule. This index is
395+
great for queries that have this pattern:
396+
</span>
397+
{/* Optimal queries */}
398+
<Body
399+
className={codeStyles}
400+
data-testid="index-flow-section-optimal-queries-examples"
401+
>
402+
{optimalQueries}
403+
</Body>
404+
<div className={coveredQueriesLinkStyles}>
405+
<Link
406+
href="https://www.mongodb.com/docs/manual/tutorial/equality-sort-range-guideline/"
407+
onClick={() => {
408+
track('ESR Learn More Clicked', {
409+
context: 'Create Index Modal',
410+
});
411+
}}
412+
>
413+
Learn about ESR
414+
</Link>
415+
</div>
416+
</div>
406417
)}
407418
</div>
408419
</>

0 commit comments

Comments
 (0)