rename retry to refresh

Signed-off-by: Yousif Al-Raheem <yousifalraheem@gmail.com>
This commit is contained in:
Yousif Al-Raheem
2021-07-22 11:24:36 +02:00
parent a750cdce43
commit 3891efb000
3 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -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
+6 -6
View File
@@ -25,14 +25,14 @@ type EntityLoadingStatus = {
entity?: Entity;
loading: boolean;
error?: Error;
retry?: VoidFunction;
refresh?: VoidFunction;
};
export const EntityContext = createContext<EntityLoadingStatus>({
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<T extends Entity = Entity>() {
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 };
}
@@ -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 (
<EntityContext.Provider value={{ entity, loading, error, retry }}>
<EntityContext.Provider value={{ entity, loading, error, refresh }}>
{children}
</EntityContext.Provider>
);