Skip to content

Commit

Permalink
Merge branch 'master' into use-faster-wait
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Jul 20, 2020
2 parents 8641cf0 + b9413cf commit 0d1d9c4
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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, { Fragment } from 'react';
import {
EuiFacetButton,
EuiFacetGroup,
Expand All @@ -14,8 +14,8 @@ import {
EuiTextColor,
EuiTitle,
} from '@elastic/eui';
import React, { Fragment } from 'react';
import styled from 'styled-components';
import { FormattedMessage } from '@kbn/i18n/react';
import {
AssetsGroupedByServiceByType,
AssetTypeToParts,
Expand Down Expand Up @@ -43,8 +43,15 @@ const FacetGroup = styled(EuiFacetGroup)`
`;

const FacetButton = styled(EuiFacetButton)`
padding: '${(props) => props.theme.eui.paddingSizes.xs} 0';
height: 'unset';
&&& {
.euiFacetButton__icon,
.euiFacetButton__quantity {
opacity: 1;
}
.euiFacetButton__text {
color: ${(props) => props.theme.eui.euiTextColor};
}
}
`;

export function AssetsFacetGroup({ assets }: { assets: AssetsGroupedByServiceByType }) {
Expand All @@ -70,7 +77,15 @@ export function AssetsFacetGroup({ assets }: { assets: AssetsGroupedByServiceByT
<EuiFlexItem>
<EuiTitle key={service} size="xs">
<EuiText>
<h4>{ServiceTitleMap[service]} Assets</h4>
<h4>
<FormattedMessage
id="xpack.ingestManager.epm.assetGroupTitle"
defaultMessage="{assetType} assets"
values={{
assetType: ServiceTitleMap[service],
}}
/>
</h4>
</EuiText>
</EuiTitle>
</EuiFlexItem>
Expand All @@ -83,13 +98,7 @@ export function AssetsFacetGroup({ assets }: { assets: AssetsGroupedByServiceByT
const iconType = type in AssetIcons && AssetIcons[type];
const iconNode = iconType ? <EuiIcon type={iconType} size="s" /> : '';
return (
<FacetButton
key={type}
quantity={parts.length}
icon={iconNode}
// https://github.com/elastic/eui/issues/2216
buttonRef={() => {}}
>
<FacetButton key={type} quantity={parts.length} icon={iconNode} isDisabled={true}>
<EuiTextColor color="subdued">{AssetTitleMap[type]}</EuiTextColor>
</FacetButton>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
EuiCallOut,
EuiText,
} from '@elastic/eui';
import { Status } from '../../../../../common/detection_engine/schemas/common/schemas';
import { alertsIndexPattern } from '../../../../../common/endpoint/constants';
import {
ExceptionListItemSchema,
Expand Down Expand Up @@ -67,6 +68,7 @@ interface AddExceptionModalProps {
};
onCancel: () => void;
onConfirm: (didCloseAlert: boolean) => void;
alertStatus?: Status;
}

const Modal = styled(EuiModal)`
Expand Down Expand Up @@ -105,6 +107,7 @@ export const AddExceptionModal = memo(function AddExceptionModal({
alertData,
onCancel,
onConfirm,
alertStatus,
}: AddExceptionModalProps) {
const { http } = useKibana().services;
const [comment, setComment] = useState('');
Expand Down Expand Up @@ -183,7 +186,8 @@ export const AddExceptionModal = memo(function AddExceptionModal({
if (indexPatternLoading === false && isSignalIndexLoading === false) {
setShouldDisableBulkClose(
entryHasListType(exceptionItemsToAdd) ||
entryHasNonEcsType(exceptionItemsToAdd, indexPatterns)
entryHasNonEcsType(exceptionItemsToAdd, indexPatterns) ||
exceptionItemsToAdd.length === 0
);
}
}, [
Expand Down Expand Up @@ -335,7 +339,7 @@ export const AddExceptionModal = memo(function AddExceptionModal({
</ModalBodySection>
<EuiHorizontalRule />
<ModalBodySection>
{alertData !== undefined && (
{alertData !== undefined && alertStatus !== 'closed' && (
<EuiFormRow fullWidth>
<EuiCheckbox
id="close-alert-on-add-add-exception-checkbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
entryHasListType,
entryHasNonEcsType,
} from '../helpers';
import { Loader } from '../../loader';

interface EditExceptionModalProps {
ruleName: string;
Expand Down Expand Up @@ -124,7 +125,8 @@ export const EditExceptionModal = memo(function EditExceptionModal({
if (indexPatternLoading === false && isSignalIndexLoading === false) {
setShouldDisableBulkClose(
entryHasListType(exceptionItemsToAdd) ||
entryHasNonEcsType(exceptionItemsToAdd, indexPatterns)
entryHasNonEcsType(exceptionItemsToAdd, indexPatterns) ||
exceptionItemsToAdd.length === 0
);
}
}, [
Expand Down Expand Up @@ -204,7 +206,11 @@ export const EditExceptionModal = memo(function EditExceptionModal({
</ModalHeaderSubtitle>
</ModalHeader>

{!isSignalIndexLoading && (
{(addExceptionIsLoading || indexPatternLoading || isSignalIndexLoading) && (
<Loader data-test-subj="loadingEditExceptionModal" size="xl" />
)}

{!isSignalIndexLoading && !addExceptionIsLoading && !indexPatternLoading && (
<>
<ModalBodySection className="builder-section">
<EuiText>{i18n.EXCEPTION_BUILDER_INFO}</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({
alertData={addExceptionModalState.alertData}
onCancel={onAddExceptionCancel}
onConfirm={onAddExceptionConfirm}
alertStatus={filterGroup}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,37 @@ export const sampleRuleAlertParams = (
exceptionsList: getListArrayMock(),
});

export const sampleDocNoSortId = (someUuid: string = sampleIdGuid): SignalSourceHit => ({
export const sampleDocNoSortIdNoVersion = (someUuid: string = sampleIdGuid): SignalSourceHit => ({
_index: 'myFakeSignalIndex',
_type: 'doc',
_score: 100,
_version: 1,
_id: someUuid,
_source: {
someKey: 'someValue',
'@timestamp': '2020-04-20T21:27:45+0000',
},
});

export const sampleDocNoSortIdNoVersion = (someUuid: string = sampleIdGuid): SignalSourceHit => ({
export const sampleDocWithSortId = (
someUuid: string = sampleIdGuid,
ip?: string
): SignalSourceHit => ({
_index: 'myFakeSignalIndex',
_type: 'doc',
_score: 100,
_version: 1,
_id: someUuid,
_source: {
someKey: 'someValue',
'@timestamp': '2020-04-20T21:27:45+0000',
source: {
ip: ip ?? '127.0.0.1',
},
},
sort: ['1234567891111'],
});

export const sampleDocWithSortId = (
export const sampleDocNoSortId = (
someUuid: string = sampleIdGuid,
ip?: string
): SignalSourceHit => ({
Expand All @@ -95,7 +102,7 @@ export const sampleDocWithSortId = (
ip: ip ?? '127.0.0.1',
},
},
sort: ['1234567891111'],
sort: [],
});

export const sampleEmptyDocSearchResults = (): SignalSearchResponse => ({
Expand All @@ -116,6 +123,8 @@ export const sampleEmptyDocSearchResults = (): SignalSearchResponse => ({

export const sampleDocWithAncestors = (): SignalSearchResponse => {
const sampleDoc = sampleDocNoSortId();
delete sampleDoc.sort;
delete sampleDoc._source.source;
sampleDoc._source.signal = {
parent: {
rule: '04128c15-0d1b-4716-a4c5-46997ac7f3bd',
Expand Down Expand Up @@ -317,6 +326,29 @@ export const repeatedSearchResultsWithSortId = (
},
});

export const repeatedSearchResultsWithNoSortId = (
total: number,
pageSize: number,
guids: string[],
ips?: string[]
) => ({
took: 10,
timed_out: false,
_shards: {
total: 10,
successful: 10,
failed: 0,
skipped: 0,
},
hits: {
total,
max_score: 100,
hits: Array.from({ length: pageSize }).map((x, index) => ({
...sampleDocNoSortId(guids[index], ips ? ips[index] : '127.0.0.1'),
})),
},
});

export const sampleDocSearchResultsWithSortId = (
someUuid: string = sampleIdGuid
): SignalSearchResponse => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ describe('buildBulkBody', () => {

test('bulk body builds well-defined body', () => {
const sampleParams = sampleRuleAlertParams();
const doc = sampleDocNoSortId();
delete doc._source.source;
const fakeSignalSourceHit = buildBulkBody({
doc: sampleDocNoSortId(),
doc,
ruleParams: sampleParams,
id: sampleRuleGuid,
name: 'rule-name',
Expand Down Expand Up @@ -107,6 +109,7 @@ describe('buildBulkBody', () => {
test('bulk body builds original_event if it exists on the event to begin with', () => {
const sampleParams = sampleRuleAlertParams();
const doc = sampleDocNoSortId();
delete doc._source.source;
doc._source.event = {
action: 'socket_opened',
module: 'system',
Expand Down Expand Up @@ -208,6 +211,7 @@ describe('buildBulkBody', () => {
test('bulk body builds original_event if it exists on the event to begin with but no kind information', () => {
const sampleParams = sampleRuleAlertParams();
const doc = sampleDocNoSortId();
delete doc._source.source;
doc._source.event = {
action: 'socket_opened',
module: 'system',
Expand Down Expand Up @@ -307,6 +311,7 @@ describe('buildBulkBody', () => {
test('bulk body builds original_event if it exists on the event to begin with with only kind information', () => {
const sampleParams = sampleRuleAlertParams();
const doc = sampleDocNoSortId();
delete doc._source.source;
doc._source.event = {
kind: 'event',
};
Expand Down
Loading

0 comments on commit 0d1d9c4

Please sign in to comment.