From 5ad229a24bd3909a53a80d7611506d72f320f5be Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Thu, 31 Mar 2022 08:45:15 +0200 Subject: [PATCH] fix(techdocs): entity page links Signed-off-by: Camila Belo --- plugins/techdocs/package.json | 1 + plugins/techdocs/src/EntityPageDocs.tsx | 15 ++--------- plugins/techdocs/src/Router.tsx | 15 ++++++----- yarn.lock | 35 ++++++++++++------------- 4 files changed, 29 insertions(+), 37 deletions(-) diff --git a/plugins/techdocs/package.json b/plugins/techdocs/package.json index 6716a1a2c5..1ac94c4a03 100644 --- a/plugins/techdocs/package.json +++ b/plugins/techdocs/package.json @@ -38,6 +38,7 @@ "@backstage/catalog-model": "^1.0.1-next.1", "@backstage/config": "^1.0.0", "@backstage/core-components": "^0.9.3-next.1", + "@backstage/core-app-api": "^1.0.0", "@backstage/core-plugin-api": "^1.0.0", "@backstage/errors": "^1.0.0", "@backstage/integration": "^1.1.0-next.1", diff --git a/plugins/techdocs/src/EntityPageDocs.tsx b/plugins/techdocs/src/EntityPageDocs.tsx index 50f44b3773..6cb11a7b25 100644 --- a/plugins/techdocs/src/EntityPageDocs.tsx +++ b/plugins/techdocs/src/EntityPageDocs.tsx @@ -16,26 +16,15 @@ import React from 'react'; -import { configApiRef, useApi } from '@backstage/core-plugin-api'; -import { DEFAULT_NAMESPACE, Entity } from '@backstage/catalog-model'; +import { Entity, getCompoundEntityRef } from '@backstage/catalog-model'; -import { toLowerMaybe } from './helpers'; import { TechDocsReaderPage } from './plugin'; import { TechDocsReaderLayout } from './reader'; type EntityPageDocsProps = { entity: Entity }; export const EntityPageDocs = ({ entity }: EntityPageDocsProps) => { - const config = useApi(configApiRef); - - const entityName = { - namespace: toLowerMaybe( - entity.metadata.namespace ?? DEFAULT_NAMESPACE, - config, - ), - kind: toLowerMaybe(entity.kind, config), - name: toLowerMaybe(entity.metadata.name, config), - }; + const entityName = getCompoundEntityRef(entity); return ( diff --git a/plugins/techdocs/src/Router.tsx b/plugins/techdocs/src/Router.tsx index 40308e3379..1908e6cad0 100644 --- a/plugins/techdocs/src/Router.tsx +++ b/plugins/techdocs/src/Router.tsx @@ -15,13 +15,16 @@ */ import React, { PropsWithChildren } from 'react'; -import { Entity } from '@backstage/catalog-model'; -import { useEntity } from '@backstage/plugin-catalog-react'; import { Route, Routes } from 'react-router-dom'; + +import { Entity } from '@backstage/catalog-model'; +import { FlatRoutes } from '@backstage/core-app-api'; +import { useEntity } from '@backstage/plugin-catalog-react'; +import { MissingAnnotationEmptyState } from '@backstage/core-components'; + +import { EntityPageDocs } from './EntityPageDocs'; import { TechDocsIndexPage } from './home/components/TechDocsIndexPage'; import { TechDocsReaderPage } from './reader/components/TechDocsReaderPage'; -import { EntityPageDocs } from './EntityPageDocs'; -import { MissingAnnotationEmptyState } from '@backstage/core-components'; const TECHDOCS_ANNOTATION = 'backstage.io/techdocs-ref'; @@ -66,10 +69,10 @@ export const EmbeddedDocsRouter = (props: PropsWithChildren<{}>) => { } return ( - + }> {children} - + ); }; diff --git a/yarn.lock b/yarn.lock index 90e3ad3e7b..44d2cf05fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1524,6 +1524,22 @@ zen-observable "^0.8.15" zod "^3.11.6" +"@backstage/core-app-api@^1.0.0": + version "1.0.0" + resolved "https://registry.npmjs.org/@backstage/core-app-api/-/core-app-api-1.0.0.tgz#2dae97b050b2f2e5ec1ea42b3d95c57e8bf434d6" + integrity sha512-hmoFMPCxAfHgDPQTHbf6rquiG0SCSycWTUrScpYeLwkH3UOekgX8o8ThKT0t3w7WPx83LwT0NqcbSH6zqI9nag== + dependencies: + "@backstage/config" "^1.0.0" + "@backstage/core-plugin-api" "^1.0.0" + "@backstage/types" "^1.0.0" + "@backstage/version-bridge" "^1.0.0" + "@types/prop-types" "^15.7.3" + prop-types "^15.7.2" + react-router-dom "6.0.0-beta.0" + react-use "^17.2.4" + zen-observable "^0.8.15" + zod "^3.11.6" + "@backstage/core-components@^0.9.0", "@backstage/core-components@^0.9.1", "@backstage/core-components@^0.9.2": version "0.9.2" resolved "https://registry.npmjs.org/@backstage/core-components/-/core-components-0.9.2.tgz#9a3d79a15039256bbc007e5daa08c983050e0238" @@ -6555,18 +6571,6 @@ dependencies: "@types/node" "*" -"@types/lodash.debounce@^4.0.6": - version "4.0.6" - resolved "https://registry.npmjs.org/@types/lodash.debounce/-/lodash.debounce-4.0.6.tgz#c5a2326cd3efc46566c47e4c0aa248dc0ee57d60" - integrity sha512-4WTmnnhCfDvvuLMaF3KV4Qfki93KebocUF45msxhYyjMttZDQYzHkO639ohhk8+oco2cluAFL3t5+Jn4mleylQ== - dependencies: - "@types/lodash" "*" - -"@types/lodash@*": - version "4.14.180" - resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.180.tgz#4ab7c9ddfc92ec4a887886483bc14c79fb380670" - integrity sha512-XOKXa1KIxtNXgASAnwj7cnttJxS4fksBRywK/9LzRV5YxrF80BXZIGeQSuoESQ/VkUj30Ae0+YcuHc15wJCB2g== - "@types/lodash@^4.14.151", "@types/lodash@^4.14.173", "@types/lodash@^4.14.175": version "4.14.178" resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8" @@ -12459,9 +12463,9 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: "@backstage/plugin-tech-insights" "^0.1.14-next.0" "@backstage/plugin-tech-radar" "^0.5.11-next.1" "@backstage/plugin-techdocs" "^1.0.1-next.1" - "@backstage/plugin-techdocs-addons" "^0.0.0" "@backstage/plugin-todo" "^0.2.6-next.0" "@backstage/plugin-user-settings" "^0.4.3-next.0" + "@backstage/techdocs-addons" "^0.0.0" "@backstage/theme" "^0.2.15" "@material-ui/core" "^4.12.2" "@material-ui/icons" "^4.9.1" @@ -24106,11 +24110,6 @@ testcontainers@^8.1.2: ssh-remote-port-forward "^1.0.4" tar-fs "^2.1.1" -testing-library__dom@^7.29.4-beta.1: - version "7.29.4-beta.1" - resolved "https://registry.npmjs.org/testing-library__dom/-/testing-library__dom-7.29.4-beta.1.tgz#dc755f485837e923efbe12c1b7ae43b0ed326f96" - integrity sha512-vb/SMg8rXYcYYFY2eQ2n2a0p2VWNAseM4WHLfsckIyLwxRz5fYqKysUzUYpAX8SwRfruRK+tZqLuL4ND+D1s7Q== - text-extensions@^1.0.0: version "1.9.0" resolved "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz#1853e45fee39c945ce6f6c36b2d659b5aabc2a26"