diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index da23d54ad7..907dad973b 100644 --- a/plugins/catalog-react/src/hooks/index.ts +++ b/plugins/catalog-react/src/hooks/index.ts @@ -25,7 +25,6 @@ export type { EntityProviderProps, AsyncEntityProviderProps, } from './useEntity'; -export { useEntityCompoundName } from './useEntityCompoundName'; export { EntityListContext, EntityListProvider, diff --git a/plugins/catalog-react/src/hooks/useEntity.tsx b/plugins/catalog-react/src/hooks/useEntity.tsx index f80f858dec..152c1ebe61 100644 --- a/plugins/catalog-react/src/hooks/useEntity.tsx +++ b/plugins/catalog-react/src/hooks/useEntity.tsx @@ -14,7 +14,11 @@ * limitations under the License. */ import { Entity } from '@backstage/catalog-model'; -import { errorApiRef, useApi } from '@backstage/core-plugin-api'; +import { + errorApiRef, + useApi, + useRouteRefParams, +} from '@backstage/core-plugin-api'; import { createVersionedContext, createVersionedValueMap, @@ -24,7 +28,7 @@ import React, { ReactNode, useEffect } from 'react'; import { useNavigate } from 'react-router'; import useAsyncRetry from 'react-use/lib/useAsyncRetry'; import { catalogApiRef } from '../api'; -import { useEntityCompoundName } from './useEntityCompoundName'; +import { entityRouteRef } from '../routes'; /** @public */ export type EntityLoadingStatus = { @@ -104,7 +108,7 @@ export const EntityProvider = ({ entity, children }: EntityProviderProps) => ( * @deprecated will be deleted shortly due to low external usage, re-implement if needed. */ export const useEntityFromUrl = (): EntityLoadingStatus => { - const { kind, namespace, name } = useEntityCompoundName(); + const { kind, namespace, name } = useRouteRefParams(entityRouteRef); const navigate = useNavigate(); const errorApi = useApi(errorApiRef); const catalogApi = useApi(catalogApiRef); diff --git a/plugins/catalog-react/src/hooks/useEntityCompoundName.ts b/plugins/catalog-react/src/hooks/useEntityCompoundName.ts deleted file mode 100644 index 481c18f8a0..0000000000 --- a/plugins/catalog-react/src/hooks/useEntityCompoundName.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { entityRouteRef } from '../routes'; -import { useRouteRefParams } from '@backstage/core-plugin-api'; - -/** - * Grabs entity kind, namespace, and name from the location - * @public - * @deprecated use {@link @backstage/core-plugin-api#useRouteRefParams} instead - */ -export const useEntityCompoundName = () => { - const { kind, namespace, name } = useRouteRefParams(entityRouteRef); - return { kind, namespace, name }; -}; diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx index 40c4f9e873..d4244419cb 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx @@ -33,15 +33,16 @@ import { attachComponentData, IconComponent, useElementFilter, + useRouteRefParams, } from '@backstage/core-plugin-api'; import { EntityRefLinks, + entityRouteRef, FavoriteEntity, getEntityRelations, InspectEntityDialog, UnregisterEntityDialog, useAsyncEntity, - useEntityCompoundName, } from '@backstage/plugin-catalog-react'; import { Box, TabProps } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; @@ -176,7 +177,7 @@ export const EntityLayout = (props: EntityLayoutProps) => { UNSTABLE_contextMenuOptions, children, } = props; - const { kind, namespace, name } = useEntityCompoundName(); + const { kind, namespace, name } = useRouteRefParams(entityRouteRef); const { entity, loading, error } = useAsyncEntity(); const location = useLocation(); const routes = useElementFilter( diff --git a/plugins/rollbar/src/hooks/useCatalogEntity.ts b/plugins/rollbar/src/hooks/useCatalogEntity.ts index 21d22dd13c..4845a275be 100644 --- a/plugins/rollbar/src/hooks/useCatalogEntity.ts +++ b/plugins/rollbar/src/hooks/useCatalogEntity.ts @@ -14,16 +14,13 @@ * limitations under the License. */ -import { - catalogApiRef, - useEntityCompoundName, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react'; import useAsync from 'react-use/lib/useAsync'; -import { useApi } from '@backstage/core-plugin-api'; +import { useApi, useRouteRefParams } from '@backstage/core-plugin-api'; export function useCatalogEntity() { const catalogApi = useApi(catalogApiRef); - const { namespace, name } = useEntityCompoundName(); + const { namespace, name } = useRouteRefParams(entityRouteRef); const { value: entity,