Catalog: Wrap EntityOrphanWarning in EntitySwitch
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -41,6 +41,7 @@ import {
|
||||
isKind,
|
||||
EntityHasResourcesCard,
|
||||
EntityOrphanWarning,
|
||||
isOrphan,
|
||||
} from '@backstage/plugin-catalog';
|
||||
import {
|
||||
EntityCircleCIContent,
|
||||
@@ -215,9 +216,14 @@ const errorsContent = (
|
||||
|
||||
const overviewContent = (
|
||||
<Grid container spacing={3} alignItems="stretch">
|
||||
<Grid item xs={12}>
|
||||
<EntityOrphanWarning />
|
||||
</Grid>
|
||||
<EntitySwitch>
|
||||
<EntitySwitch.Case if={isOrphan}>
|
||||
<Grid item xs={12}>
|
||||
<EntityOrphanWarning />
|
||||
</Grid>
|
||||
</EntitySwitch.Case>
|
||||
</EntitySwitch>
|
||||
|
||||
<Grid item md={8} xs={12}>
|
||||
<EntityAboutCard variant="gridItem" />
|
||||
</Grid>
|
||||
|
||||
@@ -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