Skip to content

Commit

Permalink
feat: add feedback toasts for delete bulk ops COMPASS-7328 (#5011)
Browse files Browse the repository at this point in the history
* feat: add feedback toasts for delete bulk ops

* chore: duplicated log id

* chore: fix duplicated log id

* chore: fix duplicated log ids

* chore: align better to error logging conventions

Co-authored-by: Anna Henningsen <anna.henningsen@mongodb.com>

* chore: reformat

---------

Co-authored-by: Anna Henningsen <anna.henningsen@mongodb.com>
  • Loading branch information
kmruiz and addaleax authored Oct 20, 2023
1 parent 1b8747a commit 38304ec
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions packages/compass-crud/src/stores/crud-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import configureGridStore from './grid-store';
import type { TypeCastMap } from 'hadron-type-checker';
import type AppRegistry from 'hadron-app-registry';
import { BaseRefluxStore } from './base-reflux-store';
import { showConfirmation } from '@mongodb-js/compass-components';
import { openToast, showConfirmation } from '@mongodb-js/compass-components';
export type BSONObject = TypeCastMap['Object'];
export type BSONArray = TypeCastMap['Array'];
type Mutable<T> = { -readonly [P in keyof T]: T[P] };
Expand Down Expand Up @@ -1619,15 +1619,50 @@ class CrudStoreImpl
...this.state.bulkDelete,
status: 'in-progress',
},
}); // TODO: COMPASS-7328
});

openToast('bulk-delete-toast', {
title: '',
variant: 'progress',
dismissible: true,
timeout: null,
description: `${
this.state.bulkDelete.affected || 0
} documents are being deleted.`,
});
}

bulkDeleteFailed(ex: Error) {
return ex; // TODO: COMPASS-7328
openToast('bulk-delete-toast', {
title: '',
variant: 'warning',
dismissible: true,
timeout: 6_000,
description: `${
this.state.bulkDelete.affected || 0
} documents could not be deleted.`,
});

log.error(
mongoLogId(1_001_000_268),
'Bulk Delete Documents',
`Delete opeartion failed: ${ex.message}`,
{
stack: ex.stack,
}
);
}

bulkDeleteSuccess() {
// TODO: COMPASS-7328
openToast('bulk-delete-toast', {
title: '',
variant: 'success',
dismissible: true,
timeout: 6_000,
description: `${
this.state.bulkDelete.affected || 0
} documents have been deleted.`,
});
}

closeBulkDeleteDialog() {
Expand Down

0 comments on commit 38304ec

Please sign in to comment.