-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Cases] Add severity field to create case #131626
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
Merged
academo
merged 54 commits into
elastic:main
from
academo:feature/cases-severity-field-create-form
May 6, 2022
Merged
Changes from all commits
Commits
Show all changes
54 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…
012972c
Merge remote-tracking branch 'origin/feature/cases-severity-field-ui'…
3ff11a2
Merge remote-tracking branch 'upstream/main' into feature/cases-sever…
ec1f3e3
Add a test case for submit case with a selected severity
e3e0560
Add severity to the schema
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
79 changes: 79 additions & 0 deletions
79
x-pack/plugins/cases/public/components/create/severity.test.tsx
This file contains hidden or 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,79 @@ | ||
| /* | ||
| * 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 { Form, FormHook, useForm } from '../../common/shared_imports'; | ||
| import { Severity } from './severity'; | ||
| import { FormProps, schema } from './schema'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { waitFor } from '@testing-library/dom'; | ||
|
|
||
| let globalForm: FormHook; | ||
| const MockHookWrapperComponent: React.FC = ({ children }) => { | ||
| const { form } = useForm<FormProps>({ | ||
| defaultValue: { severity: CaseSeverity.LOW }, | ||
| schema: { | ||
| severity: schema.severity, | ||
| }, | ||
| }); | ||
|
|
||
| globalForm = form; | ||
|
|
||
| return <Form form={form}>{children}</Form>; | ||
| }; | ||
| describe('Severity form field', () => { | ||
| let appMockRender: AppMockRenderer; | ||
| beforeEach(() => { | ||
| appMockRender = createAppMockRenderer(); | ||
| }); | ||
| it('renders', () => { | ||
| const result = appMockRender.render( | ||
| <MockHookWrapperComponent> | ||
| <Severity isLoading={false} /> | ||
| </MockHookWrapperComponent> | ||
| ); | ||
| expect(result.getByTestId('caseSeverity')).toBeTruthy(); | ||
| expect(result.getByTestId('case-severity-selection')).not.toHaveAttribute('disabled'); | ||
| }); | ||
|
|
||
| // default to LOW in this test configuration | ||
| it('defaults to the correct value', () => { | ||
| const result = appMockRender.render( | ||
| <MockHookWrapperComponent> | ||
| <Severity isLoading={false} /> | ||
| </MockHookWrapperComponent> | ||
| ); | ||
| expect(result.getByTestId('caseSeverity')).toBeTruthy(); | ||
| // two items. one for the popover one for the selected field | ||
| expect(result.getAllByTestId('case-severity-selection-low').length).toBe(2); | ||
| }); | ||
|
|
||
| it('selects the correct value when changed', async () => { | ||
| const result = appMockRender.render( | ||
| <MockHookWrapperComponent> | ||
| <Severity isLoading={false} /> | ||
| </MockHookWrapperComponent> | ||
| ); | ||
| expect(result.getByTestId('caseSeverity')).toBeTruthy(); | ||
| userEvent.click(result.getByTestId('case-severity-selection')); | ||
| userEvent.click(result.getByTestId('case-severity-selection-high')); | ||
| await waitFor(() => { | ||
| expect(globalForm.getFormData()).toEqual({ severity: 'high' }); | ||
| }); | ||
| }); | ||
|
|
||
| it('disables when loading data', () => { | ||
| const result = appMockRender.render( | ||
| <MockHookWrapperComponent> | ||
| <Severity isLoading={true} /> | ||
| </MockHookWrapperComponent> | ||
| ); | ||
| expect(result.getByTestId('case-severity-selection')).toHaveAttribute('disabled'); | ||
| }); | ||
| }); |
50 changes: 50 additions & 0 deletions
50
x-pack/plugins/cases/public/components/create/severity.tsx
This file contains hidden or 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,50 @@ | ||
| /* | ||
| * 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 { EuiFormRow } from '@elastic/eui'; | ||
| import React, { memo } from 'react'; | ||
| import { CaseSeverity } from '../../../common/api'; | ||
| import { UseField, useFormContext, useFormData } from '../../common/shared_imports'; | ||
| import { SeveritySelector } from '../severity/selector'; | ||
| import { SEVERITY_TITLE } from '../severity/translations'; | ||
|
|
||
| interface Props { | ||
| isLoading: boolean; | ||
| } | ||
|
|
||
| const SeverityFieldFormComponent = ({ isLoading }: { isLoading: boolean }) => { | ||
| const { setFieldValue } = useFormContext(); | ||
| const [{ severity }] = useFormData({ watch: ['severity'] }); | ||
| const onSeverityChange = (newSeverity: CaseSeverity) => { | ||
| setFieldValue('severity', newSeverity); | ||
| }; | ||
| return ( | ||
| <EuiFormRow data-test-subj="caseSeverity" fullWidth={true} label={SEVERITY_TITLE}> | ||
| <SeveritySelector | ||
| isLoading={isLoading} | ||
| isDisabled={isLoading} | ||
| selectedSeverity={severity ?? CaseSeverity.LOW} | ||
| onSeverityChange={onSeverityChange} | ||
| /> | ||
| </EuiFormRow> | ||
| ); | ||
| }; | ||
| SeverityFieldFormComponent.displayName = 'SeverityFieldForm'; | ||
|
|
||
| const SeverityComponent: React.FC<Props> = ({ isLoading }) => ( | ||
| <UseField | ||
| path={'severity'} | ||
| component={SeverityFieldFormComponent} | ||
| componentProps={{ | ||
| isLoading, | ||
| }} | ||
| /> | ||
| ); | ||
|
|
||
| SeverityComponent.displayName = 'SeverityComponent'; | ||
|
|
||
| export const Severity = memo(SeverityComponent); |
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.
Uh oh!
There was an error while loading. Please reload this page.