From 060dd5d518849989f2a16e56c02ac909118e2346 Mon Sep 17 00:00:00 2001 From: mufaddal motiwala Date: Wed, 15 Dec 2021 19:40:33 +0530 Subject: [PATCH] validation added Signed-off-by: mufaddal motiwala --- plugins/newrelic-dashboard/src/Router.tsx | 2 +- plugins/newrelic-dashboard/src/hooks/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/newrelic-dashboard/src/Router.tsx b/plugins/newrelic-dashboard/src/Router.tsx index 67fe12f146..64d185defc 100644 --- a/plugins/newrelic-dashboard/src/Router.tsx +++ b/plugins/newrelic-dashboard/src/Router.tsx @@ -22,7 +22,7 @@ import { useEntity } from '@backstage/plugin-catalog-react'; import { NEWRELIC_GUID } from './constants'; export const isNewRelicDashboardAvailable = (entity: Entity) => - Boolean(entity.metadata.annotations?.[NEWRELIC_GUID]); + Boolean(entity?.metadata?.annotations?.[NEWRELIC_GUID]); type Props = { /** @deprecated The entity is now grabbed from context instead */ diff --git a/plugins/newrelic-dashboard/src/hooks/index.ts b/plugins/newrelic-dashboard/src/hooks/index.ts index 3739607b82..517f3b54b6 100644 --- a/plugins/newrelic-dashboard/src/hooks/index.ts +++ b/plugins/newrelic-dashboard/src/hooks/index.ts @@ -20,8 +20,8 @@ import { NEWRELIC_GUID } from '../constants'; export function useNewRelicDashboardEntity() { const { entity } = useEntity(); const integrationKey: string | undefined = - entity.metadata.annotations?.[NEWRELIC_GUID]; - const name: string | undefined = entity.metadata.name; + entity?.metadata?.annotations?.[NEWRELIC_GUID]; + const name: string | undefined = entity?.metadata?.name; return { integrationKey, name }; }