feat(Techdocs) fix the annotations

Signed-off-by: jrwpatterson <jrwpatterson@gmail.com>
This commit is contained in:
jrwpatterson
2023-08-28 08:00:23 +10:00
parent 56e5baf7f0
commit 0299919d86
4 changed files with 16 additions and 10 deletions
@@ -61,6 +61,10 @@ import EditIcon from '@material-ui/icons/Edit';
import { isTemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
import { parseEntityRef } from '@backstage/catalog-model';
const TECHDOCS_ANNOTATION = 'backstage.io/techdocs-ref';
const TECHDOCS_EXTERNAL_ANNOTATION = 'backstage.io/techdocs-entity';
const useStyles = makeStyles({
gridItemCard: {
display: 'flex',
@@ -114,10 +118,10 @@ export function AboutCard(props: AboutCardProps) {
let techdocsRef: CompoundEntityRef | undefined;
if (entity.metadata.annotations?.['backstage.io/techdocs-entity']) {
if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {
try {
techdocsRef = parseEntityRef(
entity.metadata.annotations?.['backstage.io/techdocs-entity'],
entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],
);
// not a fan of this but we don't care if the parseEntityRef fails
} catch {
@@ -135,8 +139,8 @@ export function AboutCard(props: AboutCardProps) {
label: 'View TechDocs',
disabled:
!(
entity.metadata.annotations?.['backstage.io/techdocs-ref'] ||
entity.metadata.annotations?.['backstage.io/techdocs-entity']
entity.metadata.annotations?.[TECHDOCS_ANNOTATION] ||
entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]
) || !viewTechdocLink,
icon: <DocsIcon />,
href:
+4 -2
View File
@@ -25,15 +25,17 @@ import { TechDocsReaderPage } from './plugin';
import { TechDocsReaderPageContent } from './reader/components/TechDocsReaderPageContent';
import { TechDocsReaderPageSubheader } from './reader/components/TechDocsReaderPageSubheader';
const TECHDOCS_EXTERNAL_ANNOTATION = 'backstage.io/techdocs-entity';
type EntityPageDocsProps = { entity: Entity };
export const EntityPageDocs = ({ entity }: EntityPageDocsProps) => {
let entityRef = getCompoundEntityRef(entity);
if (entity.metadata.annotations?.['backstage.io/techdocs-entity']) {
if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {
try {
entityRef = parseEntityRef(
entity.metadata.annotations?.['backstage.io/techdocs-entity'],
entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],
);
} catch {
// not a fan of this but we don't care if the parseEntityRef fails
+1 -1
View File
@@ -84,7 +84,7 @@ export const EmbeddedDocsRouter = (props: PropsWithChildren<{}>) => {
if (!projectId) {
return (
<MissingAnnotationEmptyState
annotation={[TECHDOCS_ANNOTATION, TECHDOCS_EXTERNAL_ANNOTATION]}
annotation={[TECHDOCS_ANNOTATION]}
/>
);
}
+3 -3
View File
@@ -21147,9 +21147,9 @@ __metadata:
linkType: hard
"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001400":
version: 1.0.30001407
resolution: "caniuse-lite@npm:1.0.30001407"
checksum: e1c449d22f120a708accc956c1780f1da01af6c226cb6a324e531dc9f26f53075bff98e6c9cfce806157cdeede459aa8de03a3407b05f71d292a57b2910018b1
version: 1.0.30001522
resolution: "caniuse-lite@npm:1.0.30001522"
checksum: 56e3551c02ae595085114073cf242f7d9d54d32255c80893ca9098a44f44fc6eef353936f234f31c7f4cb894dd2b6c9c4626e30649ee29e04d70aa127eeefeb0
languageName: node
linkType: hard