From f88d8873a828a86595a50f261af8b5d584686628 Mon Sep 17 00:00:00 2001 From: alandovskis <61091411+alandovskis@users.noreply.github.com> Date: Wed, 9 Sep 2020 02:52:36 -0400 Subject: [PATCH] Display Warning if TechDocs Annotation is Missing (#2319) * Display warning if TechDocs annotation is missing. * TechDocs: Add link to Getting Started when annotation is missing. --- plugins/techdocs/src/Router.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/techdocs/src/Router.tsx b/plugins/techdocs/src/Router.tsx index 45daa3f3d9..6dc0dd02ad 100644 --- a/plugins/techdocs/src/Router.tsx +++ b/plugins/techdocs/src/Router.tsx @@ -15,8 +15,9 @@ */ import React from 'react'; -import { Route, Routes } from 'react-router-dom'; import { Entity } from '@backstage/catalog-model'; +import { Route, Routes } from 'react-router-dom'; +import { WarningPanel } from '@backstage/core'; import { rootRouteRef, @@ -27,6 +28,8 @@ import { TechDocsHome } from './reader/components/TechDocsHome'; import { TechDocsPage } from './reader/components/TechDocsPage'; import { EntityPageDocs } from './EntityPageDocs'; +const TECHDOCS_ANNOTATION = 'backstage.io/techdocs-ref'; + export const Router = () => { return ( @@ -37,6 +40,20 @@ export const Router = () => { }; export const EmbeddedDocsRouter = ({ entity }: { entity: Entity }) => { + const projectId = entity.metadata.annotations?.[TECHDOCS_ANNOTATION]; + + if (!projectId) { + return ( + +
{TECHDOCS_ANNOTATION}
annotation is missing on the entity. +
+ + Getting Started + +
+ ); + } + return (