Add icons to Add Data list and tutorial view (#16592)

* add icons for home tutorials

* add test for Synopsis component
This commit is contained in:
Nathan Reese 2018-02-13 10:31:19 -07:00 committed by GitHub
parent b677848bee
commit 62f3b808ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 452 additions and 25 deletions

View file

@ -56,7 +56,7 @@ export const tutorialSchema = {
category: Joi.string().valid(Object.values(TUTORIAL_CATEGORY)).required(),
name: Joi.string().required(),
shortDescription: Joi.string().required(),
iconPath: Joi.string(),
euiIconType: Joi.string(), //EUI icon type string, one of https://elastic.github.io/eui/#/icons
longDescription: Joi.string().required(),
completionTimeMinutes: Joi.number().integer(),
previewImagePath: Joi.string(),

View file

@ -0,0 +1,149 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`props iconType 1`] = `
<a
className="euiLink synopsis"
data-test-subj="homeSynopsisLinkgreat tutorial"
href="link_to_item"
>
<EuiFlexGroup
alignItems="stretch"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={false}
>
<EuiIcon
size="xl"
type="logoApache"
/>
</EuiFlexItem>
<EuiFlexItem
className="synopsisContent"
component="div"
grow={true}
>
<EuiTitle
className="synopsisTitle"
size="s"
>
<h4>
Great tutorial
</h4>
</EuiTitle>
<EuiText
className="synopsisBody"
>
<p>
<EuiTextColor
color="subdued"
>
this is a great tutorial about...
</EuiTextColor>
</p>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</a>
`;
exports[`props iconUrl 1`] = `
<a
className="euiLink synopsis"
data-test-subj="homeSynopsisLinkgreat tutorial"
href="link_to_item"
>
<EuiFlexGroup
alignItems="stretch"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={false}
>
<img
alt=""
className="synopsisIcon"
src="icon_url"
/>
</EuiFlexItem>
<EuiFlexItem
className="synopsisContent"
component="div"
grow={true}
>
<EuiTitle
className="synopsisTitle"
size="s"
>
<h4>
Great tutorial
</h4>
</EuiTitle>
<EuiText
className="synopsisBody"
>
<p>
<EuiTextColor
color="subdued"
>
this is a great tutorial about...
</EuiTextColor>
</p>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</a>
`;
exports[`render 1`] = `
<a
className="euiLink synopsis"
data-test-subj="homeSynopsisLinkgreat tutorial"
href="link_to_item"
>
<EuiFlexGroup
alignItems="stretch"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
className="synopsisContent"
component="div"
grow={true}
>
<EuiTitle
className="synopsisTitle"
size="s"
>
<h4>
Great tutorial
</h4>
</EuiTitle>
<EuiText
className="synopsisBody"
>
<p>
<EuiTextColor
color="subdued"
>
this is a great tutorial about...
</EuiTextColor>
</p>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</a>
`;

View file

@ -8,9 +8,10 @@ import {
EuiTitle,
EuiText,
EuiTextColor,
EuiIcon,
} from '@elastic/eui';
export function Synopsis({ description, iconUrl, title, url, wrapInPanel }) {
export function Synopsis({ description, iconUrl, iconType, title, url, wrapInPanel }) {
let optionalImg;
if (iconUrl) {
optionalImg = (
@ -22,6 +23,15 @@ export function Synopsis({ description, iconUrl, title, url, wrapInPanel }) {
/>
</EuiFlexItem>
);
} else if (iconType) {
optionalImg = (
<EuiFlexItem grow={false}>
<EuiIcon
type={iconType}
size="xl"
/>
</EuiFlexItem>
);
}
const content = (
@ -53,8 +63,6 @@ export function Synopsis({ description, iconUrl, title, url, wrapInPanel }) {
);
}
return (
<a
href={url}
@ -69,6 +77,7 @@ export function Synopsis({ description, iconUrl, title, url, wrapInPanel }) {
Synopsis.propTypes = {
description: PropTypes.string.isRequired,
iconUrl: PropTypes.string,
iconType: PropTypes.string,
title: PropTypes.string.isRequired,
url: PropTypes.string.isRequired
};

View file

@ -0,0 +1,35 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Synopsis } from './synopsis';
test('render', () => {
const component = shallow(<Synopsis
description="this is a great tutorial about..."
title="Great tutorial"
url="link_to_item"
/>);
expect(component).toMatchSnapshot(); // eslint-disable-line
});
describe('props', () => {
test('iconType', () => {
const component = shallow(<Synopsis
description="this is a great tutorial about..."
title="Great tutorial"
url="link_to_item"
iconType="logoApache"
/>);
expect(component).toMatchSnapshot(); // eslint-disable-line
});
test('iconUrl', () => {
const component = shallow(<Synopsis
description="this is a great tutorial about..."
title="Great tutorial"
url="link_to_item"
iconUrl="icon_url"
/>);
expect(component).toMatchSnapshot(); // eslint-disable-line
});
});

View file

@ -0,0 +1,171 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`props exportedFieldsUrl 1`] = `
<EuiFlexGroup
alignItems="stretch"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={true}
>
<EuiTitle
size="l"
>
<h2>
Great tutorial
</h2>
</EuiTitle>
<EuiSpacer
size="l"
/>
<Content
text="this is a great tutorial about..."
/>
<div>
<EuiSpacer
size="l"
/>
<EuiButton
color="primary"
fill={false}
href="exported_fields_url"
iconSide="left"
rel="noopener noreferrer"
target="_blank"
type="button"
>
View exported fields
</EuiButton>
</div>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
/>
</EuiFlexGroup>
`;
exports[`props iconType 1`] = `
<EuiFlexGroup
alignItems="stretch"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={true}
>
<EuiTitle
size="l"
>
<h2>
<EuiIcon
size="xl"
style={
Object {
"marginRight": 16,
}
}
type="logoElastic"
/>
Great tutorial
</h2>
</EuiTitle>
<EuiSpacer
size="l"
/>
<Content
text="this is a great tutorial about..."
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
/>
</EuiFlexGroup>
`;
exports[`props previewUrl 1`] = `
<EuiFlexGroup
alignItems="stretch"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={true}
>
<EuiTitle
size="l"
>
<h2>
Great tutorial
</h2>
</EuiTitle>
<EuiSpacer
size="l"
/>
<Content
text="this is a great tutorial about..."
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<EuiImage
allowFullScreen={true}
alt="screenshot of primary dashboard."
fullScreenIconColor="dark"
hasShadow={true}
size="l"
url="preview_image_url"
/>
</EuiFlexItem>
</EuiFlexGroup>
`;
exports[`render 1`] = `
<EuiFlexGroup
alignItems="stretch"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={true}
>
<EuiTitle
size="l"
>
<h2>
Great tutorial
</h2>
</EuiTitle>
<EuiSpacer
size="l"
/>
<Content
text="this is a great tutorial about..."
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
/>
</EuiFlexGroup>
`;

View file

@ -91,6 +91,7 @@ exports[`isCloudEnabled is false should render ON_PREM instructions with instruc
<div>
<Introduction
description="tutorial used to drive jest tests"
iconType="logoApache"
title="jest test tutorial"
/>
<EuiSpacer
@ -175,6 +176,7 @@ exports[`should render ELASTIC_CLOUD instructions when isCloudEnabled is true 1`
<div>
<Introduction
description="tutorial used to drive jest tests"
iconType="logoApache"
title="jest test tutorial"
/>
<EuiSpacer

View file

@ -1,12 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Content } from './content';
import { EuiTitle, EuiFlexItem, EuiFlexGroup, EuiSpacer, EuiImage } from '@elastic/eui';
import {
KuiLinkButton,
} from 'ui_framework/components';
EuiTitle,
EuiFlexItem,
EuiFlexGroup,
EuiSpacer,
EuiImage,
EuiButton,
EuiIcon,
} from '@elastic/eui';
export function Introduction({ description, previewUrl, title, exportedFieldsUrl }) {
export function Introduction({ description, previewUrl, title, exportedFieldsUrl, iconType }) {
let img;
if (previewUrl) {
img = (
@ -25,22 +30,35 @@ export function Introduction({ description, previewUrl, title, exportedFieldsUrl
exportedFields = (
<div>
<EuiSpacer />
<KuiLinkButton
buttonType="secondary"
<EuiButton
href={exportedFieldsUrl}
target="_blank"
rel="noopener noreferrer"
>
View exported fields
</KuiLinkButton>
</EuiButton>
</div>
);
}
let icon;
if (iconType) {
icon = (
<EuiIcon
type={iconType}
size="xl"
style={{ marginRight: 16 }}
/>
);
}
return (
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="l">
<h2>{title}</h2>
<h2>
{icon}
{title}
</h2>
</EuiTitle>
<EuiSpacer />
<Content text={description} />
@ -58,4 +76,5 @@ Introduction.propTypes = {
title: PropTypes.string.isRequired,
previewUrl: PropTypes.string,
exportedFieldsUrl: PropTypes.string,
iconType: PropTypes.string,
};

View file

@ -0,0 +1,41 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Introduction } from './introduction';
test('render', () => {
const component = shallow(<Introduction
description="this is a great tutorial about..."
title="Great tutorial"
/>);
expect(component).toMatchSnapshot(); // eslint-disable-line
});
describe('props', () => {
test('iconType', () => {
const component = shallow(<Introduction
description="this is a great tutorial about..."
title="Great tutorial"
iconType="logoElastic"
/>);
expect(component).toMatchSnapshot(); // eslint-disable-line
});
test('exportedFieldsUrl', () => {
const component = shallow(<Introduction
description="this is a great tutorial about..."
title="Great tutorial"
exportedFieldsUrl="exported_fields_url"
/>);
expect(component).toMatchSnapshot(); // eslint-disable-line
});
test('previewUrl', () => {
const component = shallow(<Introduction
description="this is a great tutorial about..."
title="Great tutorial"
previewUrl="preview_image_url"
/>);
expect(component).toMatchSnapshot(); // eslint-disable-line
});
});

View file

@ -194,6 +194,7 @@ export class Tutorial extends React.Component {
description={this.props.replaceTemplateStrings(this.state.tutorial.longDescription)}
previewUrl={previewUrl}
exportedFieldsUrl={exportedFieldsUrl}
iconType={this.state.tutorial.euiIconType}
/>
<EuiSpacer />

View file

@ -28,6 +28,7 @@ function buildInstructionSet(type) {
const tutorial = {
name: 'jest test tutorial',
longDescription: 'tutorial used to drive jest tests',
euiIconType: 'logoApache',
elasticCloud: buildInstructionSet('elasticCloud'),
onPrem: buildInstructionSet('onPrem'),
onPremElasticCloud: buildInstructionSet('onPremElasticCloud')

View file

@ -93,6 +93,7 @@ export class TutorialDirectory extends React.Component {
return (
<EuiFlexItem key={tutorial.name}>
<Synopsis
iconType={tutorial.euiIconType}
description={tutorial.shortDescription}
title={tutorial.name}
wrapInPanel

View file

@ -11,7 +11,7 @@ export function apacheLogsSpecProvider() {
shortDescription: 'Collect and parse access and error logs created by the Apache HTTP server.',
longDescription: 'The apache2 Filebeat module parses access and error logs created by the Apache 2 HTTP server.' +
' [Learn more]({config.docs.beats.filebeat}/filebeat-module-apache2.html).',
//iconPath: '', TODO
euiIconType: 'logoApache',
artifacts: {
dashboards: [
{

View file

@ -11,7 +11,7 @@ export function apacheMetricsSpecProvider() {
shortDescription: 'Fetch internal metrics from the Apache 2 HTTP server.',
longDescription: 'The `apache` Metricbeat module fetches internal metrics from the Apache 2 HTTP server.' +
' [Learn more]({config.docs.beats.metricbeat}/metricbeat-module-apache.html).',
//iconPath: '', TODO
euiIconType: 'logoApache',
artifacts: {
dashboards: [
{

View file

@ -13,6 +13,7 @@ export function apmSpecProvider() {
' performance metrics and errors from inside your application.' +
' It allows you to monitor the performance of thousands of applications in real time.' +
' [Learn more]({config.docs.base_url}guide/en/apm/get-started/{config.docs.version}/index.html).',
euiIconType: 'apmApp',
artifacts: {
dashboards: [
{

View file

@ -11,7 +11,7 @@ export function dockerMetricsSpecProvider() {
shortDescription: 'Fetch metrics about your Docker containers.',
longDescription: 'The `docker` Metricbeat module fetches metrics from the Docker server.' +
' [Learn more]({config.docs.beats.metricbeat}/metricbeat-module-docker.html).',
//iconPath: '', TODO
euiIconType: 'logoDocker',
artifacts: {
dashboards: [
{

View file

@ -11,7 +11,7 @@ export function kubernetesMetricsSpecProvider() {
shortDescription: 'Fetch metrics from your Kubernetes installation.',
longDescription: 'The `kubernetes` Metricbeat module fetches metrics from the Kubernetes APIs.' +
' [Learn more]({config.docs.beats.metricbeat}/metricbeat-module-kubernetes.html).',
//iconPath: '', TODO
euiIconType: 'logoKubernetes',
artifacts: {
dashboards: [
{

View file

@ -11,7 +11,7 @@ export function mysqlLogsSpecProvider() {
shortDescription: 'Collect and parse error and slow logs created by MySQL.',
longDescription: 'The `mysql` Filebeat module parses error and slow logs created by MySQL.' +
' [Learn more]({config.docs.beats.filebeat}/filebeat-module-mysql.html).',
//iconPath: '', TODO
euiIconType: 'logoMySQL',
artifacts: {
dashboards: [
{

View file

@ -11,7 +11,7 @@ export function mysqlMetricsSpecProvider() {
shortDescription: 'Fetch internal metrics from MySQL.',
longDescription: 'The `mysql` Metricbeat module fetches internal metrics from the MySQL server.' +
' [Learn more]({config.docs.beats.metricbeat}/metricbeat-module-mysql.html).',
//iconPath: '', TODO
euiIconType: 'logoMySQL',
artifacts: {
dashboards: [
{

View file

@ -13,7 +13,6 @@ export function netflowSpecProvider() {
' indexes the events into Elasticsearch, and installs a suite of Kibana dashboards.' +
' This module support Netflow Version 5 and 9.' +
' [Learn more]({config.docs.logstash}/netflow-module.html).',
//iconPath: '', TODO
completionTimeMinutes: 10,
//previewImagePath: 'kibana-apache.png', TODO
onPrem: ON_PREM_INSTRUCTIONS,

View file

@ -11,7 +11,7 @@ export function nginxLogsSpecProvider() {
shortDescription: 'Collect and parse access and error logs created by the Nginx HTTP server.',
longDescription: 'The `nginx` Filebeat module parses access and error logs created by the Nginx HTTP server.' +
' [Learn more]({config.docs.beats.filebeat}/filebeat-module-nginx.html).',
//iconPath: '', TODO
euiIconType: 'logoNginx',
artifacts: {
dashboards: [
{

View file

@ -14,7 +14,7 @@ export function nginxMetricsSpecProvider() {
' [ngx_http_stub_status_module](http://nginx.org/en/docs/http/ngx_http_stub_status_module.html),' +
' which must be enabled in your Nginx installation.' +
' [Learn more]({config.docs.beats.metricbeat}/metricbeat-module-nginx.html).',
//iconPath: '', TODO
euiIconType: 'logoNginx',
artifacts: {
dashboards: [
{

View file

@ -17,7 +17,7 @@ export function redisLogsSpecProvider() {
' option is set.' +
' Note that the `slowlog` fileset is experimental.' +
' [Learn more]({config.docs.beats.filebeat}/filebeat-module-redis.html).',
//iconPath: '', TODO
euiIconType: 'logoRedis',
artifacts: {
dashboards: [
{

View file

@ -11,7 +11,7 @@ export function redisMetricsSpecProvider() {
shortDescription: 'Fetch internal metrics from Redis.',
longDescription: 'The `redis` Metricbeat module fetches internal metrics from the Redis server.' +
' [Learn more]({config.docs.beats.metricbeat}/metricbeat-module-redis.html).',
//iconPath: '', TODO
euiIconType: 'logoRedis',
artifacts: {
dashboards: [
{

View file

@ -12,7 +12,6 @@ export function systemLogsSpecProvider() {
longDescription: 'The `system` Filebeat module collects and parses logs created by the system logging service of common ' +
' Unix/Linux based distributions. This module is not available on Windows.' +
' [Learn more]({config.docs.beats.filebeat}/filebeat-module-system.html).',
//iconPath: '', TODO
artifacts: {
dashboards: [
{

View file

@ -12,7 +12,6 @@ export function systemMetricsSpecProvider() {
longDescription: 'The `system` Metricbeat module collects CPU, memory, network, and disk statistics from the host.' +
' It collects system wide statistics and statistics per process and filesystem.' +
' [Learn more]({config.docs.beats.metricbeat}/metricbeat-module-system.html).',
//iconPath: '', TODO
artifacts: {
dashboards: [
{