fix: fix edge case of sonarqube plugin if no quality gate was computed

Initially no quality gate is available, till the first analysis. Previously this was handled as "failed". Now it has its own state.
This commit is contained in:
Oliver Sand
2020-11-02 19:20:23 +01:00
parent b22c4ac14c
commit 3cbebc9c13
@@ -51,6 +51,9 @@ const useStyles = makeStyles(theme => ({
margin: 0,
backgroundColor: theme.palette.success.main,
},
badgeUnknown: {
backgroundColor: theme.palette.grey[500],
},
header: {
padding: theme.spacing(2, 2, 2, 2.5),
},
@@ -104,17 +107,20 @@ export const SonarQubeCard = ({
}
: undefined;
const gatePassed = value && value.metrics.alert_status === 'OK';
const classes = useStyles();
let gateLabel = 'Not computed';
let gateColor = classes.badgeUnknown;
if (value?.metrics.alert_status) {
const gatePassed = value.metrics.alert_status === 'OK';
gateLabel = gatePassed ? 'Gate passed' : 'Gate failed';
gateColor = gatePassed ? classes.badgeSuccess : classes.badgeError;
}
const qualityBadge = !loading && value && (
<Chip
label={gatePassed ? 'Gate Passed' : 'Gate Failed'}
classes={{
root: gatePassed ? classes.badgeSuccess : classes.badgeError,
label: classes.badgeLabel,
}}
label={gateLabel}
classes={{ root: gateColor, label: classes.badgeLabel }}
/>
);