import React from 'react' ; import { Route , Routes } from 'react-router' ; import { Entity } from '@backstage/catalog-model' ; import { MissingAnnotationEmptyState } from '@backstage/core-components' ; import BuildkiteBuildsTable from './BuildKiteBuildsTable' ; import BuildkiteBuildView from './BuildKiteBuildView' ; import { BUILDKITE_ANNOTATION } from '../consts' ; import { useEntity } from '@backstage/plugin-catalog-react' ; export const isBuildkiteAvailable = ( entity ) => Boolean ( entity ?. metadata . annotations ?. [ BUILDKITE_ANNOTATION ] ) ; type Props = { deprecated entity ? : Entity ; } ; export const Router = ( _props ) => { const { entity } = useEntity ( ) ; return ! isBuildkiteAvailable ( entity ) ? ( < MissingAnnotationEmptyState annotation = { BUILDKITE_ANNOTATION } / > ) : ( < Routes > < Route path = "/" element = { < BuildkiteBuildsTable entity = { entity } / > } /> < Route element = { < BuildkiteBuildView entity = { entity } / > } /> < /Routes>); } ;