mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Cases] Show toast when a case is updated from the cases list (#123357)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
b44f82e918
commit
ab5741ff78
6 changed files with 19 additions and 6 deletions
|
@ -81,6 +81,6 @@ export const SYNC_CASE = (caseTitle: string) =>
|
|||
export const STATUS_CHANGED_TOASTER_TEXT = i18n.translate(
|
||||
'xpack.cases.containers.statusChangeToasterText',
|
||||
{
|
||||
defaultMessage: 'Alerts in this case have been also had their status updated',
|
||||
defaultMessage: 'Updated the statuses of attached alerts.',
|
||||
}
|
||||
);
|
||||
|
|
|
@ -20,12 +20,15 @@ import { UpdateKey } from './types';
|
|||
import { allCases, basicCase } from './mock';
|
||||
import * as api from './api';
|
||||
import { TestProviders } from '../common/mock';
|
||||
import { useToasts } from '../common/lib/kibana';
|
||||
|
||||
jest.mock('./api');
|
||||
jest.mock('../common/lib/kibana');
|
||||
|
||||
describe('useGetCases', () => {
|
||||
const abortCtrl = new AbortController();
|
||||
const addSuccess = jest.fn();
|
||||
(useToasts as jest.Mock).mockReturnValue({ addSuccess, addError: jest.fn() });
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
@ -113,6 +116,9 @@ describe('useGetCases', () => {
|
|||
abortCtrl.signal
|
||||
);
|
||||
});
|
||||
expect(addSuccess).toHaveBeenCalledWith({
|
||||
title: `Updated "${basicCase.title}"`,
|
||||
});
|
||||
});
|
||||
|
||||
it('refetch cases', async () => {
|
||||
|
|
|
@ -212,6 +212,7 @@ export const useGetCases = (
|
|||
|
||||
const dispatchUpdateCaseProperty = useCallback(
|
||||
async ({ updateKey, updateValue, caseId, refetchCasesStatus, version }: UpdateCase) => {
|
||||
const caseData = state.data.cases.find((caseInfo) => caseInfo.id === caseId);
|
||||
try {
|
||||
didCancelUpdateCases.current = false;
|
||||
abortCtrlUpdateCases.current.abort();
|
||||
|
@ -230,6 +231,15 @@ export const useGetCases = (
|
|||
dispatch({ type: 'FETCH_UPDATE_CASE_SUCCESS' });
|
||||
fetchCases(state.filterOptions, state.queryParams);
|
||||
refetchCasesStatus();
|
||||
if (caseData) {
|
||||
toasts.addSuccess({
|
||||
title: i18n.UPDATED_CASE(caseData.title),
|
||||
text:
|
||||
updateKey === 'status' && caseData.totalAlerts > 0
|
||||
? i18n.STATUS_CHANGED_TOASTER_TEXT
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (!didCancelUpdateCases.current) {
|
||||
|
@ -240,8 +250,7 @@ export const useGetCases = (
|
|||
}
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[state.filterOptions, state.queryParams]
|
||||
[fetchCases, state.data, state.filterOptions, state.queryParams, toasts]
|
||||
);
|
||||
|
||||
const refetchCases = useCallback(() => {
|
||||
|
|
|
@ -97,7 +97,7 @@ describe('utils', () => {
|
|||
|
||||
expect(toast).toEqual({
|
||||
title: 'Updated "My case"',
|
||||
text: 'Alerts in this case have been also had their status updated',
|
||||
text: 'Updated the statuses of attached alerts.',
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -7694,7 +7694,6 @@
|
|||
"xpack.cases.containers.markInProgressCases": "{totalCases, plural, =1 {\"{caseTitle}\"} other {{totalCases}件のケース}}を進行中に設定しました",
|
||||
"xpack.cases.containers.pushToExternalService": "{ serviceName }への送信が正常に完了しました",
|
||||
"xpack.cases.containers.reopenedCases": "{totalCases, plural, =1 {\"{caseTitle}\"} other {{totalCases}件のケース}}をオープンしました",
|
||||
"xpack.cases.containers.statusChangeToasterText": "このケースのアラートはステータスが更新されました",
|
||||
"xpack.cases.containers.syncCase": "\"{caseTitle}\"のアラートが同期されました",
|
||||
"xpack.cases.containers.updatedCase": "\"{caseTitle}\"を更新しました",
|
||||
"xpack.cases.create.stepOneTitle": "ケースフィールド",
|
||||
|
|
|
@ -7753,7 +7753,6 @@
|
|||
"xpack.cases.containers.markInProgressCases": "已将{totalCases, plural, =1 {“{caseTitle}”} other { {totalCases} 个案例}}标记为进行中",
|
||||
"xpack.cases.containers.pushToExternalService": "已成功发送到 { serviceName }",
|
||||
"xpack.cases.containers.reopenedCases": "已打开{totalCases, plural, =1 {“{caseTitle}”} other { {totalCases} 个案例}}",
|
||||
"xpack.cases.containers.statusChangeToasterText": "此案例中的告警也更新了状态",
|
||||
"xpack.cases.containers.syncCase": "“{caseTitle}”中的告警已同步",
|
||||
"xpack.cases.containers.updatedCase": "已更新“{caseTitle}”",
|
||||
"xpack.cases.create.stepOneTitle": "案例字段",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue