Skip to content

Commit f545087

Browse files
committed
added link
1 parent 28e4492 commit f545087

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

packages/compass-indexes/src/components/create-index-form/mdb-code-viewer.spec.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,36 @@ import MDBCodeViewer from './mdb-code-viewer';
44
import { expect } from 'chai';
55

66
describe('MDBCodeViewer', () => {
7-
it('shows the db name, collection name, and field names, and field types', () => {
8-
const dbName = 'testDB';
9-
const collectionName = 'testCollection';
10-
const indexNameTypeMap = {
11-
field1: '1 (asc)',
12-
field2: '-1 (desc)',
13-
field3: '2dsphere',
14-
field4: 'text',
15-
};
7+
const dbName = 'testDB';
8+
const collectionName = 'testCollection';
9+
const indexNameTypeMap = {
10+
field1: '1 (asc)',
11+
field2: '-1 (desc)',
12+
field3: '2dsphere',
13+
field4: 'text',
14+
};
1615

16+
const renderComponent = () => {
1717
render(
1818
<MDBCodeViewer
1919
dbName={dbName}
2020
collectionName={collectionName}
2121
indexNameTypeMap={indexNameTypeMap}
2222
/>
2323
);
24+
};
25+
26+
it('shows the db name, collection name, and field names, and field types', () => {
27+
renderComponent();
2428
const codeElement = screen.getByTestId('mdb-code-viewer');
2529
expect(codeElement).to.have.text(
2630
'db.getSiblingDB("testDB").getCollection("testCollection").createIndex{( field1: "1", field2: "-1", field3: "2dsphere", field4: "text"});'
2731
);
2832
});
33+
34+
it('renders the link to the MongoDB documentation', () => {
35+
renderComponent();
36+
const linkElement = screen.getByText('here');
37+
expect(linkElement).to.be.visible;
38+
});
2939
});

packages/compass-indexes/src/components/create-index-form/mdb-code-viewer.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
import { Code } from '@mongodb-js/compass-components';
1+
import { Code, Link, css, spacing } from '@mongodb-js/compass-components';
22
import React from 'react';
33

4+
const containerStyles = css({
5+
display: 'flex',
6+
flexDirection: 'column',
7+
});
8+
9+
const programmingLanguageLinkStyles = css({
10+
marginLeft: 'auto',
11+
marginTop: spacing[100],
12+
});
13+
414
const MDBCodeViewer = ({
515
dbName,
616
collectionName,
@@ -30,9 +40,22 @@ const MDBCodeViewer = ({
3040
};
3141

3242
return (
33-
<Code data-testid="mdb-code-viewer" language="javascript">
34-
{generateCode()}
35-
</Code>
43+
<div className={containerStyles}>
44+
<Code data-testid="mdb-code-viewer" language="javascript">
45+
{generateCode()}
46+
</Code>
47+
<span className={programmingLanguageLinkStyles}>
48+
View programming language driver syntax{' '}
49+
<Link
50+
href="https://www.mongodb.com/docs/manual/core/indexes/create-index/"
51+
target="_blank"
52+
rel="noreferrer noopener"
53+
>
54+
here
55+
</Link>
56+
.
57+
</span>
58+
</div>
3659
);
3760
};
3861

0 commit comments

Comments
 (0)