From ecd571237f04b676f2877b55c9f67d8fe81f362d Mon Sep 17 00:00:00 2001 From: Prasetya Aria Wibawa Date: Fri, 20 Aug 2021 09:53:04 +0700 Subject: [PATCH] use catalogRouteRef to generate url path Signed-off-by: Prasetya Aria Wibawa --- .../components/Cards/OwnershipCard/OwnershipCard.test.tsx | 6 ++++++ .../src/components/Cards/OwnershipCard/OwnershipCard.tsx | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index 4bf6d2007a..eab3606f77 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -19,6 +19,7 @@ import { CatalogApi, catalogApiRef, EntityProvider, + catalogRouteRef, } from '@backstage/plugin-catalog-react'; import { renderInTestApp } from '@backstage/test-utils'; import { queryByText } from '@testing-library/react'; @@ -123,6 +124,11 @@ describe('OwnershipCard', () => { , + { + mountedRoutes: { + '/create': catalogRouteRef, + }, + }, ); expect(getByText('OPENAPI')).toBeInTheDocument(); diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx index 2c7e1db2eb..00e20bb709 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx @@ -19,6 +19,7 @@ import { catalogApiRef, isOwnerOf, useEntity, + catalogRouteRef, } from '@backstage/plugin-catalog-react'; import { BackstageTheme, genPageTheme } from '@backstage/theme'; import { @@ -39,7 +40,7 @@ import { Progress, ResponseErrorPanel, } from '@backstage/core-components'; -import { useApi } from '@backstage/core-plugin-api'; +import { useApi, useRouteRef } from '@backstage/core-plugin-api'; type EntityTypeProps = { name: string; @@ -93,10 +94,11 @@ const EntityCountTile = ({ queryParams: string; }) => { const classes = useStyles({ type }); + const catalogLink = useRouteRef(catalogRouteRef); return (