Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Use the shared ux Markdown component #174320

Merged
merged 12 commits into from
Feb 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { mountWithIntl, findTestSubject } from '@kbn/test-jest-helpers';
import { act } from 'react-dom/test-utils';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import { Markdown } from '@kbn/shared-ux-markdown';
import { LanguageDocumentationPopoverContent } from './documentation_content';

describe('###Documentation popover content', () => {
Expand All @@ -25,11 +25,15 @@ describe('###Documentation popover content', () => {
items: [
{
label: 'Section two item 1',
description: <Markdown markdown={`## Section two item 1 description `} />,
description: (
<Markdown readOnly markdownContent={`## Section two item 1 description `} />
),
},
{
label: 'Section two item 2',
description: <Markdown markdown={`## Section two item 2 description `} />,
description: (
<Markdown readOnly markdownContent={`## Section two item 2 description `} />
),
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import React from 'react';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import { Markdown } from '@kbn/shared-ux-markdown';
import { elementToString } from './element_to_string';

describe('elementToString', () => {
Expand All @@ -21,15 +21,15 @@ describe('elementToString', () => {
});

test('Should convert to string if markdown is passed', () => {
const text = elementToString(<Markdown markdown={`## Markdown goes here `} />);
const text = elementToString(<Markdown markdownContent="## Markdown goes here " readOnly />);
expect(text).toEqual('## Markdown goes here ');
});

test('Should convert to string if children with markdown are passed', () => {
const text = elementToString(
<>
<h1>Meow</h1>
<Markdown markdown={`## Markdown goes here `} />
<Markdown markdownContent="## Markdown goes here " readOnly />
</>
);
expect(text).toEqual('## Markdown goes here ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function elementToString(element?: JSX.Element): string {
return '';
}
const props = element.props;
if (props && 'markdown' in props) {
return String(props.markdown);
if (props && 'markdownContent' in props) {
return String(props.markdownContent);
} else if (props && 'children' in props && Array.isArray(props.children)) {
return props.children.reduce((text: string, child: React.ReactNode): string => {
const validChildren = React.Children.toArray(child).filter(nonNullable);
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-language-documentation-popover/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"kbn_references": [
"@kbn/i18n",
"@kbn/test-jest-helpers",
"@kbn/kibana-react-plugin",
"@kbn/shared-ux-markdown",
],
"exclude": [
"target/**/*",
Expand Down
Loading