mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* fix abort agent singular
* changed toast message to tag(s) updated
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit c46a624d91
)
Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
This commit is contained in:
parent
c6eef453a2
commit
e1696401ba
4 changed files with 25 additions and 8 deletions
|
@ -82,7 +82,23 @@ describe('useActionStatus', () => {
|
|||
});
|
||||
expect(mockSendPostCancelAction).toHaveBeenCalledWith('action1');
|
||||
expect(mockOnAbortSuccess).toHaveBeenCalled();
|
||||
expect(mockOpenConfirm).toHaveBeenCalledWith('This action will abort upgrade of 1 agents', {
|
||||
expect(mockOpenConfirm).toHaveBeenCalledWith('This action will abort upgrade of 1 agent', {
|
||||
title: 'Abort upgrade?',
|
||||
});
|
||||
});
|
||||
|
||||
it('should post abort and invoke callback on abort upgrade - plural', async () => {
|
||||
mockSendPostCancelAction.mockResolvedValue({});
|
||||
let result: any | undefined;
|
||||
await act(async () => {
|
||||
({ result } = renderHook(() => useActionStatus(mockOnAbortSuccess, false)));
|
||||
});
|
||||
await act(async () => {
|
||||
await result.current.abortUpgrade({ ...mockActionStatuses[0], nbAgentsAck: 0 });
|
||||
});
|
||||
expect(mockSendPostCancelAction).toHaveBeenCalledWith('action1');
|
||||
expect(mockOnAbortSuccess).toHaveBeenCalled();
|
||||
expect(mockOpenConfirm).toHaveBeenCalledWith('This action will abort upgrade of 2 agents', {
|
||||
title: 'Abort upgrade?',
|
||||
});
|
||||
});
|
||||
|
|
|
@ -54,7 +54,8 @@ export function useActionStatus(onAbortSuccess: () => void, refreshAgentActivity
|
|||
try {
|
||||
const confirmRes = await overlays.openConfirm(
|
||||
i18n.translate('xpack.fleet.currentUpgrade.confirmDescription', {
|
||||
defaultMessage: 'This action will abort upgrade of {nbAgents} agents',
|
||||
defaultMessage:
|
||||
'This action will abort upgrade of {nbAgents, plural, one {# agent} other {# agents}}',
|
||||
values: {
|
||||
nbAgents: action.nbAgentsActioned - action.nbAgentsAck,
|
||||
},
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('useUpdateTags', () => {
|
|||
await act(() => result.current.updateTags('agent1', ['tag1'], mockOnSuccess));
|
||||
expect(mockOnSuccess).toHaveBeenCalled();
|
||||
expect(useStartServices().notifications.toasts.addSuccess as jest.Mock).toHaveBeenCalledWith(
|
||||
'Tags updated'
|
||||
'Tag(s) updated'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -57,7 +57,7 @@ describe('useUpdateTags', () => {
|
|||
expect(mockOnSuccess).not.toHaveBeenCalled();
|
||||
expect(useStartServices().notifications.toasts.addError as jest.Mock).toHaveBeenCalledWith(
|
||||
'error',
|
||||
{ title: 'Tags update failed' }
|
||||
{ title: 'Tag(s) update failed' }
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe('useUpdateTags', () => {
|
|||
await act(() => result.current.bulkUpdateTags('query', ['tag1'], [], mockOnSuccess));
|
||||
expect(mockOnSuccess).toHaveBeenCalled();
|
||||
expect(useStartServices().notifications.toasts.addSuccess as jest.Mock).toHaveBeenCalledWith(
|
||||
'Tags updated'
|
||||
'Tag(s) updated'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -80,7 +80,7 @@ describe('useUpdateTags', () => {
|
|||
expect(mockOnSuccess).not.toHaveBeenCalled();
|
||||
expect(useStartServices().notifications.toasts.addError as jest.Mock).toHaveBeenCalledWith(
|
||||
'error',
|
||||
{ title: 'Tags update failed' }
|
||||
{ title: 'Tag(s) update failed' }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ export const useUpdateTags = () => {
|
|||
const message =
|
||||
successMessage ??
|
||||
i18n.translate('xpack.fleet.updateAgentTags.successNotificationTitle', {
|
||||
defaultMessage: 'Tags updated',
|
||||
defaultMessage: 'Tag(s) updated',
|
||||
});
|
||||
notifications.toasts.addSuccess(message);
|
||||
|
||||
|
@ -43,7 +43,7 @@ export const useUpdateTags = () => {
|
|||
const errorTitle =
|
||||
errorMessage ??
|
||||
i18n.translate('xpack.fleet.updateAgentTags.errorNotificationTitle', {
|
||||
defaultMessage: 'Tags update failed',
|
||||
defaultMessage: 'Tag(s) update failed',
|
||||
});
|
||||
notifications.toasts.addError(error, { title: errorTitle });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue