-
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.
[Security Solution][Case] Attach/Sync alert to case: Fix toast messag…
…es (#87206)
- Loading branch information
Showing
14 changed files
with
353 additions
and
43 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
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/security_solution/public/cases/components/timeline_actions/helpers.test.ts
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 { createUpdateSuccessToaster } from './helpers'; | ||
import { Case } from '../../containers/types'; | ||
|
||
const theCase = { | ||
title: 'My case', | ||
settings: { | ||
syncAlerts: true, | ||
}, | ||
} as Case; | ||
|
||
describe('helpers', () => { | ||
describe('createUpdateSuccessToaster', () => { | ||
it('creates the correct toast when the sync alerts is on', () => { | ||
// We remove the id as is randomly generated | ||
const { id, ...toast } = createUpdateSuccessToaster(theCase); | ||
expect(toast).toEqual({ | ||
color: 'success', | ||
iconType: 'check', | ||
text: 'Alerts in this case have their status synched with the case status', | ||
title: 'An alert has been added to "My case"', | ||
}); | ||
}); | ||
|
||
it('creates the correct toast when the sync alerts is off', () => { | ||
// We remove the id as is randomly generated | ||
const { id, ...toast } = createUpdateSuccessToaster({ | ||
...theCase, | ||
settings: { syncAlerts: false }, | ||
}); | ||
expect(toast).toEqual({ | ||
color: 'success', | ||
iconType: 'check', | ||
title: 'An alert has been added to "My case"', | ||
}); | ||
}); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/security_solution/public/cases/components/timeline_actions/helpers.ts
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,25 @@ | ||
/* | ||
* 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 uuid from 'uuid'; | ||
import { AppToast } from '../../../common/components/toasters'; | ||
import { Case } from '../../containers/types'; | ||
import * as i18n from './translations'; | ||
|
||
export const createUpdateSuccessToaster = (theCase: Case): AppToast => { | ||
const toast: AppToast = { | ||
id: uuid.v4(), | ||
color: 'success', | ||
iconType: 'check', | ||
title: i18n.CASE_CREATED_SUCCESS_TOAST(theCase.title), | ||
}; | ||
|
||
if (theCase.settings.syncAlerts) { | ||
return { ...toast, text: i18n.CASE_CREATED_SUCCESS_TOAST_TEXT }; | ||
} | ||
|
||
return toast; | ||
}; |
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
Oops, something went wrong.