Skip to content

Commit 4dc7b36

Browse files
authored
Replace EuiCodeEditor with EuiCodeBlock at DocView (#43852)
* Replace EuiCodeEditor with EuiCodeBlock * Adapt filenames to block
1 parent 6685bc5 commit 4dc7b36

File tree

5 files changed

+30
-58
lines changed

5 files changed

+30
-58
lines changed

src/legacy/core_plugins/kbn_doc_views/public/views/__snapshots__/json_code_block.test.tsx.snap

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/legacy/core_plugins/kbn_doc_views/public/views/__snapshots__/json_code_editor.test.tsx.snap

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/legacy/core_plugins/kbn_doc_views/public/views/json.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
import { addDocView } from 'ui/registry/doc_views';
2020
import { i18n } from '@kbn/i18n';
21-
import { JsonCodeEditor } from './json_code_editor';
21+
import { JsonCodeBlock } from './json_code_block';
2222

2323
/*
2424
* Registration of the the doc view: json
@@ -29,5 +29,5 @@ addDocView({
2929
defaultMessage: 'JSON',
3030
}),
3131
order: 20,
32-
component: JsonCodeEditor,
32+
component: JsonCodeBlock,
3333
});

src/legacy/core_plugins/kbn_doc_views/public/views/json_code_editor.test.tsx renamed to src/legacy/core_plugins/kbn_doc_views/public/views/json_code_block.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
import React from 'react';
2020
import { shallow } from 'enzyme';
21-
import { JsonCodeEditor } from './json_code_editor';
21+
import { JsonCodeBlock } from './json_code_block';
2222
import { IndexPattern } from 'ui/index_patterns';
2323

2424
it('returns the `JsonCodeEditor` component', () => {
@@ -30,5 +30,5 @@ it('returns the `JsonCodeEditor` component', () => {
3030
onAddColumn: jest.fn(),
3131
onRemoveColumn: jest.fn(),
3232
};
33-
expect(shallow(<JsonCodeEditor {...props} />)).toMatchSnapshot();
33+
expect(shallow(<JsonCodeBlock {...props} />)).toMatchSnapshot();
3434
});

src/legacy/core_plugins/kbn_doc_views/public/views/json_code_editor.tsx renamed to src/legacy/core_plugins/kbn_doc_views/public/views/json_code_block.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,18 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
// @ts-ignore
20-
import { EuiCodeEditor } from '@elastic/eui';
2119
import React from 'react';
22-
import { FormattedMessage } from '@kbn/i18n/react';
20+
import { EuiCodeBlock } from '@elastic/eui';
21+
import { i18n } from '@kbn/i18n';
2322
import { DocViewRenderProps } from 'ui/registry/doc_views';
2423

25-
export function JsonCodeEditor({ hit }: DocViewRenderProps) {
24+
export function JsonCodeBlock({ hit }: DocViewRenderProps) {
25+
const label = i18n.translate('kbnDocViews.json.codeEditorAriaLabel', {
26+
defaultMessage: 'Read only JSON view of an elasticsearch document',
27+
});
2628
return (
27-
<EuiCodeEditor
28-
aria-label={
29-
<FormattedMessage
30-
id="kbnDocViews.json.codeEditorAriaLabel"
31-
defaultMessage="Read only JSON view of an elasticsearch document"
32-
/>
33-
}
34-
isReadOnly
35-
mode="json"
36-
setOptions={{
37-
showPrintMargin: false,
38-
minLines: 20,
39-
maxLines: Infinity,
40-
highlightActiveLine: false,
41-
}}
42-
theme="textmate"
43-
value={JSON.stringify(hit, null, 2)}
44-
width="100%"
45-
/>
29+
<EuiCodeBlock aria-label={label} language="json" isCopyable paddingSize="s">
30+
{JSON.stringify(hit, null, 2)}
31+
</EuiCodeBlock>
4632
);
4733
}

0 commit comments

Comments
 (0)