mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
Port Kibana Overview from js to ts (#211711)
## Summary - Moved Synopsis component to ts - Updated unit tests to use testing-library
This commit is contained in:
parent
670da35d41
commit
14605f462a
6 changed files with 50 additions and 141 deletions
|
@ -64,7 +64,6 @@ exports[`AddData render 1`] = `
|
||||||
description="Ingest data from popular apps and services."
|
description="Ingest data from popular apps and services."
|
||||||
iconType="indexOpen"
|
iconType="indexOpen"
|
||||||
id="home_tutorial_directory"
|
id="home_tutorial_directory"
|
||||||
isBeta={false}
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
title="Ingest data"
|
title="Ingest data"
|
||||||
url="/app/home#/tutorial_directory"
|
url="/app/home#/tutorial_directory"
|
||||||
|
@ -86,7 +85,6 @@ exports[`AddData render 1`] = `
|
||||||
description="Add and manage your fleet of Elastic Agents and integrations."
|
description="Add and manage your fleet of Elastic Agents and integrations."
|
||||||
iconType="indexManagementApp"
|
iconType="indexManagementApp"
|
||||||
id="ingestManager"
|
id="ingestManager"
|
||||||
isBeta={false}
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
title="Add Elastic Agent"
|
title="Add Elastic Agent"
|
||||||
url="/app/ingestManager"
|
url="/app/ingestManager"
|
||||||
|
@ -108,7 +106,6 @@ exports[`AddData render 1`] = `
|
||||||
description="Import your own CSV, NDJSON, or log file"
|
description="Import your own CSV, NDJSON, or log file"
|
||||||
iconType="document"
|
iconType="document"
|
||||||
id="ml_file_data_visualizer"
|
id="ml_file_data_visualizer"
|
||||||
isBeta={false}
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
title="Upload a file"
|
title="Upload a file"
|
||||||
url="/app/ml#/filedatavisualizer"
|
url="/app/ml#/filedatavisualizer"
|
||||||
|
|
|
@ -45,7 +45,6 @@ exports[`ManageData render 1`] = `
|
||||||
description="Control who has access and what tasks they can perform."
|
description="Control who has access and what tasks they can perform."
|
||||||
iconType="securityApp"
|
iconType="securityApp"
|
||||||
id="security"
|
id="security"
|
||||||
isBeta={false}
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
title="Protect your data"
|
title="Protect your data"
|
||||||
url="path-to-security-roles"
|
url="path-to-security-roles"
|
||||||
|
@ -68,7 +67,6 @@ exports[`ManageData render 1`] = `
|
||||||
description="Track the real-time health and performance of your deployment."
|
description="Track the real-time health and performance of your deployment."
|
||||||
iconType="monitoringApp"
|
iconType="monitoringApp"
|
||||||
id="monitoring"
|
id="monitoring"
|
||||||
isBeta={false}
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
title="Monitor the stack"
|
title="Monitor the stack"
|
||||||
url="path-to-monitoring"
|
url="path-to-monitoring"
|
||||||
|
@ -91,7 +89,6 @@ exports[`ManageData render 1`] = `
|
||||||
description="Save snapshots to a backup repository, and restore to recover index and cluster state."
|
description="Save snapshots to a backup repository, and restore to recover index and cluster state."
|
||||||
iconType="storage"
|
iconType="storage"
|
||||||
id="snapshot_restore"
|
id="snapshot_restore"
|
||||||
isBeta={false}
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
title="Store & recover backups"
|
title="Store & recover backups"
|
||||||
url="path-to-snapshot-restore"
|
url="path-to-snapshot-restore"
|
||||||
|
@ -114,7 +111,6 @@ exports[`ManageData render 1`] = `
|
||||||
description="Define lifecycle policies to automatically perform operations as an index ages."
|
description="Define lifecycle policies to automatically perform operations as an index ages."
|
||||||
iconType="indexSettings"
|
iconType="indexSettings"
|
||||||
id="index_lifecycle_management"
|
id="index_lifecycle_management"
|
||||||
isBeta={false}
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
title="Manage index lifecycles"
|
title="Manage index lifecycles"
|
||||||
url="path-to-index-lifecycle-management"
|
url="path-to-index-lifecycle-management"
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`props iconType 1`] = `
|
|
||||||
<EuiCard
|
|
||||||
betaBadgeProps={
|
|
||||||
Object {
|
|
||||||
"label": null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
className="homSynopsis__card homSynopsis__card--noPanel"
|
|
||||||
data-test-subj="homeSynopsisLinktutorial"
|
|
||||||
description="this is a great tutorial about..."
|
|
||||||
href="link_to_item"
|
|
||||||
icon={
|
|
||||||
<EuiIcon
|
|
||||||
color="text"
|
|
||||||
size="l"
|
|
||||||
title=""
|
|
||||||
type="logoApache"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
layout="horizontal"
|
|
||||||
title="Great tutorial"
|
|
||||||
titleElement="h3"
|
|
||||||
titleSize="xs"
|
|
||||||
/>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`props iconUrl 1`] = `
|
|
||||||
<EuiCard
|
|
||||||
betaBadgeProps={
|
|
||||||
Object {
|
|
||||||
"label": null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
className="homSynopsis__card homSynopsis__card--noPanel"
|
|
||||||
data-test-subj="homeSynopsisLinktutorial"
|
|
||||||
description="this is a great tutorial about..."
|
|
||||||
href="link_to_item"
|
|
||||||
icon={
|
|
||||||
<img
|
|
||||||
alt=""
|
|
||||||
className="synopsisIcon"
|
|
||||||
src="icon_url"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
layout="horizontal"
|
|
||||||
title="Great tutorial"
|
|
||||||
titleElement="h3"
|
|
||||||
titleSize="xs"
|
|
||||||
/>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`props isBeta 1`] = `
|
|
||||||
<EuiCard
|
|
||||||
betaBadgeProps={
|
|
||||||
Object {
|
|
||||||
"label": "Beta",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
className="homSynopsis__card homSynopsis__card--noPanel"
|
|
||||||
data-test-subj="homeSynopsisLinktutorial"
|
|
||||||
description="this is a great tutorial about..."
|
|
||||||
href="link_to_item"
|
|
||||||
layout="horizontal"
|
|
||||||
title="Great tutorial"
|
|
||||||
titleElement="h3"
|
|
||||||
titleSize="xs"
|
|
||||||
/>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`render 1`] = `
|
|
||||||
<EuiCard
|
|
||||||
betaBadgeProps={
|
|
||||||
Object {
|
|
||||||
"label": null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
className="homSynopsis__card homSynopsis__card--noPanel"
|
|
||||||
data-test-subj="homeSynopsisLinktutorial"
|
|
||||||
description="this is a great tutorial about..."
|
|
||||||
href="link_to_item"
|
|
||||||
layout="horizontal"
|
|
||||||
title="Great tutorial"
|
|
||||||
titleElement="h3"
|
|
||||||
titleSize="xs"
|
|
||||||
/>
|
|
||||||
`;
|
|
|
@ -8,59 +8,67 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { render } from '@testing-library/react';
|
||||||
|
|
||||||
import { Synopsis } from './synopsis';
|
import { Synopsis } from './synopsis';
|
||||||
|
|
||||||
test('render', () => {
|
describe('Synopsis component', () => {
|
||||||
const component = shallow(
|
test('renders', () => {
|
||||||
|
const { getByText } = render(
|
||||||
<Synopsis
|
<Synopsis
|
||||||
id={'tutorial'}
|
id={'tutorial'}
|
||||||
description="this is a great tutorial about..."
|
description="this is a great tutorial about..."
|
||||||
title="Great tutorial"
|
title="Great tutorial"
|
||||||
url="link_to_item"
|
url="link_to_item"
|
||||||
|
wrapInPanel
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
expect(component).toMatchSnapshot();
|
expect(getByText('this is a great tutorial about...')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('props', () => {
|
|
||||||
test('iconType', () => {
|
test('iconType', () => {
|
||||||
const component = shallow(
|
const { container } = render(
|
||||||
<Synopsis
|
<Synopsis
|
||||||
id={'tutorial'}
|
id={'tutorial'}
|
||||||
description="this is a great tutorial about..."
|
description="this is a great tutorial about..."
|
||||||
title="Great tutorial"
|
title="Great tutorial"
|
||||||
url="link_to_item"
|
url="link_to_item"
|
||||||
iconType="logoApache"
|
iconType="logoApache"
|
||||||
|
wrapInPanel
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
expect(component).toMatchSnapshot();
|
|
||||||
|
const icon = container.querySelector('[data-euiicon-type="logoApache"]');
|
||||||
|
expect(icon).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('iconUrl', () => {
|
test('iconUrl', () => {
|
||||||
const component = shallow(
|
const { getByRole } = render(
|
||||||
<Synopsis
|
<Synopsis
|
||||||
id={'tutorial'}
|
id={'tutorial'}
|
||||||
description="this is a great tutorial about..."
|
description="this is a great tutorial about..."
|
||||||
title="Great tutorial"
|
title="Great tutorial"
|
||||||
url="link_to_item"
|
url="link_to_item"
|
||||||
iconUrl="icon_url"
|
iconUrl="icon_url"
|
||||||
|
wrapInPanel
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
expect(component).toMatchSnapshot();
|
const anchorElement = getByRole('link', {
|
||||||
|
name: 'Great tutorial',
|
||||||
|
});
|
||||||
|
expect(anchorElement).toHaveAttribute('href', 'link_to_item');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isBeta', () => {
|
test('isBeta', () => {
|
||||||
const component = shallow(
|
const { getByText } = render(
|
||||||
<Synopsis
|
<Synopsis
|
||||||
id={'tutorial'}
|
id={'tutorial'}
|
||||||
description="this is a great tutorial about..."
|
description="this is a great tutorial about..."
|
||||||
title="Great tutorial"
|
title="Great tutorial"
|
||||||
url="link_to_item"
|
url="link_to_item"
|
||||||
isBeta={true}
|
isBeta={true}
|
||||||
|
wrapInPanel
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
expect(component).toMatchSnapshot();
|
expect(getByText('Beta')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -8,35 +8,46 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { EuiCard, EuiCardProps, EuiIcon, IconType } from '@elastic/eui';
|
||||||
|
|
||||||
import { EuiCard, EuiIcon } from '@elastic/eui';
|
export interface SynopsisProps {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
iconUrl?: string;
|
||||||
|
iconType?: IconType;
|
||||||
|
url?: string;
|
||||||
|
isBeta?: boolean;
|
||||||
|
onClick?: EuiCardProps['onClick'];
|
||||||
|
wrapInPanel: boolean;
|
||||||
|
}
|
||||||
export function Synopsis({
|
export function Synopsis({
|
||||||
id,
|
id,
|
||||||
|
title,
|
||||||
description,
|
description,
|
||||||
iconUrl,
|
iconUrl,
|
||||||
iconType,
|
iconType,
|
||||||
title,
|
|
||||||
url,
|
url,
|
||||||
wrapInPanel,
|
|
||||||
onClick,
|
|
||||||
isBeta,
|
isBeta,
|
||||||
}) {
|
onClick,
|
||||||
|
wrapInPanel,
|
||||||
|
}: SynopsisProps) {
|
||||||
let optionalImg;
|
let optionalImg;
|
||||||
|
|
||||||
|
const classes = classNames('homSynopsis__card', {
|
||||||
|
'homSynopsis__card--noPanel': !wrapInPanel,
|
||||||
|
});
|
||||||
|
const betaBadgeProps = isBeta ? { label: 'Beta' } : undefined;
|
||||||
if (iconUrl) {
|
if (iconUrl) {
|
||||||
optionalImg = <img alt="" className="synopsisIcon" src={iconUrl} />;
|
optionalImg = <img alt="" className="synopsisIcon" src={iconUrl} />;
|
||||||
} else if (iconType) {
|
} else if (iconType) {
|
||||||
optionalImg = <EuiIcon color="text" size="l" title="" type={iconType} />;
|
optionalImg = <EuiIcon color="text" size="l" title="" type={iconType} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const classes = classNames('homSynopsis__card', {
|
|
||||||
'homSynopsis__card--noPanel': !wrapInPanel,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EuiCard
|
<EuiCard
|
||||||
|
{...(betaBadgeProps && { betaBadgeProps })}
|
||||||
className={classes}
|
className={classes}
|
||||||
layout="horizontal"
|
layout="horizontal"
|
||||||
icon={optionalImg}
|
icon={optionalImg}
|
||||||
|
@ -46,22 +57,7 @@ export function Synopsis({
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
href={url}
|
href={url}
|
||||||
data-test-subj={`homeSynopsisLink${id.toLowerCase()}`}
|
data-test-subj={`homeSynopsisLink${id.toLowerCase()}`}
|
||||||
betaBadgeProps={{ label: isBeta ? 'Beta' : null }}
|
|
||||||
titleElement="h3"
|
titleElement="h3"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Synopsis.propTypes = {
|
|
||||||
description: PropTypes.string.isRequired,
|
|
||||||
iconUrl: PropTypes.string,
|
|
||||||
iconType: PropTypes.string,
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
url: PropTypes.string,
|
|
||||||
onClick: PropTypes.func,
|
|
||||||
isBeta: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
Synopsis.defaultProps = {
|
|
||||||
isBeta: false,
|
|
||||||
};
|
|
Loading…
Add table
Add a link
Reference in a new issue