fix: handle empty checks in tech-insights scorecard
Show a warning about missing data instead of crashing if checks return empty. Signed-off-by: Jacob Wejendorp <jwe@tradeshift.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import { Content, Page, InfoCard } from '@backstage/core-components';
|
||||
import { CheckResult } from '@backstage/plugin-tech-insights-common';
|
||||
import { techInsightsApiRef } from '../../api/TechInsightsApi';
|
||||
import { BackstageTheme } from '@backstage/theme';
|
||||
import { Alert } from '@material-ui/lab';
|
||||
|
||||
const useStyles = makeStyles((theme: BackstageTheme) => ({
|
||||
contentScorecards: {
|
||||
@@ -40,6 +41,9 @@ type Checks = {
|
||||
export const ChecksOverview = ({ checks }: Checks) => {
|
||||
const classes = useStyles();
|
||||
const api = useApi(techInsightsApiRef);
|
||||
if (!checks.length) {
|
||||
return <Alert severity="warning">No checks have any data yet.</Alert>;
|
||||
}
|
||||
const checkRenderType = api.getScorecardsDefinition(
|
||||
checks[0].check.type,
|
||||
checks,
|
||||
|
||||
Reference in New Issue
Block a user