Skip to content

Commit

Permalink
Merge branch 'master' into nls/hide-lens
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jul 18, 2021
2 parents b4d8ad4 + e9988b1 commit 789068e
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,34 @@ export const DOCUMENT_CREATION_WARNINGS = {
// This is indented the way it is to work with ApiCodeExample.
// Use dedent() when calling this alone
export const DOCUMENTS_API_JSON_EXAMPLE = `[
{
"id": "park_rocky-mountain",
"title": "Rocky Mountain",
"description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra. Wildlife including mule deer, bighorn sheep, black bears, and cougars inhabit its igneous mountains and glacial valleys. Longs Peak, a classic Colorado fourteener, and the scenic Bear Lake are popular destinations, as well as the historic Trail Ridge Road, which reaches an elevation of more than 12,000 feet (3,700 m).",
"nps_link": "https://www.nps.gov/romo/index.htm",
"states": [
"Colorado"
],
"visitors": 4517585,
"world_heritage_site": false,
"location": "40.4,-105.58",
"acres": 265795.2,
"square_km": 1075.6,
"date_established": "1915-01-26T06:00:00Z"
},
{
"id": "park_saguaro",
"title": "Saguaro",
"description": "Split into the separate Rincon Mountain and Tucson Mountain districts, this park is evidence that the dry Sonoran Desert is still home to a great variety of life spanning six biotic communities. Beyond the namesake giant saguaro cacti, there are barrel cacti, chollas, and prickly pears, as well as lesser long-nosed bats, spotted owls, and javelinas.",
"nps_link": "https://www.nps.gov/sagu/index.htm",
"states": [
"Arizona"
],
"visitors": 820426,
"world_heritage_site": false,
"location": "32.25,-110.5",
"acres": 91715.72,
"square_km": 371.2,
"date_established": "1994-10-14T05:00:00Z"
}
]`;
{
"id": "park_rocky-mountain",
"title": "Rocky Mountain",
"description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra. Wildlife including mule deer, bighorn sheep, black bears, and cougars inhabit its igneous mountains and glacial valleys. Longs Peak, a classic Colorado fourteener, and the scenic Bear Lake are popular destinations, as well as the historic Trail Ridge Road, which reaches an elevation of more than 12,000 feet (3,700 m).",
"nps_link": "https://www.nps.gov/romo/index.htm",
"states": [
"Colorado"
],
"visitors": 4517585,
"world_heritage_site": false,
"location": "40.4,-105.58",
"acres": 265795.2,
"square_km": 1075.6,
"date_established": "1915-01-26T06:00:00Z"
},
{
"id": "park_saguaro",
"title": "Saguaro",
"description": "Split into the separate Rincon Mountain and Tucson Mountain districts, this park is evidence that the dry Sonoran Desert is still home to a great variety of life spanning six biotic communities. Beyond the namesake giant saguaro cacti, there are barrel cacti, chollas, and prickly pears, as well as lesser long-nosed bats, spotted owls, and javelinas.",
"nps_link": "https://www.nps.gov/sagu/index.htm",
"states": [
"Arizona"
],
"visitors": 820426,
"world_heritage_site": false,
"location": "32.25,-110.5",
"acres": 91715.72,
"square_km": 371.2,
"date_established": "1994-10-14T05:00:00Z"
}
]`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import React from 'react';

import dedent from 'dedent';

import { useValues, useActions } from 'kea';

import {
Expand Down Expand Up @@ -107,23 +105,22 @@ export const FlyoutBody: React.FC = () => {
</EuiFlexGroup>
</EuiPanel>
<EuiCodeBlock language="bash" fontSize="m" isCopyable>
{dedent(`
curl -X POST '${documentsApiUrl}'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer ${apiKey}'
-d '${DOCUMENTS_API_JSON_EXAMPLE}'
# Returns
# [
# {
# "id": "park_rocky-mountain",
# "errors": []
# },
# {
# "id": "park_saguaro",
# "errors": []
# }
# ]
`)}
{`\
curl -X POST '${documentsApiUrl}' \\
-H 'Content-Type: application/json' \\
-H 'Authorization: Bearer ${apiKey}' \\
-d '${DOCUMENTS_API_JSON_EXAMPLE}'
# Returns
# [
# {
# "id": "park_rocky-mountain",
# "errors": []
# },
# {
# "id": "park_saguaro",
# "errors": []
# }
# ]`}
</EuiCodeBlock>
</EuiFlyoutBody>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@

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

export const LEAVE_UNASSIGNED_FIELD = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.leaveUnassigned.field',
{
defaultMessage: 'Leave unassigned',
}
);
export const LEAVE_UNASSIGNED_FIELD = '';

