Merge pull request #14920 from RoadieHQ/handle-about-card-error
Handle about card error
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog': patch
|
||||
---
|
||||
|
||||
Handle refresh entity error in `AboutCard`.
|
||||
@@ -26,7 +26,12 @@ import {
|
||||
InfoCardVariants,
|
||||
Link,
|
||||
} from '@backstage/core-components';
|
||||
import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
|
||||
import {
|
||||
alertApiRef,
|
||||
errorApiRef,
|
||||
useApi,
|
||||
useRouteRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import {
|
||||
ScmIntegrationIcon,
|
||||
scmIntegrationsApiRef,
|
||||
@@ -90,6 +95,7 @@ export function AboutCard(props: AboutCardProps) {
|
||||
const scmIntegrationsApi = useApi(scmIntegrationsApiRef);
|
||||
const catalogApi = useApi(catalogApiRef);
|
||||
const alertApi = useApi(alertApiRef);
|
||||
const errorApi = useApi(errorApiRef);
|
||||
const viewTechdocLink = useRouteRef(viewTechDocRouteRef);
|
||||
|
||||
const entitySourceLocation = getEntitySourceLocation(
|
||||
@@ -139,9 +145,13 @@ export function AboutCard(props: AboutCardProps) {
|
||||
const allowRefresh =
|
||||
entityLocation?.startsWith('url:') || entityLocation?.startsWith('file:');
|
||||
const refreshEntity = useCallback(async () => {
|
||||
await catalogApi.refreshEntity(stringifyEntityRef(entity));
|
||||
alertApi.post({ message: 'Refresh scheduled', severity: 'info' });
|
||||
}, [catalogApi, alertApi, entity]);
|
||||
try {
|
||||
await catalogApi.refreshEntity(stringifyEntityRef(entity));
|
||||
alertApi.post({ message: 'Refresh scheduled', severity: 'info' });
|
||||
} catch (e) {
|
||||
errorApi.post(e);
|
||||
}
|
||||
}, [catalogApi, alertApi, errorApi, entity]);
|
||||
|
||||
return (
|
||||
<Card className={cardClass}>
|
||||
|
||||
Reference in New Issue
Block a user