Skip to content

Commit

Permalink
[SIEM] Map Docs Link & Intrinsic Ratios (#49267)
Browse files Browse the repository at this point in the history
* rough out markup and intrinsic ratio poc

* reorganize comps

* media queries for aspect ratios

* disable ratio when error; add translations

* unit tests, translations & cleanup

* update copy per ben’s suggestions

* snapshots and translations

* move paddingSize prop inline

* change panel selector

* fix FormattedMessage id

* update snapshots
  • Loading branch information
MichaelMarcialis authored Oct 25, 2019
1 parent ed07fb4 commit 7003c2c
Show file tree
Hide file tree
Showing 14 changed files with 375 additions and 133 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';

import '../../mock/ui_settings';
import { TestProviders } from '../../mock';
import { Embeddable } from './embeddable';

jest.mock('../../lib/settings/use_kibana_ui_setting');

describe('Embeddable', () => {
test('it renders', () => {
const wrapper = shallow(
<TestProviders>
<Embeddable>
<p>{'Test content'}</p>
</Embeddable>
</TestProviders>
);

expect(toJson(wrapper)).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiPanel } from '@elastic/eui';
import React from 'react';
import styled from 'styled-components';

const Panel = styled(EuiPanel)`
overflow: hidden;
`;
Panel.displayName = 'Panel';

export interface EmbeddableProps {
children: React.ReactNode;
}

export const Embeddable = React.memo<EmbeddableProps>(({ children }) => (
<section className="siemEmbeddable">
<Panel paddingSize="none">{children}</Panel>
</section>
));
Embeddable.displayName = 'Embeddable';
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';

import '../../mock/ui_settings';
import { TestProviders } from '../../mock';
import { EmbeddableHeader } from './embeddable_header';

jest.mock('../../lib/settings/use_kibana_ui_setting');

describe('EmbeddableHeader', () => {
test('it renders', () => {
const wrapper = shallow(
<TestProviders>
<EmbeddableHeader title="Test title" />
</TestProviders>
);

expect(toJson(wrapper)).toMatchSnapshot();
});

test('it renders the title', () => {
const wrapper = mount(
<TestProviders>
<EmbeddableHeader title="Test title" />
</TestProviders>
);

expect(
wrapper
.find('[data-test-subj="header-embeddable-title"]')
.first()
.exists()
).toBe(true);
});

test('it renders supplements when children provided', () => {
const wrapper = mount(
<TestProviders>
<EmbeddableHeader title="Test title">
<p>{'Test children'}</p>
</EmbeddableHeader>
</TestProviders>
);

expect(
wrapper
.find('[data-test-subj="header-embeddable-supplements"]')
.first()
.exists()
).toBe(true);
});

test('it DOES NOT render supplements when children not provided', () => {
const wrapper = mount(
<TestProviders>
<EmbeddableHeader title="Test title" />
</TestProviders>
);

expect(
wrapper
.find('[data-test-subj="header-embeddable-supplements"]')
.first()
.exists()
).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
import React from 'react';
import styled, { css } from 'styled-components';

const Header = styled.header.attrs({
className: 'siemEmbeddable__header',
})`
${({ theme }) => css`
border-bottom: ${theme.eui.euiBorderThin};
padding: ${theme.eui.paddingSizes.m};
`}
`;
Header.displayName = 'Header';

export interface EmbeddableHeaderProps {
children?: React.ReactNode;
title: string | React.ReactNode;
}

export const EmbeddableHeader = React.memo<EmbeddableHeaderProps>(({ children, title }) => (
<Header>
<EuiFlexGroup alignItems="center" gutterSize="m">
<EuiFlexItem>
<EuiTitle size="xxxs">
<h6 data-test-subj="header-embeddable-title">{title}</h6>
</EuiTitle>
</EuiFlexItem>

{children && (
<EuiFlexItem data-test-subj="header-embeddable-supplements" grow={false}>
{children}
</EuiFlexItem>
)}
</EuiFlexGroup>
</Header>
));
EmbeddableHeader.displayName = 'EmbeddableHeader';
Loading

0 comments on commit 7003c2c

Please sign in to comment.