import React from 'react' ; import { Entity } from '@backstage/catalog-model' ; import { Routes , Route } from 'react-router' ; import { MissingAnnotationEmptyState } from '@backstage/core-components' ; import { GITHUB_REPO_ANNOTATION } from './useProjectName' ; import SecurityInsightsTab from './SecurityInsightsTab' ; import { useEntity } from '@backstage/plugin-catalog-react' ; export const isSecurityInsightsAvailable = ( entity ) => Boolean ( entity . metadata . annotations ?. [ GITHUB_REPO_ANNOTATION ] ) ; type Props = { deprecated entity ? : Entity ; } ; export const Router = ( _props ) => { const { entity } = useEntity ( ) ; return ! isSecurityInsightsAvailable ( entity ) ? ( < MissingAnnotationEmptyState annotation = { GITHUB_REPO_ANNOTATION } / > ) : ( < Routes > < Route element = { < SecurityInsightsTab entity = { entity } / > } /> < /Routes>); } ;