Skip to content

Commit 717c042

Browse files
cursoragentdobrac
andcommitted
fix status priority
Co-authored-by: Jakub Dobry <dobrac@users.noreply.github.com>
1 parent 60bcfee commit 717c042

2 files changed

Lines changed: 47 additions & 7 deletions

File tree

src/features/dashboard/layouts/status-indicator.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,32 @@ function hasMaintenanceInProgress(
4949
maintenances: IncidentIOStatusPageSummaryResponse['scheduled_maintenances']
5050
) {
5151
return maintenances?.some(
52-
(maintenance) => maintenance.status === 'maintenance_in_progress'
52+
(maintenance) =>
53+
maintenance.status === 'in_progress' ||
54+
maintenance.status === 'maintenance_in_progress'
5355
)
5456
}
5557

5658
export function getStatusPageStateFromSummary(
5759
data: IncidentIOStatusPageSummaryResponse
5860
): AggregateState {
59-
if (hasMaintenanceInProgress(data.scheduled_maintenances))
60-
return 'maintenance'
61+
const indicatorState = stateFromIndicator(data.status?.indicator)
62+
const componentState = getWorstComponentState(data.components)
63+
64+
if (indicatorState === 'downtime' || componentState === 'downtime')
65+
return 'downtime'
66+
67+
if (indicatorState === 'degraded' || componentState === 'degraded')
68+
return 'degraded'
6169

62-
return (
63-
stateFromIndicator(data.status?.indicator) ??
64-
getWorstComponentState(data.components) ??
65-
'unknown'
70+
if (
71+
indicatorState === 'maintenance' ||
72+
componentState === 'maintenance' ||
73+
hasMaintenanceInProgress(data.scheduled_maintenances)
6674
)
75+
return 'maintenance'
76+
77+
if (indicatorState === 'operational') return 'operational'
78+
79+
return 'unknown'
6780
}

tests/unit/status-indicator.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ describe('status-indicator', () => {
1313
})
1414

1515
it('should report maintenance for in-progress maintenance', () => {
16+
expect(
17+
getStatusPageStateFromSummary({
18+
scheduled_maintenances: [
19+
{
20+
status: 'in_progress',
21+
},
22+
],
23+
})
24+
).toBe('maintenance')
25+
})
26+
27+
it('should support incident.io maintenance status naming', () => {
1628
expect(
1729
getStatusPageStateFromSummary({
1830
scheduled_maintenances: [
@@ -24,6 +36,21 @@ describe('status-indicator', () => {
2436
).toBe('maintenance')
2537
})
2638

39+
it('should prioritize critical indicator over maintenance', () => {
40+
expect(
41+
getStatusPageStateFromSummary({
42+
status: {
43+
indicator: 'critical',
44+
},
45+
scheduled_maintenances: [
46+
{
47+
status: 'in_progress',
48+
},
49+
],
50+
})
51+
).toBe('downtime')
52+
})
53+
2754
it('should report downtime for critical summary indicator', () => {
2855
expect(
2956
getStatusPageStateFromSummary({

0 commit comments

Comments
 (0)