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:
Jacob Wejendorp
2021-12-16 14:52:03 +01:00
parent c88d8339a3
commit cf7fc2b41a
@@ -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,