Skip to content

Commit 59c4696

Browse files
committed
updated index flow's copy and updated text input to codemirror editor
1 parent 6f19f2b commit 59c4696

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ const IndexFlowSection = ({
153153
</Body>
154154
<p>
155155
<span className={underlineStyles}>
156-
Follow the Equality, Sort, Range (ESR) Rule and this index is
157-
optimal for queries that have this pattern:
156+
Follow the Equality, Sort, Range (ESR) Rule. This index is optimal
157+
for queries that have this pattern:
158158
</span>
159159
{/* Optimal queries, clean up with actual optimal queries in CLOUDP-311783 */}
160160
<Body

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import QueryFlowSection from './query-flow-section';
44
import { expect } from 'chai';
55

66
describe('QueryFlowSection', () => {
7-
it('renders the input query section with placeholder text', () => {
7+
it('renders the input query section with a code editor', () => {
88
render(<QueryFlowSection />);
9-
const inputElement = screen.getByPlaceholderText(
10-
"Type a query: { field: 'value' }"
11-
);
12-
expect(inputElement).to.be.visible;
9+
const codeEditor = screen.getByTestId('query-flow-section-json-editor');
10+
expect(codeEditor).to.be.visible;
1311
});
1412

1513
it('renders the "Show me suggested index" button', () => {

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import {
22
Button,
33
palette,
4-
TextInput,
54
Body,
6-
fontFamilies,
75
Code,
86
Link,
97
} from '@mongodb-js/compass-components';
108
import React from 'react';
119
import { css, spacing } from '@mongodb-js/compass-components';
10+
import { CodemirrorInlineEditor } from '@mongodb-js/compass-editor';
1211

1312
const inputQueryContainerStyles = css({
1413
marginBottom: spacing[600],
@@ -23,18 +22,6 @@ const headerStyles = css({
2322
marginBottom: spacing[200],
2423
});
2524

26-
const queryInputStyles = css({
27-
div: {
28-
border: 0,
29-
},
30-
input: {
31-
fontFamily: `${fontFamilies.code} !important`,
32-
'&::placeholder': {
33-
fontFamily: fontFamilies.code,
34-
},
35-
},
36-
});
37-
3825
const suggestedIndexContainerStyles = css({
3926
flexDirection: 'column',
4027
display: 'flex',
@@ -64,17 +51,22 @@ db.getSiblingDB("${db_name}").getCollection("${collection_name}").createIndex(
6451
`;
6552
};
6653

54+
const [inputQuery, setInputQuery] = React.useState('');
55+
6756
return (
6857
<>
6958
<Body baseFontSize={16} weight="medium" className={headerStyles}>
7059
Input Query
7160
</Body>
7261
<div className={inputQueryContainerStyles}>
7362
<div>
74-
<TextInput
63+
<CodemirrorInlineEditor
64+
data-testid="query-flow-section-json-editor"
65+
language="json"
66+
text={inputQuery}
67+
onChangeText={(text) => setInputQuery(text)}
68+
initialJSONFoldAll={false}
7569
placeholder="Type a query: { field: 'value' }"
76-
aria-labelledby="query-text-area"
77-
className={queryInputStyles}
7870
/>
7971
</div>
8072
<div>

0 commit comments

Comments
 (0)