-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed UI/UX issues: alerts delete confirmation, combobox behaviors (#…
…60703) * Fixed UI/UX issues: alerts delete confirmation * Fixed 4. Popover disappears when clearing the field selector * Fixed tests * Fixed due to comments * fixed tests * Fixed test
- Loading branch information
1 parent
9e91146
commit 0390251
Showing
13 changed files
with
242 additions
and
158 deletions.
There are no files selected for viewing
91 changes: 0 additions & 91 deletions
91
x-pack/plugins/triggers_actions_ui/public/application/components/delete_connectors_modal.tsx
This file was deleted.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
...k/plugins/triggers_actions_ui/public/application/components/delete_modal_confirmation.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,105 @@ | ||
/* | ||
* 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 { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
import { HttpSetup } from 'kibana/public'; | ||
import { useAppDependencies } from '../app_context'; | ||
|
||
export const DeleteModalConfirmation = ({ | ||
idsToDelete, | ||
apiDeleteCall, | ||
onDeleted, | ||
onCancel, | ||
singleTitle, | ||
multipleTitle, | ||
}: { | ||
idsToDelete: string[]; | ||
apiDeleteCall: ({ | ||
ids, | ||
http, | ||
}: { | ||
ids: string[]; | ||
http: HttpSetup; | ||
}) => Promise<{ successes: string[]; errors: string[] }>; | ||
onDeleted: (deleted: string[]) => void; | ||
onCancel: () => void; | ||
singleTitle: string; | ||
multipleTitle: string; | ||
}) => { | ||
const { http, toastNotifications } = useAppDependencies(); | ||
const numIdsToDelete = idsToDelete.length; | ||
if (!numIdsToDelete) { | ||
return null; | ||
} | ||
const confirmModalText = i18n.translate( | ||
'xpack.triggersActionsUI.deleteSelectedIdsConfirmModal.descriptionText', | ||
{ | ||
defaultMessage: | ||
"You can't recover {numIdsToDelete, plural, one {a deleted {singleTitle}} other {deleted {multipleTitle}}}.", | ||
values: { numIdsToDelete, singleTitle, multipleTitle }, | ||
} | ||
); | ||
const confirmButtonText = i18n.translate( | ||
'xpack.triggersActionsUI.deleteSelectedIdsConfirmModal.deleteButtonLabel', | ||
{ | ||
defaultMessage: | ||
'Delete {numIdsToDelete, plural, one {{singleTitle}} other {# {multipleTitle}}} ', | ||
values: { numIdsToDelete, singleTitle, multipleTitle }, | ||
} | ||
); | ||
const cancelButtonText = i18n.translate( | ||
'xpack.triggersActionsUI.deleteSelectedIdsConfirmModal.cancelButtonLabel', | ||
{ | ||
defaultMessage: 'Cancel', | ||
} | ||
); | ||
return ( | ||
<EuiOverlayMask> | ||
<EuiConfirmModal | ||
buttonColor="danger" | ||
data-test-subj="deleteIdsConfirmation" | ||
title={confirmButtonText} | ||
onCancel={() => onCancel()} | ||
onConfirm={async () => { | ||
const { successes, errors } = await apiDeleteCall({ ids: idsToDelete, http }); | ||
const numSuccesses = successes.length; | ||
const numErrors = errors.length; | ||
onDeleted(successes); | ||
if (numSuccesses > 0) { | ||
toastNotifications.addSuccess( | ||
i18n.translate( | ||
'xpack.triggersActionsUI.components.deleteSelectedIdsSuccessNotification.descriptionText', | ||
{ | ||
defaultMessage: | ||
'Deleted {numSuccesses, number} {numSuccesses, plural, one {{singleTitle}} other {{multipleTitle}}}', | ||
values: { numSuccesses, singleTitle, multipleTitle }, | ||
} | ||
) | ||
); | ||
} | ||
|
||
if (numErrors > 0) { | ||
toastNotifications.addDanger( | ||
i18n.translate( | ||
'xpack.triggersActionsUI.components.deleteSelectedIdsErrorNotification.descriptionText', | ||
{ | ||
defaultMessage: | ||
'Failed to delete {numErrors, number} {numErrors, plural, one {{singleTitle}} other {{multipleTitle}}}', | ||
values: { numErrors, singleTitle, multipleTitle }, | ||
} | ||
) | ||
); | ||
} | ||
}} | ||
cancelButtonText={cancelButtonText} | ||
confirmButtonText={confirmButtonText} | ||
> | ||
{confirmModalText} | ||
</EuiConfirmModal> | ||
</EuiOverlayMask> | ||
); | ||
}; |
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.