use catalogRouteRef to generate url path
Signed-off-by: Prasetya Aria Wibawa <prasetya.wibawa@grabtaxi.com>
This commit is contained in:
@@ -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', () => {
|
||||
<OwnershipCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/create': catalogRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('OPENAPI')).toBeInTheDocument();
|
||||
|
||||
@@ -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 (
|
||||
<Link
|
||||
href={generatePath(`/catalog/?${queryParams}`)}
|
||||
href={generatePath(`${catalogLink()}/?${queryParams}`)}
|
||||
target="_blank"
|
||||
rel="noreferrer noopenner"
|
||||
variant="body2"
|
||||
|
||||
Reference in New Issue
Block a user