-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM][CASE] Configure cases: Closure Options & Field Mappings UI (#5…
…9062) * Create closure options radio group * Create closure options component * Refactor structure * Create field mapping row * Create field component * Show closure options * Show field mapping * Translate editUpdate options * Add more siem fields * Remove unnecessary export * Leave spaces between sections * Fix callbacks * Better return * Fix callback * Move thirdPartyFields to parent component * Rename constant Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
2361fe6
commit aea4811
Showing
7 changed files
with
326 additions
and
6 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
x-pack/legacy/plugins/siem/public/pages/case/components/configure_cases/closure_options.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,27 @@ | ||
/* | ||
* 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 { EuiDescribedFormGroup, EuiFormRow } from '@elastic/eui'; | ||
|
||
import * as i18n from './translations'; | ||
import { ClosureOptionsRadio } from './closure_options_radio'; | ||
|
||
const ClosureOptionsComponent: React.FC = () => { | ||
return ( | ||
<EuiDescribedFormGroup | ||
fullWidth | ||
title={<h3>{i18n.CASE_CLOSURE_OPTIONS_TITLE}</h3>} | ||
description={i18n.CASE_CLOSURE_OPTIONS_DESC} | ||
> | ||
<EuiFormRow fullWidth label={i18n.CASE_CLOSURE_OPTIONS_LABEL}> | ||
<ClosureOptionsRadio /> | ||
</EuiFormRow> | ||
</EuiDescribedFormGroup> | ||
); | ||
}; | ||
|
||
export const ClosureOptions = React.memo(ClosureOptionsComponent); |
43 changes: 43 additions & 0 deletions
43
...egacy/plugins/siem/public/pages/case/components/configure_cases/closure_options_radio.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,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 React, { useState } from 'react'; | ||
import { EuiRadioGroup } from '@elastic/eui'; | ||
|
||
import * as i18n from './translations'; | ||
|
||
const ID_PREFIX = 'closure_options'; | ||
const DEFAULT_RADIO = `${ID_PREFIX}_manual`; | ||
|
||
const radios = [ | ||
{ | ||
id: DEFAULT_RADIO, | ||
label: i18n.CASE_CLOSURE_OPTIONS_MANUAL, | ||
}, | ||
{ | ||
id: `${ID_PREFIX}_new_incident`, | ||
label: i18n.CASE_CLOSURE_OPTIONS_NEW_INCIDENT, | ||
}, | ||
{ | ||
id: `${ID_PREFIX}_closed_incident`, | ||
label: i18n.CASE_CLOSURE_OPTIONS_CLOSED_INCIDENT, | ||
}, | ||
]; | ||
|
||
const ClosureOptionsRadioComponent: React.FC = () => { | ||
const [selectedClosure, setSelectedClosure] = useState(DEFAULT_RADIO); | ||
|
||
return ( | ||
<EuiRadioGroup | ||
options={radios} | ||
idSelected={selectedClosure} | ||
onChange={setSelectedClosure} | ||
name="closure_options" | ||
/> | ||
); | ||
}; | ||
|
||
export const ClosureOptionsRadio = React.memo(ClosureOptionsRadioComponent); |
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
66 changes: 66 additions & 0 deletions
66
x-pack/legacy/plugins/siem/public/pages/case/components/configure_cases/field_mapping.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,66 @@ | ||
/* | ||
* 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 { EuiDescribedFormGroup, EuiFormRow, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; | ||
import styled from 'styled-components'; | ||
|
||
import * as i18n from './translations'; | ||
import { FieldMappingRow } from './field_mapping_row'; | ||
|
||
const FieldRowWrapper = styled.div` | ||
margin-top: 8px; | ||
font-size: 14px; | ||
`; | ||
|
||
const supportedThirdPartyFields = [ | ||
{ | ||
value: 'short_description', | ||
inputDisplay: <span>{'Short Description'}</span>, | ||
}, | ||
{ | ||
value: 'comment', | ||
inputDisplay: <span>{'Comment'}</span>, | ||
}, | ||
{ | ||
value: 'tags', | ||
inputDisplay: <span>{'Tags'}</span>, | ||
}, | ||
{ | ||
value: 'description', | ||
inputDisplay: <span>{'Description'}</span>, | ||
}, | ||
]; | ||
|
||
const FieldMappingComponent: React.FC = () => ( | ||
<EuiDescribedFormGroup | ||
fullWidth | ||
title={<h3>{i18n.FIELD_MAPPING_TITLE}</h3>} | ||
description={i18n.FIELD_MAPPING_DESC} | ||
> | ||
<EuiFormRow fullWidth> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<span className="euiFormLabel">{i18n.FIELD_MAPPING_FIRST_COL}</span> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<span className="euiFormLabel">{i18n.FIELD_MAPPING_SECOND_COL}</span> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<span className="euiFormLabel">{i18n.FIELD_MAPPING_THIRD_COL}</span> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFormRow> | ||
<FieldRowWrapper> | ||
<FieldMappingRow siemField="Name" thirdPartyOptions={supportedThirdPartyFields} /> | ||
<FieldMappingRow siemField="Tags" thirdPartyOptions={supportedThirdPartyFields} /> | ||
<FieldMappingRow siemField="Description" thirdPartyOptions={supportedThirdPartyFields} /> | ||
<FieldMappingRow siemField="Comment" thirdPartyOptions={supportedThirdPartyFields} /> | ||
</FieldRowWrapper> | ||
</EuiDescribedFormGroup> | ||
); | ||
|
||
export const FieldMapping = React.memo(FieldMappingComponent); |
73 changes: 73 additions & 0 deletions
73
...ck/legacy/plugins/siem/public/pages/case/components/configure_cases/field_mapping_row.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,73 @@ | ||
/* | ||
* 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, { useState } from 'react'; | ||
import { EuiFlexItem, EuiFlexGroup, EuiSuperSelect, EuiIcon } from '@elastic/eui'; | ||
|
||
import * as i18n from './translations'; | ||
|
||
interface ThirdPartyField { | ||
value: string; | ||
inputDisplay: JSX.Element; | ||
} | ||
interface RowProps { | ||
siemField: string; | ||
thirdPartyOptions: ThirdPartyField[]; | ||
} | ||
|
||
const editUpdateOptions = [ | ||
{ | ||
value: 'nothing', | ||
inputDisplay: <span>{i18n.FIELD_MAPPING_EDIT_NOTHING}</span>, | ||
'data-test-subj': 'edit-update-option-nothing', | ||
}, | ||
{ | ||
value: 'overwrite', | ||
inputDisplay: <span>{i18n.FIELD_MAPPING_EDIT_OVERWRITE}</span>, | ||
'data-test-subj': 'edit-update-option-overwrite', | ||
}, | ||
{ | ||
value: 'append', | ||
inputDisplay: <span>{i18n.FIELD_MAPPING_EDIT_APPEND}</span>, | ||
'data-test-subj': 'edit-update-option-append', | ||
}, | ||
]; | ||
|
||
const FieldMappingRowComponent: React.FC<RowProps> = ({ siemField, thirdPartyOptions }) => { | ||
const [selectedEditUpdate, setSelectedEditUpdate] = useState(editUpdateOptions[0].value); | ||
const [selectedThirdParty, setSelectedThirdParty] = useState(thirdPartyOptions[0].value); | ||
|
||
return ( | ||
<EuiFlexGroup alignItems="center"> | ||
<EuiFlexItem> | ||
<EuiFlexGroup component="span" justifyContent="spaceBetween"> | ||
<EuiFlexItem component="span" grow={false}> | ||
{siemField} | ||
</EuiFlexItem> | ||
<EuiFlexItem component="span" grow={false}> | ||
<EuiIcon type="sortRight" /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiSuperSelect | ||
options={thirdPartyOptions} | ||
valueOfSelected={selectedThirdParty} | ||
onChange={setSelectedThirdParty} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiSuperSelect | ||
options={editUpdateOptions} | ||
valueOfSelected={selectedEditUpdate} | ||
onChange={setSelectedEditUpdate} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; | ||
|
||
export const FieldMappingRow = React.memo(FieldMappingRowComponent); |
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