-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fixed UI/UX issues: alerts delete confirmation, combobox behaviors #60703
Merged
YulNaumenko
merged 9 commits into
elastic:master
from
YulNaumenko:alerting-ui-ux-issues
Mar 21, 2020
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0f38d5d
Fixed UI/UX issues: alerts delete confirmation
YulNaumenko 88da512
Fixed 4. Popover disappears when clearing the field selector
YulNaumenko 33f0469
Fixed tests
YulNaumenko 2813433
Merge remote-tracking branch 'upstream/master' into alerting-ui-ux-is…
YulNaumenko 0612f4e
Merge remote-tracking branch 'upstream/master' into alerting-ui-ux-is…
YulNaumenko d22aea5
Merge remote-tracking branch 'upstream/master' into alerting-ui-ux-is…
YulNaumenko 699dd87
Fixed due to comments
YulNaumenko 886d75c
fixed tests
YulNaumenko 7ab39b0
Fixed test
YulNaumenko 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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if one delete fails, they will all report as failing. Seems like this needs to be restructured so that the delete's are wrapped in a function that never fails, but internally, it updates
successes
anderrors
, so that it can report a combination of successes and failures.Seems survivable for 7.7, and should probably just be a new tech debt issue.