diff --git a/.changeset/early-socks-beg.md b/.changeset/early-socks-beg.md index 33265fe8f1..915ca8f63a 100644 --- a/.changeset/early-socks-beg.md +++ b/.changeset/early-socks-beg.md @@ -1,6 +1,6 @@ --- -'@backstage/plugin-catalog': minor -'@backstage/plugin-catalog-react': minor +'@backstage/plugin-catalog': patch +'@backstage/plugin-catalog-react': patch --- added retry callback to useEntity hook diff --git a/plugins/catalog-react/src/hooks/useEntity.ts b/plugins/catalog-react/src/hooks/useEntity.ts index a83e573753..6fe25fb115 100644 --- a/plugins/catalog-react/src/hooks/useEntity.ts +++ b/plugins/catalog-react/src/hooks/useEntity.ts @@ -25,14 +25,14 @@ type EntityLoadingStatus = { entity?: Entity; loading: boolean; error?: Error; - retry?: VoidFunction; + refresh?: VoidFunction; }; export const EntityContext = createContext({ entity: undefined, loading: true, error: undefined, - retry: () => {}, + refresh: () => {}, }); export const useEntityFromUrl = (): EntityLoadingStatus => { @@ -41,7 +41,7 @@ export const useEntityFromUrl = (): EntityLoadingStatus => { const errorApi = useApi(errorApiRef); const catalogApi = useApi(catalogApiRef); - const { value: entity, error, loading, retry } = useAsyncRetry( + const { value: entity, error, loading, retry: refresh } = useAsyncRetry( () => catalogApi.getEntityByName({ kind, namespace, name }), [catalogApi, kind, namespace, name], ); @@ -53,13 +53,13 @@ export const useEntityFromUrl = (): EntityLoadingStatus => { } }, [errorApi, navigate, error, loading, entity, name]); - return { entity, loading, error, retry }; + return { entity, loading, error, refresh }; }; /** * Grab the current entity from the context and its current loading state. */ export function useEntity() { - const { entity, loading, error, retry } = useContext(EntityContext); - return { entity: entity as T, loading, error, retry }; + const { entity, loading, error, refresh } = useContext(EntityContext); + return { entity: entity as T, loading, error, refresh }; } diff --git a/plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx b/plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx index 20828b390b..8d2feae7da 100644 --- a/plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx +++ b/plugins/catalog/src/components/EntityLoaderProvider/EntityLoaderProvider.tsx @@ -20,10 +20,10 @@ import { import React, { ReactNode } from 'react'; export const EntityLoaderProvider = ({ children }: { children: ReactNode }) => { - const { entity, loading, error, retry } = useEntityFromUrl(); + const { entity, loading, error, refresh } = useEntityFromUrl(); return ( - + {children} );