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

[7.x] [SIEM] Update Empty Page Messages (#37251) #37367

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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

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
Expand Up @@ -13,10 +13,9 @@ import { EmptyPage } from './index';
test('renders correctly', () => {
const EmptyComponent = shallow(
<EmptyPage
actionPrimaryLabel="Do Something"
actionPrimaryUrl="my/url/from/nowwhere"
title="My Super Title"
message="My awesome message"
actionLabel="Do Something"
actionUrl="my/url/from/nowwhere"
/>
);
expect(toJson(EmptyComponent)).toMatchSnapshot();
Expand Down
69 changes: 54 additions & 15 deletions x-pack/plugins/siem/public/components/empty_page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,73 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiButton, EuiEmptyPrompt } from '@elastic/eui';
import { EuiButton, EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem, IconType } from '@elastic/eui';
import React from 'react';
import { pure } from 'recompose';
import styled from 'styled-components';

const EmptyPrompt = styled(EuiEmptyPrompt)`
align-self: center; // Corrects horizontal centering in IE11
`;

interface EmptyPageProps {
message: string;
title: string;
actionLabel: string;
actionUrl: string;
actionPrimaryIcon?: IconType;
actionPrimaryLabel: string;
actionPrimaryTarget?: string;
actionPrimaryUrl: string;
actionSecondaryIcon?: IconType;
actionSecondaryLabel?: string;
actionSecondaryTarget?: string;
actionSecondaryUrl?: string;
'data-test-subj'?: string;
message?: string;
title: string;
}

export const EmptyPage = pure<EmptyPageProps>(
({ actionLabel, actionUrl, message, title, ...rest }) => (
<CenteredEmptyPrompt
({
actionPrimaryIcon,
actionPrimaryLabel,
actionPrimaryTarget,
actionPrimaryUrl,
actionSecondaryIcon,
actionSecondaryLabel,
actionSecondaryTarget,
actionSecondaryUrl,
message,
title,
...rest
}) => (
<EmptyPrompt
title={<h2>{title}</h2>}
body={<p>{message}</p>}
body={message && <p>{message}</p>}
actions={
<EuiButton href={actionUrl} color="primary" fill>
{actionLabel}
</EuiButton>
<EuiFlexGroup>
<EuiFlexItem>
<EuiButton
fill
href={actionPrimaryUrl}
iconType={actionPrimaryIcon}
target={actionPrimaryTarget}
>
{actionPrimaryLabel}
</EuiButton>
</EuiFlexItem>

{actionSecondaryLabel && actionSecondaryUrl && (
<EuiFlexItem>
<EuiButton
href={actionSecondaryUrl}
iconType={actionSecondaryIcon}
target={actionSecondaryTarget}
>
{actionSecondaryLabel}
</EuiButton>
</EuiFlexItem>
)}
</EuiFlexGroup>
}
{...rest}
/>
)
);

const CenteredEmptyPrompt = styled(EuiEmptyPrompt)`
align-self: center;
`;
18 changes: 8 additions & 10 deletions x-pack/plugins/siem/public/pages/hosts/host_details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import React from 'react';
import { connect } from 'react-redux';
import { StickyContainer } from 'react-sticky';
import { pure } from 'recompose';
import chrome, { Breadcrumb } from 'ui/chrome';
import { Breadcrumb } from 'ui/chrome';
import { StaticIndexPattern } from 'ui/index_patterns';

import { ESTermQuery } from '../../../common/typed_json';
import { EmptyPage } from '../../components/empty_page';
import { FiltersGlobal } from '../../components/filters_global';
import { HeaderPage } from '../../components/header_page';
import { LastEventTime } from '../../components/last_event_time';
Expand All @@ -33,11 +32,11 @@ import { LastEventIndexKey } from '../../graphql/types';
import { convertKueryToElasticSearchQuery, escapeQueryValue } from '../../lib/keury';
import { hostsModel, hostsSelectors, State } from '../../store';

import { HostsEmptyPage } from './hosts_empty_page';
import { HostsKql } from './kql';
import * as i18n from './translations';
import { UrlStateContainer } from '../../components/url_state';

const basePath = chrome.getBasePath();
const type = hostsModel.HostsType.details;

const HostOverviewManage = manageQuery(HostOverview);
Expand Down Expand Up @@ -190,12 +189,11 @@ const HostDetailsComponent = pure<HostDetailsComponentProps>(
</GlobalTime>
</StickyContainer>
) : (
<EmptyPage
title={i18n.NO_AUDITBEAT_INDICES}
message={i18n.LETS_ADD_SOME}
actionLabel={i18n.SETUP_INSTRUCTIONS}
actionUrl={`${basePath}/app/kibana#/home/tutorial_directory/security`}
/>
<>
<HeaderPage title={hostName} />

<HostsEmptyPage />
</>
)
}
</WithSource>
Expand All @@ -213,7 +211,7 @@ export const HostDetails = connect(makeMapStateToProps)(HostDetailsComponent);

export const getBreadcrumbs = (hostId: string): Breadcrumb[] => [
{
text: i18n.HOSTS,
text: i18n.PAGE_TITLE,
href: getHostsUrl(),
},
{
Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/siem/public/pages/hosts/hosts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import { TestProviders } from '../../mock';
import { MockedProvider } from 'react-apollo/test-utils';
import { cloneDeep } from 'lodash/fp';

import * as i18n from './translations';

jest.mock('ui/documentation_links', () => ({
documentationLinks: {
kibana: 'http://www.example.com',
Expand Down Expand Up @@ -89,7 +87,7 @@ describe('Hosts - rendering', () => {
// Why => https://github.com/apollographql/react-apollo/issues/1711
await new Promise(resolve => setTimeout(resolve));
wrapper.update();
expect(wrapper.text()).toContain(i18n.SETUP_INSTRUCTIONS);
expect(wrapper.find('[data-test-subj="empty-page"]').exists()).toBe(true);
});

test('it DOES NOT render the Setup Instructions text when an index is available', async () => {
Expand All @@ -106,6 +104,6 @@ describe('Hosts - rendering', () => {
// Why => https://github.com/apollographql/react-apollo/issues/1711
await new Promise(resolve => setTimeout(resolve));
wrapper.update();
expect(wrapper.text()).not.toContain(i18n.SETUP_INSTRUCTIONS);
expect(wrapper.find('[data-test-subj="empty-page"]').exists()).toBe(false);
});
});
18 changes: 7 additions & 11 deletions x-pack/plugins/siem/public/pages/hosts/hosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { StickyContainer } from 'react-sticky';
import { pure } from 'recompose';
import chrome from 'ui/chrome';

import { EmptyPage } from '../../components/empty_page';
import { FiltersGlobal } from '../../components/filters_global';
import { HeaderPage } from '../../components/header_page';
import { LastEventTime } from '../../components/last_event_time';
Expand All @@ -34,12 +32,11 @@ import { UncommonProcessesQuery } from '../../containers/uncommon_processes';
import { LastEventIndexKey } from '../../graphql/types';
import { hostsModel, hostsSelectors, State } from '../../store';

import { HostsEmptyPage } from './hosts_empty_page';
import { HostsKql } from './kql';
import * as i18n from './translations';
import { UrlStateContainer } from '../../components/url_state';

const basePath = chrome.getBasePath();

const AuthenticationTableManage = manageQuery(AuthenticationTable);
const HostsTableManage = manageQuery(HostsTable);
const EventsTableManage = manageQuery(EventsTable);
Expand All @@ -63,7 +60,7 @@ const HostsComponent = pure<HostsComponentProps>(({ filterQuery }) => (

<HeaderPage
subtitle={<LastEventTime indexKey={LastEventIndexKey.hosts} />}
title={i18n.HOSTS}
title={i18n.PAGE_TITLE}
/>

<GlobalTime>
Expand Down Expand Up @@ -200,12 +197,11 @@ const HostsComponent = pure<HostsComponentProps>(({ filterQuery }) => (
</GlobalTime>
</StickyContainer>
) : (
<EmptyPage
title={i18n.NO_AUDITBEAT_INDICES}
message={i18n.LETS_ADD_SOME}
actionLabel={i18n.SETUP_INSTRUCTIONS}
actionUrl={`${basePath}/app/kibana#/home/tutorial_directory/security`}
/>
<>
<HeaderPage title={i18n.PAGE_TITLE} />

<HostsEmptyPage />
</>
)
}
</WithSource>
Expand Down
30 changes: 30 additions & 0 deletions x-pack/plugins/siem/public/pages/hosts/hosts_empty_page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 React from 'react';
import { pure } from 'recompose';
import chrome from 'ui/chrome';
import { documentationLinks } from 'ui/documentation_links';

import { EmptyPage } from '../../components/empty_page';

import * as i18n from './translations';

const basePath = chrome.getBasePath();

export const HostsEmptyPage = pure(() => (
<EmptyPage
actionPrimaryIcon="gear"
actionPrimaryLabel={i18n.EMPTY_ACTION_PRIMARY}
actionPrimaryUrl={`${basePath}/app/kibana#/home/tutorial_directory/security`}
actionSecondaryIcon="popout"
actionSecondaryLabel={i18n.EMPTY_ACTION_SECONDARY}
actionSecondaryTarget="_blank"
actionSecondaryUrl={documentationLinks.siem}
data-test-subj="empty-page"
title={i18n.EMPTY_TITLE}
/>
));
2 changes: 1 addition & 1 deletion x-pack/plugins/siem/public/pages/hosts/kql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const HostsKql = pure<HostsKqlProps>(({ indexPattern, type }) => (
loadSuggestions={loadSuggestions}
onChange={setFilterQueryDraftFromKueryExpression}
onSubmit={applyFilterQueryFromKueryExpression}
placeholder={i18n.KQL_PLACE_HOLDER}
placeholder={i18n.KQL_PLACEHOLDER}
suggestions={suggestions}
value={filterQueryDraft ? filterQueryDraft.expression : ''}
/>
Expand Down
21 changes: 11 additions & 10 deletions x-pack/plugins/siem/public/pages/hosts/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@

import { i18n } from '@kbn/i18n';

export const HOSTS = i18n.translate('xpack.siem.hosts.hosts', {
defaultMessage: 'Hosts',
export const KQL_PLACEHOLDER = i18n.translate('xpack.siem.hosts.kqlPlaceholder', {
defaultMessage: 'e.g. host.name: "foo"',
});

export const NO_AUDITBEAT_INDICES = i18n.translate('xpack.siem.hosts.noAuditBeatIndicies', {
defaultMessage: "Looks like you don't have any Auditbeat indices.",
export const PAGE_TITLE = i18n.translate('xpack.siem.hosts.pageTitle', {
defaultMessage: 'Hosts',
});

export const KQL_PLACE_HOLDER = i18n.translate('xpack.siem.hosts.kqlPlaceHolder', {
defaultMessage: 'e.g. host.name: "foo"',
export const EMPTY_TITLE = i18n.translate('xpack.siem.hosts.emptyTitle', {
defaultMessage:
'It looks like you don’t have any indices relevant to hosts in the SIEM application',
});

export const LETS_ADD_SOME = i18n.translate('xpack.siem.hosts.letsAddSome.description', {
defaultMessage: "Let's add some!",
export const EMPTY_ACTION_PRIMARY = i18n.translate('xpack.siem.hosts.emptyActionPrimary', {
defaultMessage: 'View setup instructions',
});

export const SETUP_INSTRUCTIONS = i18n.translate('xpack.siem.hosts.setupInstructions', {
defaultMessage: 'Setup Instructions',
export const EMPTY_ACTION_SECONDARY = i18n.translate('xpack.siem.hosts.emptyActionSecondary', {
defaultMessage: 'Go to documentation',
});
19 changes: 8 additions & 11 deletions x-pack/plugins/siem/public/pages/network/ip_details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import React from 'react';
import { connect } from 'react-redux';
import { StickyContainer } from 'react-sticky';
import { pure } from 'recompose';
import chrome, { Breadcrumb } from 'ui/chrome';
import { Breadcrumb } from 'ui/chrome';

import { EmptyPage } from '../../components/empty_page';
import { FiltersGlobal } from '../../components/filters_global';
import { HeaderPage } from '../../components/header_page';
import { LastEventTime } from '../../components/last_event_time';
Expand All @@ -31,14 +30,13 @@ import { networkModel, networkSelectors, State } from '../../store';
import { TlsTable } from '../../components/page/network/tls_table';

import { NetworkKql } from './kql';
import { NetworkEmptyPage } from './network_empty_page';
import * as i18n from './translations';
import { TlsQuery } from '../../containers/tls';
import { UsersTable } from '../../components/page/network/users_table';
import { UsersQuery } from '../../containers/users';
import { UrlStateContainer } from '../../components/url_state';

const basePath = chrome.getBasePath();

const DomainsTableManage = manageQuery(DomainsTable);
const TlsTableManage = manageQuery(TlsTable);
const UsersTableManage = manageQuery(UsersTable);
Expand Down Expand Up @@ -183,12 +181,11 @@ const IPDetailsComponent = pure<IPDetailsComponentProps>(
</GlobalTime>
</StickyContainer>
) : (
<EmptyPage
title={i18n.NO_FILEBEAT_INDICES}
message={i18n.LETS_ADD_SOME}
actionLabel={i18n.SETUP_INSTRUCTIONS}
actionUrl={`${basePath}/app/kibana#/home/tutorial_directory/security`}
/>
<>
<HeaderPage title={ip} />

<NetworkEmptyPage />
</>
)
}
</WithSource>
Expand All @@ -208,7 +205,7 @@ export const IPDetails = connect(makeMapStateToProps)(IPDetailsComponent);

export const getBreadcrumbs = (ip: string): Breadcrumb[] => [
{
text: i18n.NETWORK,
text: i18n.PAGE_TITLE,
href: getNetworkUrl(),
},
{
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/siem/public/pages/network/kql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const NetworkKql = pure<NetworkKqlProps>(({ indexPattern, type }) => (
loadSuggestions={loadSuggestions}
onChange={setFilterQueryDraftFromKueryExpression}
onSubmit={applyFilterQueryFromKueryExpression}
placeholder={i18n.KQL_PLACE_HOLDER}
placeholder={i18n.KQL_PLACEHOLDER}
suggestions={suggestions}
value={filterQueryDraft ? filterQueryDraft.expression : ''}
/>
Expand Down
Loading