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

Delete legacy markdown components #168692

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1d4898d
delete legacy markdown components
vadimkibana Oct 12, 2023
4a917d4
use new markdown component
vadimkibana Oct 12, 2023
75cbf22
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 12, 2023
0a0b8df
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 12, 2023
aa993bc
Merge branch 'main' into comp-dupes-markdown
vadimkibana Oct 19, 2023
dab367d
Merge branch 'main' into comp-dupes-markdown
kibanamachine Oct 19, 2023
988706d
use new markdown component in embeddable error message
vadimkibana Oct 19, 2023
db247f8
Merge remote-tracking branch 'origin/comp-dupes-markdown' into comp-d…
vadimkibana Oct 19, 2023
968dec1
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 19, 2023
b810e62
switch to new Markdown renderer in visualizations
vadimkibana Oct 19, 2023
5d4a210
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 19, 2023
823d5f7
use new Markdown component in Lens and viz
vadimkibana Oct 19, 2023
80e9fa9
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 19, 2023
820506d
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 19, 2023
a12c0bd
add MarkdownSimple component
vadimkibana Oct 23, 2023
6eef74a
use markdown simple component in discover
vadimkibana Oct 23, 2023
19c2191
Merge branch 'main' into comp-dupes-markdown
kibanamachine Oct 26, 2023
7e41c82
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 26, 2023
37455f6
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 26, 2023
0b8b296
Merge branch 'main' into comp-dupes-markdown
vadimkibana Oct 30, 2023
97a16df
Merge branch 'main' into comp-dupes-markdown
kibanamachine Oct 30, 2023
8649a79
Merge remote-tracking branch 'upstream/main' into comp-dupes-markdown
vadimkibana Nov 2, 2023
4e94b7b
remove unused plugin
vadimkibana Nov 2, 2023
f405e80
allow empty markdown text
vadimkibana Nov 2, 2023
705af5a
add missing prop
vadimkibana Nov 2, 2023
ab00b5b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 2, 2023
a6c572f
Revert "delete legacy markdown components"
vadimkibana Nov 6, 2023
74ca9dd
Merge branch 'main' into comp-dupes-markdown
kibanamachine Nov 6, 2023
d1a0bdc
Merge branch 'main' into comp-dupes-markdown
vadimkibana Nov 10, 2023
06d7766
change canvas to use the new component
vadimkibana Nov 10, 2023
3662d34
mark old components more clearly as deprecated
vadimkibana Nov 10, 2023
f93735e
Merge branch 'main' into comp-dupes-markdown
kibanamachine Nov 10, 2023
b110f0e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 10, 2023
8dc3c0b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 10, 2023
2275065
make deprecation label in pascal case
vadimkibana Nov 10, 2023
2fe6304
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 10, 2023
9314037
fix error embeddable tests
vadimkibana Nov 10, 2023
f35f36c
fix markdown vis tests
vadimkibana Nov 10, 2023
bfb49c7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 10, 2023
36e6d55
fix markdown import in tsvb
vadimkibana Nov 11, 2023
9cc505b
Merge remote-tracking branch 'origin/comp-dupes-markdown' into comp-d…
vadimkibana Nov 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';

const Markdown: React.FC<{ markdown: string; openLinksInNewTab?: boolean }> = ({
markdown,
openLinksInNewTab,
}) => {
return <md.Markdown markdownContent={markdown} openLinksInNewTab={openLinksInNewTab} readOnly />;
};

