-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Cases] severity field in the cases list and allow to filter by it #131694
Merged
academo
merged 73 commits into
elastic:main
from
academo:feature/cases-severity-field-list-table
May 9, 2022
Merged
Changes from all commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
8abc0d3
Add severity field to create API and migration
c7986b0
Adds integration test for severity field migration
8ff9f9b
remove exclusive test
04c413e
Change severity levels
9d488bc
Update integration tests for post case
13f3406
Add more integration tests
a749da5
Fix all cases list test
f76213a
Fix some server test
d62bf70
Fix util server test
8906ccd
Fix client util test
99923ec
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
ede3328
Merge branch 'main' into feature/cases-severity-field
academo 70300c2
Convert event log's duration from number to string in Kibana (keep as…
mikecote bcb2ab1
filter o11y rule aggregations (#131301)
mgiota 7caa070
[Cloud Posture] Display and save rules per benchmark (#131412)
JordanSh ed7c949
Adding aria-label for discover data grid select document checkbox (#1…
bhavyarm e120e56
Update API docs (#130999)
thomasneirynck 16467d1
[CI] Use GCS buckets for bazel remote caching (#131345)
brianseeders 1186b3e
[Actionable Observability] Add license modal to rules table (#131232)
mgiota 0e91bd6
[RAM] Add shareable rule status filter (#130705)
JiaweiWu f11b843
[storybook] Watch for changes in packages (#131467)
clintandrewhall c574ab6
Improve saved objects migrations failure errors and logs (#131359)
TinaHeiligers fed45c9
[Unified observability] Add tour step to guided setup (#131149)
9dd98b9
[Lens] Improved interval input (#131372)
flash1293 8fa9dc8
[Vega] Adjust vega doc for usage of ems files (#130948)
flash1293 e2b8cf4
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
de4a093
Excess intersections
cnasikas 87f2cd5
Create severity user action
cnasikas 6958994
Add severity selector to the case vie wpage
23417a1
Add test cases for the severity field
caa528a
Add severity to create_case user action
cnasikas f528955
Fix and add integration tests
cnasikas 7a7037a
Minor improvements
cnasikas 76faded
Merge branch 'main' into feature/cases-severity-field
academo 4ec9ac3
Merge branch 'feature/cases-severity-field' into feature/cases-severi…
58eb811
Add severity user action builder
54d6c1e
use correct colors for the severity levels
83724b1
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
b2890b1
return null if no severydata found
248092a
disable super select if not permissions
fff645c
Use isDisabled at the superselect level
7d01839
Fix broken TS
5f44fbe
Add the severity field to the create form
5106252
Fix test
c7b9223
Add severity field tests
e3e0dca
Add test cases for the severity field in the create form
da31573
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
4faab1e
Merge branch 'main' into feature/cases-severity-field-ui
academo 918d56b
Merge branch 'main' into feature/cases-severity-field-ui
academo ca68fda
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
42acda8
WIP: List filter
e1e980d
Fix backend API for severity filter
1561248
Allow severity filter
7f04a4a
fix test cases
28f7ff6
Merge remote-tracking branch 'origin/feature/cases-severity-field-ui'…
36f2ae8
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
012972c
Merge remote-tracking branch 'origin/feature/cases-severity-field-ui'…
3ff11a2
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
2577132
Merge branch 'feature/cases-severity-field-create-form' into feature/…
e7a0ed4
Add tests for the severity filter
5a89f9b
Adds validation for severity column in the all cases list test
f18427e
Add tests for the table filter
b342e20
add API tests for filtering
2781374
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
b6672a9
remove comment
da96a48
update tests for the api
a1a54dd
Update useGetCases test
ec674cc
Add test for rbac
5b168a3
Fix severities order
bbd09d0
Change test title
775b2bb
Rollback fixture changes
bb05c1e
add cases for severity fitert
5d33d28
update comment
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
56 changes: 56 additions & 0 deletions
56
x-pack/plugins/cases/public/components/all_cases/severity_filter.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,56 @@ | ||
/* | ||
* 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 { CaseSeverity } from '../../../common/api'; | ||
import React from 'react'; | ||
import { AppMockRenderer, createAppMockRenderer } from '../../common/mock'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { waitFor } from '@testing-library/dom'; | ||
import { SeverityFilter } from './severity_filter'; | ||
|
||
describe('Severity form field', () => { | ||
const onSeverityChange = jest.fn(); | ||
let appMockRender: AppMockRenderer; | ||
const props = { | ||
isLoading: false, | ||
selectedSeverity: CaseSeverity.LOW, | ||
isDisabled: false, | ||
onSeverityChange, | ||
}; | ||
beforeEach(() => { | ||
appMockRender = createAppMockRenderer(); | ||
}); | ||
it('renders', () => { | ||
const result = appMockRender.render(<SeverityFilter {...props} />); | ||
expect(result.getByTestId('case-severity-filter')).not.toHaveAttribute('disabled'); | ||
}); | ||
|
||
// default to LOW in this test configuration | ||
it('defaults to the correct value', () => { | ||
const result = appMockRender.render(<SeverityFilter {...props} />); | ||
// two items. one for the popover one for the selected field | ||
expect(result.getAllByTestId('case-severity-filter-low').length).toBe(2); | ||
}); | ||
|
||
it('selects the correct value when changed', async () => { | ||
const result = appMockRender.render(<SeverityFilter {...props} />); | ||
userEvent.click(result.getByTestId('case-severity-filter')); | ||
userEvent.click(result.getByTestId('case-severity-filter-high')); | ||
await waitFor(() => { | ||
expect(onSeverityChange).toHaveBeenCalledWith('high'); | ||
}); | ||
}); | ||
|
||
it('selects the correct value when changed (all)', async () => { | ||
const result = appMockRender.render(<SeverityFilter {...props} />); | ||
userEvent.click(result.getByTestId('case-severity-filter')); | ||
userEvent.click(result.getByTestId('case-severity-filter-all')); | ||
await waitFor(() => { | ||
expect(onSeverityChange).toHaveBeenCalledWith('all'); | ||
}); | ||
}); | ||
}); |
71 changes: 71 additions & 0 deletions
71
x-pack/plugins/cases/public/components/all_cases/severity_filter.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,71 @@ | ||
/* | ||
* 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 { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiHealth, | ||
EuiSuperSelect, | ||
EuiSuperSelectOption, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
import React from 'react'; | ||
import { CaseSeverityWithAll, SeverityAll } from '../../containers/types'; | ||
import { severitiesWithAll } from '../severity/config'; | ||
|
||
interface Props { | ||
selectedSeverity: CaseSeverityWithAll; | ||
onSeverityChange: (status: CaseSeverityWithAll) => void; | ||
isLoading: boolean; | ||
isDisabled: boolean; | ||
} | ||
|
||
export const SeverityFilter: React.FC<Props> = ({ | ||
selectedSeverity, | ||
onSeverityChange, | ||
isLoading, | ||
isDisabled, | ||
}) => { | ||
const caseSeverities = Object.keys(severitiesWithAll) as CaseSeverityWithAll[]; | ||
const options: Array<EuiSuperSelectOption<CaseSeverityWithAll>> = caseSeverities.map( | ||
(severity) => { | ||
const severityData = severitiesWithAll[severity]; | ||
return { | ||
value: severity, | ||
inputDisplay: ( | ||
<EuiFlexGroup | ||
gutterSize="xs" | ||
alignItems={'center'} | ||
responsive={false} | ||
data-test-subj={`case-severity-filter-${severity}`} | ||
> | ||
<EuiFlexItem grow={false}> | ||
{severity === SeverityAll ? ( | ||
<EuiText size="s">{severityData.label}</EuiText> | ||
) : ( | ||
<EuiHealth color={severityData.color}>{severityData.label}</EuiHealth> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
), | ||
}; | ||
} | ||
); | ||
|
||
return ( | ||
<EuiSuperSelect | ||
disabled={isDisabled} | ||
fullWidth={true} | ||
isLoading={isLoading} | ||
options={options} | ||
valueOfSelected={selectedSeverity} | ||
onChange={onSeverityChange} | ||
data-test-subj="case-severity-filter" | ||
/> | ||
); | ||
}; | ||
SeverityFilter.displayName = 'SeverityFilter'; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section was merely moved down to allow the severity field to show before the status.