export const SUCCESS_MESSAGE = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.success.message',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,30 @@ jest.mock('../../../lib/kibana');
describe('NoEnrichmentsPanelView', () => {
it('renders a qualified container', () => {
const wrapper = mount(
<NoEnrichmentsPanel existingEnrichmentsCount={1} investigationEnrichmentsCount={0} />
<NoEnrichmentsPanel
isIndicatorMatchesPresent={true}
isInvestigationTimeEnrichmentsPresent={false}
/>
);
expect(wrapper.find('[data-test-subj="no-enrichments-panel"]').exists()).toEqual(true);
});

it('renders nothing when all enrichments are present', () => {
const wrapper = mount(
<NoEnrichmentsPanel existingEnrichmentsCount={1} investigationEnrichmentsCount={1} />
<NoEnrichmentsPanel
isIndicatorMatchesPresent={true}
isInvestigationTimeEnrichmentsPresent={true}
/>
);
expect(wrapper.find('[data-test-subj="no-enrichments-panel"]').exists()).toEqual(false);
});

it('renders expected text when no enrichments are present', () => {
const wrapper = mount(
<NoEnrichmentsPanel existingEnrichmentsCount={0} investigationEnrichmentsCount={0} />
<NoEnrichmentsPanel
isIndicatorMatchesPresent={false}
isInvestigationTimeEnrichmentsPresent={false}
/>
);
expect(wrapper.find('[data-test-subj="no-enrichments-panel"]').hostNodes().text()).toContain(
i18n.NO_ENRICHMENTS_FOUND_TITLE
Expand All @@ -39,7 +48,10 @@ describe('NoEnrichmentsPanelView', () => {

it('renders expected text when existing enrichments are absent', () => {
const wrapper = mount(
<NoEnrichmentsPanel existingEnrichmentsCount={0} investigationEnrichmentsCount={1} />
<NoEnrichmentsPanel
isIndicatorMatchesPresent={false}
isInvestigationTimeEnrichmentsPresent={true}
/>
);
expect(wrapper.find('[data-test-subj="no-enrichments-panel"]').hostNodes().text()).toContain(
i18n.NO_INDICATOR_ENRICHMENTS_TITLE
Expand All @@ -48,7 +60,10 @@ describe('NoEnrichmentsPanelView', () => {

it('renders expected text when investigation enrichments are absent', () => {
const wrapper = mount(
<NoEnrichmentsPanel existingEnrichmentsCount={1} investigationEnrichmentsCount={0} />
<NoEnrichmentsPanel
isIndicatorMatchesPresent={true}
isInvestigationTimeEnrichmentsPresent={false}
/>
);
expect(wrapper.find('[data-test-subj="no-enrichments-panel"]').hostNodes().text()).toContain(
i18n.NO_INVESTIGATION_ENRICHMENTS_TITLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const NoEnrichmentsPanelView: React.FC<{
NoEnrichmentsPanelView.displayName = 'NoEnrichmentsPanelView';

export const NoEnrichmentsPanel: React.FC<{
existingEnrichmentsCount: number;
investigationEnrichmentsCount: number;
}> = ({ existingEnrichmentsCount, investigationEnrichmentsCount }) => {
isIndicatorMatchesPresent: boolean;
isInvestigationTimeEnrichmentsPresent: boolean;
}> = ({ isIndicatorMatchesPresent, isInvestigationTimeEnrichmentsPresent }) => {
const threatIntelDocsUrl = `${
useKibana().services.docLinks.links.filebeat.base
}/filebeat-module-threatintel.html`;
Expand All @@ -50,7 +50,7 @@ export const NoEnrichmentsPanel: React.FC<{
</>
);

if (existingEnrichmentsCount === 0 && investigationEnrichmentsCount === 0) {
if (!isIndicatorMatchesPresent && !isInvestigationTimeEnrichmentsPresent) {
return (
<NoEnrichmentsPanelView
title={<h2>{i18n.NO_ENRICHMENTS_FOUND_TITLE}</h2>}
Expand All @@ -61,7 +61,7 @@ export const NoEnrichmentsPanel: React.FC<{
}
/>
);
} else if (existingEnrichmentsCount === 0) {
} else if (!isIndicatorMatchesPresent) {
return (
<>
<EuiHorizontalRule margin="s" />
Expand All @@ -75,7 +75,7 @@ export const NoEnrichmentsPanel: React.FC<{
/>
</>
);
} else if (investigationEnrichmentsCount === 0) {
} else if (!isInvestigationTimeEnrichmentsPresent) {
return (
<>
<EuiHorizontalRule margin="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,14 @@ const EventDetailsComponent: React.FC<Props> = ({
loading: enrichmentsLoading,
result: enrichmentsResponse,
} = useInvestigationTimeEnrichment(eventFields);
const investigationEnrichments = useMemo(() => enrichmentsResponse?.enrichments ?? [], [
enrichmentsResponse?.enrichments,
]);

const allEnrichments = useMemo(() => {
if (enrichmentsLoading || !enrichmentsResponse?.enrichments) {
return existingEnrichments;
}
return filterDuplicateEnrichments([...existingEnrichments, ...enrichmentsResponse.enrichments]);
}, [enrichmentsLoading, enrichmentsResponse, existingEnrichments]);

const enrichmentCount = allEnrichments.length;

const summaryTab: EventViewTab | undefined = useMemo(
Expand Down Expand Up @@ -184,21 +183,16 @@ const EventDetailsComponent: React.FC<Props> = ({
<>
<ThreatDetailsView enrichments={allEnrichments} />
<NoEnrichmentsPanel
investigationEnrichmentsCount={investigationEnrichments.length}
existingEnrichmentsCount={existingEnrichments.length}
isInvestigationTimeEnrichmentsPresent={
enrichmentCount > existingEnrichments.length
}
isIndicatorMatchesPresent={existingEnrichments.length > 0}
/>
</>
),
}
: undefined,
[
allEnrichments,
enrichmentCount,
enrichmentsLoading,
existingEnrichments.length,
investigationEnrichments.length,
isAlert,
]
[allEnrichments, enrichmentCount, enrichmentsLoading, existingEnrichments.length, isAlert]
);

const tableTab = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export const CtiDisabledModuleComponent = () => {
);

return (
<ThreatIntelPanelView totalEventCount={0} splitPanel={danger} listItems={EMPTY_LIST_ITEMS} />
<ThreatIntelPanelView
totalEventCount={0}
splitPanel={danger}
listItems={EMPTY_LIST_ITEMS}
isInspectEnabled={false}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,32 @@ describe('ThreatIntelPanelView', () => {
`Showing: ${mockThreatIntelPanelViewProps.totalEventCount} indicators`
);
});

it('renders inspect button by default', () => {
const wrapper = mount(
<Provider store={store}>
<I18nProvider>
<ThemeProvider theme={mockTheme}>
<ThreatIntelPanelView {...mockThreatIntelPanelViewProps} />
</ThemeProvider>
</I18nProvider>
</Provider>
);

expect(wrapper.exists('[data-test-subj="inspect-icon-button"]')).toBe(true);
});

it('does not render inspect button if isInspectEnabled is false', () => {
const wrapper = mount(
<Provider store={store}>
<I18nProvider>
<ThemeProvider theme={mockTheme}>
<ThreatIntelPanelView {...mockThreatIntelPanelViewProps} isInspectEnabled={false} />
</ThemeProvider>
</I18nProvider>
</Provider>
);

expect(wrapper.exists('[data-test-subj="inspect-icon-button"]')).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const RightSideLink = styled(EuiLink)`
interface ThreatIntelPanelViewProps {
buttonHref?: string;
isDashboardPluginDisabled?: boolean;
isInspectEnabled?: boolean;
listItems: CtiListItem[];
splitPanel?: JSX.Element;
totalEventCount: number;
Expand All @@ -77,6 +78,7 @@ const panelTitle = (
export const ThreatIntelPanelView: React.FC<ThreatIntelPanelViewProps> = ({
buttonHref = '',
isDashboardPluginDisabled,
isInspectEnabled = true,
listItems,
splitPanel,
totalEventCount,
Expand Down Expand Up @@ -142,7 +144,11 @@ export const ThreatIntelPanelView: React.FC<ThreatIntelPanelViewProps> = ({
<EuiFlexItem grow={1}>
<InspectButtonContainer>
<EuiPanel hasBorder>
<HeaderSection id={CTIEventCountQueryId} subtitle={subtitle} title={panelTitle}>
<HeaderSection
id={isInspectEnabled ? CTIEventCountQueryId : undefined}
subtitle={subtitle}
title={panelTitle}
>
<>{button}</>
</HeaderSection>
{splitPanel}
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -8041,7 +8041,6 @@
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.featuredResults.title": "強調された結果",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.go.button": "Go",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.lastUpdated.heading": "最終更新",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.leaveUnassigned.field": "割り当てなし",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.preview.title": "プレビュー",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.reset.button": "リセット",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.resultDetail.label": "結果詳細",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8109,7 +8109,6 @@
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.featuredResults.title": "精选结果",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.go.button": "执行",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.lastUpdated.heading": "上次更新时间",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.leaveUnassigned.field": "不分配",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.preview.title": "预览",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.reset.button": "重置",
"xpack.enterpriseSearch.workplaceSearch.contentSources.displaySettings.resultDetail.label": "结果详情",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dashboardExpect = getService('dashboardExpect');
const searchSessions = getService('searchSessions');

describe('save a search sessions with relative time', () => {
// Failing: See https://github.com/elastic/kibana/issues/97701
describe.skip('save a search sessions with relative time', () => {
before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');

describe('test metadata api', () => {
// Failing: See https://github.com/elastic/kibana/issues/106051
describe.skip('test metadata api', () => {
describe(`POST ${HOST_METADATA_LIST_ROUTE} when index is empty`, () => {
it('metadata api should return empty result when index is empty', async () => {
await deleteMetadataStream(getService);
Expand Down

0 comments on commit 789068e

Please sign in to comment.