From 4b5c4cc5cef87649a4defc72e2d4ffdcfa00a770 Mon Sep 17 00:00:00 2001 From: Dominik Henneke Date: Tue, 19 Jan 2021 16:44:00 +0100 Subject: [PATCH] Update with review comments --- .changeset/cool-horses-applaud.md | 2 +- .../software-catalog/well-known-annotations.md | 10 +++++----- .../UnregisterEntityDialog/UnregisterEntityDialog.tsx | 11 +++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.changeset/cool-horses-applaud.md b/.changeset/cool-horses-applaud.md index f934634225..83667d2b54 100644 --- a/.changeset/cool-horses-applaud.md +++ b/.changeset/cool-horses-applaud.md @@ -2,5 +2,5 @@ '@backstage/plugin-catalog': patch --- -Derive the list of to-deleted entities in the `UnregisterEntityDialog` from the `backstage.io/managed-by-origin-location` annotation. +Derive the list of to-delete entities in the `UnregisterEntityDialog` from the `backstage.io/managed-by-origin-location` annotation. The dialog also rejects deleting entities that are created by the `bootstrap:bootstrap` location. diff --git a/docs/features/software-catalog/well-known-annotations.md b/docs/features/software-catalog/well-known-annotations.md index e3f9e86fae..c74f3cb52c 100644 --- a/docs/features/software-catalog/well-known-annotations.md +++ b/docs/features/software-catalog/well-known-annotations.md @@ -50,12 +50,12 @@ metadata: ``` The value of this annotation is a location reference string (see above). It -points to the location, which registration lead to the creation of the entity. +points to the location, whose registration lead to the creation of the entity. In most cases, the `backstage.io/managed-by-location` and -`backstage.io/managed-by-origin-location` will be equal. It will be different if -the original location delegates to another location. A common case is, that a -location is registered via the `bootstrap:boostrap` which means that is part of -the `app-config.yml` of a backstage installation. +`backstage.io/managed-by-origin-location` will be equal. They will be different +if the original location delegates to another location. A common case is, that a +location is registered as `bootstrap:boostrap` which means that it is part of +the `app-config.yaml` of a backstage installation. ### backstage.io/techdocs-ref diff --git a/plugins/catalog/src/components/UnregisterEntityDialog/UnregisterEntityDialog.tsx b/plugins/catalog/src/components/UnregisterEntityDialog/UnregisterEntityDialog.tsx index 0c52b24d90..1de56e3f1b 100644 --- a/plugins/catalog/src/components/UnregisterEntityDialog/UnregisterEntityDialog.tsx +++ b/plugins/catalog/src/components/UnregisterEntityDialog/UnregisterEntityDialog.tsx @@ -15,7 +15,7 @@ */ import { Entity, ORIGIN_LOCATION_ANNOTATION } from '@backstage/catalog-model'; -import { alertApiRef, Progress, useApi } from '@backstage/core'; +import { alertApiRef, configApiRef, Progress, useApi } from '@backstage/core'; import { Button, Dialog, @@ -81,6 +81,7 @@ export const UnregisterEntityDialog = ({ const fullScreen = useMediaQuery(theme.breakpoints.down('sm')); const catalogApi = useApi(catalogApiRef); const alertApi = useApi(alertApiRef); + const configApi = useApi(configApiRef); const removeEntity = async () => { const uid = entity.metadata.uid; @@ -104,12 +105,14 @@ export const UnregisterEntityDialog = ({ {error ? ( - {error instanceof DeniedLocationException ? ( + {error.name === 'DeniedLocationException' ? ( <> You cannot unregister this entity, since it originates from a protected Backstage configuration (location - {`"${error.locationName}"`}). If you believe this is in error, - please contact your Backstage operator. + {`"${(error as DeniedLocationException).locationName}"`}). If + you believe this is in error, please contact the{' '} + {configApi.getOptionalString('app.title') ?? 'Backstage'}{' '} + operator. ) : ( error.toString()