export const initialSection = (
<Markdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';

const Markdown: React.FC<{ markdown: string }> = ({ markdown }) => {
return <md.Markdown markdownContent={markdown} readOnly />;
};

export const initialSection = (
<Markdown
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-text-based-editor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"@kbn/data-plugin",
"@kbn/expressions-plugin",
"@kbn/data-views-plugin",
"@kbn/index-management-plugin"
"@kbn/index-management-plugin",
"@kbn/shared-ux-markdown"
],
"exclude": [
"target/**/*",
Expand Down
1 change: 1 addition & 0 deletions packages/shared-ux/markdown/impl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*/

export { Markdown } from './markdown';
export { MarkdownSimple, type MarkdownSimpleProps } from './markdown_simple';
2 changes: 1 addition & 1 deletion packages/shared-ux/markdown/impl/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Markdown = ({

// Render EuiMarkdownFormat when readOnly set to true
if (readOnly) {
if (!children && !markdownContent) {
if (!children && typeof markdownContent !== 'string') {
throw new Error('Markdown content is required in [readOnly] mode');
}
return (
Expand Down
18 changes: 18 additions & 0 deletions packages/shared-ux/markdown/impl/markdown_simple.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { EuiMarkdownFormat } from '@elastic/eui';

export interface MarkdownSimpleProps {
src: string;
}

export const MarkdownSimple: React.FC<MarkdownSimpleProps> = ({ src }) => (
<EuiMarkdownFormat aria-label={'markdown component'} children={src} />
);
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React, { useState } from 'react';

import { EuiButtonEmpty, EuiPopover } from '@elastic/eui';
import { FormattedMessage, I18nProvider } from '@kbn/i18n-react';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';

interface ControlErrorProps {
error: Error | string;
Expand Down Expand Up @@ -46,8 +46,9 @@ export const ControlError = ({ error }: ControlErrorProps) => {
anchorClassName="errorEmbeddableCompact__popoverAnchor"
closePopover={() => setPopoverOpen(false)}
>
<Markdown
markdown={errorMessage}
<md.Markdown
readOnly
markdownContent={errorMessage}
openLinksInNewTab={true}
data-test-subj="errorMessageMarkdown"
/>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/controls/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@kbn/safer-lodash-set",
"@kbn/ui-actions-plugin",
"@kbn/core-mount-utils-browser",
"@kbn/shared-ux-markdown",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React, { useCallback, useMemo, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { MarkdownSimple } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';
import type { DataView } from '@kbn/data-views-plugin/public';
import { SortDirection } from '@kbn/data-plugin/public';
import type { DataTableRecord } from '@kbn/discover-utils/types';
Expand Down Expand Up @@ -105,7 +105,7 @@ export function useContextAppFetch({
setState(createError('anchorStatus', FailureReason.UNKNOWN, error));
toastNotifications.addDanger({
title: errorTitle,
text: toMountPoint(<MarkdownSimple>{error.message}</MarkdownSimple>, {
text: toMountPoint(<md.MarkdownSimple src={String(error.message)} />, {
theme: services.core.theme,
i18n: services.core.i18n,
}),
Expand Down Expand Up @@ -160,7 +160,7 @@ export function useContextAppFetch({
setState(createError(statusKey, FailureReason.UNKNOWN, error));
toastNotifications.addDanger({
title: errorTitle,
text: toMountPoint(<MarkdownSimple>{error.message}</MarkdownSimple>, {
text: toMountPoint(<md.MarkdownSimple src={String(error.message)} />, {
theme: services.core.theme,
i18n: services.core.i18n,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { Rule } from '@kbn/alerting-plugin/common';
import type { RuleTypeParams } from '@kbn/alerting-plugin/common';
import { ISearchSource, SerializedSearchSourceFields, getTime } from '@kbn/data-plugin/common';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { MarkdownSimple } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { Filter } from '@kbn/es-query';
import { DiscoverAppLocatorParams } from '../../../common/locator';
Expand Down Expand Up @@ -83,7 +83,7 @@ export const getAlertUtils = (
});
toastNotifications.addDanger({
title: errorTitle,
text: toMountPoint(<MarkdownSimple>{error.message}</MarkdownSimple>, {
text: toMountPoint(<md.MarkdownSimple src={String(error.message)} />, {
theme: core.theme,
i18n: core.i18n,
}),
Expand All @@ -106,7 +106,7 @@ export const getAlertUtils = (
});
toastNotifications.addDanger({
title: errorTitle,
text: toMountPoint(<MarkdownSimple>{error.message}</MarkdownSimple>, {
text: toMountPoint(<md.MarkdownSimple src={String(error.message)} />, {
theme: core.theme,
i18n: core.i18n,
}),
Expand Down
1 change: 1 addition & 0 deletions src/plugins/discover/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@kbn/rule-data-utils",
"@kbn/global-search-plugin",
"@kbn/resizable-layout",
"@kbn/shared-ux-markdown",
"@kbn/core-chrome-browser"
],
"exclude": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import React, { ReactNode, useEffect, useMemo, useState } from 'react';
import { EuiButtonEmpty, EuiEmptyPrompt, EuiText } from '@elastic/eui';

import type { MaybePromise } from '@kbn/utility-types';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';
import { ErrorLike } from '@kbn/expressions-plugin/common';

import { EditPanelAction } from './panel_actions';
Expand Down Expand Up @@ -65,12 +65,8 @@ export function EmbeddablePanelError({
return (
<EuiEmptyPrompt
body={
<EuiText size="s">
<Markdown
markdown={error.message}
openLinksInNewTab={true}
data-test-subj="errorMessageMarkdown"
/>
<EuiText size="s" data-test-subj="errorMessageMarkdown">
<md.Markdown readOnly markdownContent={error.message} openLinksInNewTab={true} />
</EuiText>
}
data-test-subj="embeddableStackError"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,23 @@ test('ErrorEmbeddable renders an embeddable with markdown message', async () =>
await waitFor(() => getByTestId('errorMessageMarkdown')); // wait for lazy markdown component
expect(getByText(/some link/i)).toMatchInlineSnapshot(`
<a
class="euiLink emotion-euiLink-primary"
href="http://localhost:5601/takeMeThere"
rel="noopener noreferrer"
target="_blank"
>
some link
<span
class="emotion-euiLink__externalIcon"
data-euiicon-type="popout"
>
External link
</span>
<span
class="emotion-euiScreenReaderOnly-euiLink__screenReaderText"
>
(opens in a new tab or window)
</span>
</a>
`);
});
1 change: 1 addition & 0 deletions src/plugins/embeddable/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@kbn/react-kibana-mount",
"@kbn/unified-search-plugin",
"@kbn/data-views-plugin",
"@kbn/shared-ux-markdown",
],
"exclude": ["target/**/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React, { FC } from 'react';
import { EuiButtonIcon, EuiCallOut } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';
import { ShowDebugging } from './show_debugging';

export interface Props {
Expand Down Expand Up @@ -47,7 +47,7 @@ export const Error: FC<Props> = ({ payload, onClose }) => {
<p>{message ? strings.getDescription() : ''}</p>
{message && (
<p style={{ padding: '0 16px' }}>
<Markdown markdown={message} openLinksInNewTab={true} />
<md.Markdown readOnly markdownContent={message} openLinksInNewTab={true} />
</p>
)}
<ShowDebugging payload={payload} />
Expand Down
1 change: 1 addition & 0 deletions src/plugins/expression_error/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@kbn/i18n",
"@kbn/kibana-react-plugin",
"@kbn/i18n-react",
"@kbn/shared-ux-markdown",
],
"exclude": [
"target/**/*",
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ export { ValidatedDualRange } from './validated_range';
export type { ToastInput, KibanaReactNotifications } from './notifications';
export { createNotifications } from './notifications';

export { toMountPoint } from './util';

/** @deprecated use `Markdown` from `@kbn/shared-ux-markdown` */
export { Markdown, MarkdownSimple } from './markdown';
export {
MarkdownButThisComponentIsDEPRECATED,
MarkdownSimpleButThisComponentIsDEPRECATED,
} from './markdown';

export { toMountPoint } from './util';
export type { ToMountPointOptions } from './util';

/** @deprecated Use `RedirectAppLinks` from `@kbn/shared-ux-link-redirect-app` */
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/kibana_react/public/markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ const Fallback = () => (

/** @deprecated use `Markdown` from `@kbn/shared-ux-markdown` */
const LazyMarkdownSimple = React.lazy(() => import('./markdown_simple'));
export const MarkdownSimple = (props: MarkdownSimpleProps) => (
export const MarkdownSimpleButThisComponentIsDEPRECATED = (props: MarkdownSimpleProps) => (
<React.Suspense fallback={<Fallback />}>
<LazyMarkdownSimple {...props} />
</React.Suspense>
);

/** @deprecated use `Markdown` from `@kbn/shared-ux-markdown` */
const LazyMarkdown = React.lazy(() => import('./markdown'));
export const Markdown = (props: MarkdownProps) => (
export const MarkdownButThisComponentIsDEPRECATED = (props: MarkdownProps) => (
<React.Suspense fallback={<Fallback />}>
<LazyMarkdown {...props} />
</React.Suspense>
Expand Down
1 change: 0 additions & 1 deletion src/plugins/vis_type_markdown/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
],
"requiredBundles": [
"expressions",
"kibanaReact",
"visDefaultEditor",
"visualizations"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe('markdown vis controller', () => {

expect(getByText('markdown')).toMatchInlineSnapshot(`
<a
class="euiLink emotion-euiLink-primary"
href="http://daringfireball.net/projects/markdown"
rel="noreferrer"
>
markdown
</a>
Expand All @@ -53,7 +55,8 @@ describe('markdown vis controller', () => {

expect(getByText(/testing/i)).toMatchInlineSnapshot(`
<p>
Testing &lt;a&gt;html&lt;/a&gt;
Testing
html
</p>
`);
});
Expand Down
10 changes: 3 additions & 7 deletions src/plugins/vis_type_markdown/public/markdown_vis_controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React, { useEffect } from 'react';
import { Markdown } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';
import { MarkdownVisParams } from './types';

import './markdown_vis.scss';
Expand All @@ -25,12 +25,8 @@ const MarkdownVisComponent = ({
useEffect(renderComplete); // renderComplete will be called after each render to signal, that we are done with rendering.

return (
<div className="mkdVis" style={{ fontSize: `${fontSize}pt` }}>
<Markdown
data-test-subj="markdownBody"
markdown={markdown}
openLinksInNewTab={openLinksInNewTab}
/>
<div className="mkdVis" style={{ fontSize: `${fontSize}pt` }} data-test-subj="markdownBody">
<md.Markdown readOnly markdownContent={markdown} openLinksInNewTab={openLinksInNewTab} />
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_markdown/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"@kbn/core",
"@kbn/expressions-plugin",
"@kbn/visualizations-plugin",
"@kbn/kibana-react-plugin",
"@kbn/vis-default-editor-plugin",
"@kbn/i18n",
"@kbn/i18n-react",
"@kbn/config-schema",
"@kbn/shared-ux-markdown",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import React from 'react';
import classNames from 'classnames';
import { get } from 'lodash';
import { ClassNames } from '@emotion/react';
import { Markdown } from '@kbn/kibana-react-plugin/public';

import { MarkdownButThisComponentIsDEPRECATED } from '@kbn/kibana-react-plugin/public';
import { ErrorComponent } from '../../error';
import { replaceVars } from '../../lib/replace_vars';
import { convertSeriesToVars } from '../../lib/convert_series_to_vars';
Expand Down Expand Up @@ -77,7 +76,7 @@ function MarkdownVisualization(props) {
>
<div>
{!markdownError && (
<Markdown
<MarkdownButThisComponentIsDEPRECATED
onRender={initialRender}
markdown={markdownSource}
openLinksInNewTab={model.markdown_openLinksInNewTab}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { EventEmitter } from 'events';
import { i18n } from '@kbn/i18n';
import { FilterStateStore } from '@kbn/es-query';

import { KibanaThemeProvider, MarkdownSimple, toMountPoint } from '@kbn/kibana-react-plugin/public';
import { KibanaThemeProvider, toMountPoint } from '@kbn/kibana-react-plugin/public';
import * as md from '@kbn/shared-ux-markdown';
import { connectToQueryState } from '@kbn/data-plugin/public';
import { migrateLegacyQuery } from '../migrate_legacy_query';
import {
Expand Down Expand Up @@ -129,7 +130,7 @@ export const useVisualizeAppState = (
}),
text: toMountPoint(
<KibanaThemeProvider theme$={services.theme.theme$}>
<MarkdownSimple>{error.message}</MarkdownSimple>
<md.Markdown readOnly markdownContent={error.message} />
</KibanaThemeProvider>
),
});
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/visualizations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"@kbn/serverless",
"@kbn/no-data-page-plugin",
"@kbn/search-response-warnings",
"@kbn/logging"
"@kbn/logging",
"@kbn/shared-ux-markdown"
],
"exclude": [
"target/**/*",
Expand Down
Loading