|
@@ -25,7 +25,7 @@ type Props = AsyncComponent['props'] &
|
|
|
};
|
|
|
|
|
|
type State = AsyncComponent['state'] & {
|
|
|
- ruleFireHistory: ProjectAlertRuleStats[];
|
|
|
+ ruleFireHistory: ProjectAlertRuleStats[] | null;
|
|
|
};
|
|
|
|
|
|
class AlertChart extends AsyncComponent<Props, State> {
|
|
@@ -76,10 +76,11 @@ class AlertChart extends AsyncComponent<Props, State> {
|
|
|
|
|
|
const series = {
|
|
|
seriesName: 'Alerts Triggered',
|
|
|
- data: ruleFireHistory.map(alert => ({
|
|
|
- name: alert.date,
|
|
|
- value: alert.count,
|
|
|
- })),
|
|
|
+ data:
|
|
|
+ ruleFireHistory?.map(alert => ({
|
|
|
+ name: alert.date,
|
|
|
+ value: alert.count,
|
|
|
+ })) ?? [],
|
|
|
emphasis: {
|
|
|
disabled: true,
|
|
|
},
|
|
@@ -128,10 +129,8 @@ class AlertChart extends AsyncComponent<Props, State> {
|
|
|
render() {
|
|
|
const {ruleFireHistory, loading} = this.state;
|
|
|
|
|
|
- const totalAlertsTriggered = ruleFireHistory.reduce(
|
|
|
- (acc, curr) => acc + curr.count,
|
|
|
- 0
|
|
|
- );
|
|
|
+ const totalAlertsTriggered =
|
|
|
+ ruleFireHistory?.reduce((acc, curr) => acc + curr.count, 0) ?? 0;
|
|
|
|
|
|
return loading ? (
|
|
|
this.renderEmpty()
|