-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
404 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...n/public/detections/components/rules/rule_execution_status/rule_status_failed_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiCallOut, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { FormattedDate } from '../../../../common/components/formatted_date'; | ||
|
||
import { RuleExecutionStatus } from '../../../../../common/detection_engine/schemas/common'; | ||
import { normalizeRuleExecutionStatus } from './utils'; | ||
|
||
import * as i18n from './translations'; | ||
|
||
interface RuleStatusFailedCallOutProps { | ||
status: RuleExecutionStatus | null | undefined; | ||
date: string; | ||
message: string; | ||
} | ||
|
||
const RuleStatusFailedCallOutComponent: React.FC<RuleStatusFailedCallOutProps> = ({ | ||
status, | ||
date, | ||
message, | ||
}) => { | ||
const props = getPropsByStatus(status); | ||
if (!props) { | ||
// we will not show this callout for this status | ||
return null; | ||
} | ||
|
||
return ( | ||
<EuiCallOut | ||
title={ | ||
<EuiFlexGroup gutterSize="xs" alignItems="center" justifyContent="flexStart"> | ||
<EuiFlexItem grow={false}>{props.title}</EuiFlexItem> | ||
<EuiFlexItem grow={true}> | ||
<FormattedDate value={date} fieldName="last_failure_at" /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
} | ||
color={props.color} | ||
iconType="alert" | ||
> | ||
<p>{message}</p> | ||
</EuiCallOut> | ||
); | ||
}; | ||
|
||
export const RuleStatusFailedCallOut = React.memo(RuleStatusFailedCallOutComponent); | ||
RuleStatusFailedCallOut.displayName = 'RuleStatusFailedCallOut'; | ||
|
||
// ------------------------------------------------------------------------------------------------- | ||
// Helpers | ||
|
||
interface HelperProps { | ||
color: 'danger' | 'warning'; | ||
title: string; | ||
} | ||
|
||
const getPropsByStatus = (status: RuleExecutionStatus | null | undefined): HelperProps | null => { | ||
const normalizedStatus = normalizeRuleExecutionStatus(status); | ||
switch (normalizedStatus) { | ||
case RuleExecutionStatus.failed: | ||
return { | ||
color: 'danger', | ||
title: i18n.ERROR_CALLOUT_TITLE, | ||
}; | ||
case RuleExecutionStatus.warning: | ||
return { | ||
color: 'warning', | ||
title: i18n.PARTIAL_FAILURE_CALLOUT_TITLE, | ||
}; | ||
default: | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...security_solution/public/detections/components/rules/rule_execution_status/utils.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getStatusColor } from './utils'; | ||
|
||
describe('Rule execution status utils', () => { | ||
describe('getStatusColor', () => { | ||
it('returns "subdued" if null was provided', () => { | ||
expect(getStatusColor(null)).toBe('subdued'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.