[ML] Lock the delete annotation button on click (#137306) (#137411)

(cherry picked from commit b378c064c8)

Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
This commit is contained in:
Kibana Machine 2022-07-28 04:19:45 -04:00 committed by GitHub
parent e9fe4ad5f3
commit 5de1d7117d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,6 +78,8 @@ interface State {
}
export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
private deletionInProgress = false;
public state: State = {
isDeleteModalVisible: false,
applyAnnotationToSeries: true,
@ -121,6 +123,8 @@ export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
};
public deleteHandler = async () => {
if (this.deletionInProgress) return;
const { annotationState } = this.state;
const toastNotifications = getToastNotifications();
@ -128,6 +132,8 @@ export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
return;
}
this.deletionInProgress = true;
try {
await ml.annotations.deleteAnnotation(annotationState._id);
toastNotifications.addSuccess(
@ -154,6 +160,8 @@ export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
this.closeDeleteModal();
this.deletionInProgress = false;
const { annotationUpdatesService } = this.props;
annotationUpdatesService.setValue(null);