Merge pull request #10675 from backstage/unregister-location-implicit-delete

Update behavior when unregistering locations from `UnregisterEntityDialog`
This commit is contained in:
Fredrik Adelöw
2022-04-08 20:59:45 +02:00
committed by GitHub
2 changed files with 9 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
Updated the "unregister location" behavior in `UnregisterEntityDialog`. Removed unnecessary entity deletion requests that were sent after successfully deleting a location.
@@ -95,18 +95,13 @@ export function useUnregisterEntityDialogState(
);
}, [catalogApi, entity]);
// Unregisters the underlying location and removes all of the entities that
// are spawned from it. Can only ever be called when the prerequisites have
// finished loading successfully, and if there was a matching location.
// Unregisters the underlying location which will remove all of the entities that are spawned from
// it. Can only ever be called when the prerequisites have finished loading successfully, and if
// there was a matching location.
const unregisterLocation = useCallback(
async function unregisterLocationFn() {
const { location, colocatedEntities } = prerequisites.value!;
const { location } = prerequisites.value!;
await catalogApi.removeLocationById(location!.id);
await Promise.allSettled(
colocatedEntities.map(e =>
catalogApi.removeEntityByUid(e.metadata.uid!),
),
);
},
[catalogApi, prerequisites],
);