Merge pull request #19492 from AmbrishRamachandiran/entity-delete-popup

delete popup added for entity delete action when user delete entity by unregister entity
This commit is contained in:
Johan Haals
2023-08-25 13:39:28 +02:00
committed by GitHub
3 changed files with 21 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
Added delete alert popup when user delete the entity
@@ -48,6 +48,10 @@ describe('UnregisterEntityDialog', () => {
},
};
beforeEach(() => {
jest.spyOn(alertApi, 'post').mockImplementation(() => {});
});
const entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
@@ -346,6 +350,11 @@ describe('UnregisterEntityDialog', () => {
await waitFor(() => {
expect(deleteEntity).toHaveBeenCalled();
expect(onConfirm).toHaveBeenCalled();
expect(alertApi.post).toHaveBeenCalledWith({
message: 'Removed entity n',
severity: 'success',
display: 'transient',
});
});
});
});
@@ -85,7 +85,13 @@ const Contents = ({
setBusy(true);
try {
await state.deleteEntity();
const entityName = entity.metadata.title ?? entity.metadata.name;
onConfirm();
alertApi.post({
message: `Removed entity ${entityName}`,
severity: 'success',
display: 'transient',
});
} catch (err) {
assertError(err);
alertApi.post({ message: err.message });
@@ -94,7 +100,7 @@ const Contents = ({
}
}
},
[alertApi, onConfirm, state],
[alertApi, onConfirm, state, entity],
);
const DialogActionsPanel = () => (