Catalog: Wrap EntityOrphanWarning in EntitySwitch
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -14,12 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { Alert } from '@material-ui/lab';
|
||||
import React, { useState } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { DeleteEntityDialog } from './DeleteEntityDialog';
|
||||
|
||||
export const isOrphan = (entity: Entity) =>
|
||||
entity?.metadata?.annotations?.['backstage.io/orphan'] === 'true';
|
||||
|
||||
/**
|
||||
* Displays a warning alert if the entity is marked as orphan with the ability to delete said entity.
|
||||
*/
|
||||
@@ -28,7 +32,7 @@ export const EntityOrphanWarning = () => {
|
||||
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
|
||||
|
||||
const { entity } = useEntity();
|
||||
if (entity.metadata?.annotations?.['backstage.io/orphan'] !== 'true') {
|
||||
if (entity?.metadata?.annotations?.['backstage.io/orphan'] !== 'true') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { EntityOrphanWarning } from './EntityOrphanWarning';
|
||||
export { EntityOrphanWarning, isOrphan } from './EntityOrphanWarning';
|
||||
|
||||
Reference in New Issue
Block a user