Skip to content

Commit 05f7d88

Browse files
Merge pull request #624 from falox/fix-incidents
NO-JIRA: Display incidents' last update time
2 parents 5517668 + 176a294 commit 05f7d88

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

web/src/components/Incidents/AlertsChart/AlertsChart.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ import {
1212
import {
1313
Card,
1414
CardBody,
15+
CardHeader,
1516
CardTitle,
1617
EmptyState,
1718
EmptyStateBody,
19+
Flex,
20+
FlexItem,
1821
getResizeObserver,
1922
} from '@patternfly/react-core';
2023
import {
@@ -30,7 +33,7 @@ import {
3033
generateAlertsDateArray,
3134
getCurrentTime,
3235
} from '../utils';
33-
import { dateTimeFormatter } from '../../console/utils/datetime';
36+
import { dateTimeFormatter, timeFormatter } from '../../console/utils/datetime';
3437
import { useTranslation } from 'react-i18next';
3538
import { AlertsChartBar } from '../model';
3639
import { setAlertsAreLoading } from '../../../store/actions';
@@ -114,7 +117,22 @@ const AlertsChart = ({ theme }: { theme: 'light' | 'dark' }) => {
114117
data-test={DataTestIDs.AlertsChart.Card}
115118
>
116119
<div ref={containerRef} data-test={DataTestIDs.AlertsChart.ChartContainer}>
117-
<CardTitle data-test={DataTestIDs.AlertsChart.Title}>{t('Alerts Timeline')}</CardTitle>
120+
<CardHeader>
121+
<Flex spaceItems={{ default: 'spaceItemsMd' }}>
122+
<FlexItem>
123+
<CardTitle data-test={DataTestIDs.AlertsChart.Title}>
124+
{t('Alerts Timeline')}
125+
</CardTitle>
126+
</FlexItem>
127+
{incidentsLastRefreshTime && (
128+
<FlexItem>
129+
<span className="pf-v6-u-text-color-subtle">
130+
{t('Last updated at')} {timeFormatter.format(new Date(incidentsLastRefreshTime))}
131+
</span>
132+
</FlexItem>
133+
)}
134+
</Flex>
135+
</CardHeader>
118136
{!selectedIncidentIsVisible || isEmpty(incidentsActiveFilters.groupId) ? (
119137
<EmptyState
120138
variant="lg"

web/src/components/Incidents/IncidentsChart/IncidentsChart.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import {
1414
Bullseye,
1515
Card,
1616
CardBody,
17+
CardHeader,
1718
CardTitle,
19+
Flex,
20+
FlexItem,
1821
getResizeObserver,
1922
Spinner,
2023
} from '@patternfly/react-core';
@@ -31,7 +34,7 @@ import {
3134
createIncidentsChartBars,
3235
generateDateArray,
3336
} from '../utils';
34-
import { dateTimeFormatter } from '../../console/utils/datetime';
37+
import { dateTimeFormatter, timeFormatter } from '../../console/utils/datetime';
3538
import { useTranslation } from 'react-i18next';
3639
import { DataTestIDs } from '../../data-test';
3740

@@ -58,13 +61,15 @@ const IncidentsChart = ({
5861
selectedGroupId,
5962
onIncidentClick,
6063
currentTime,
64+
lastRefreshTime,
6165
}: {
6266
incidentsData: Array<Incident>;
6367
chartDays: number;
6468
theme: 'light' | 'dark';
6569
selectedGroupId: string;
6670
onIncidentClick: (groupId: string) => void;
6771
currentTime: number;
72+
lastRefreshTime: number | null;
6873
}) => {
6974
const [isLoading, setIsLoading] = useState(true);
7075
const [chartContainerHeight, setChartContainerHeight] = useState<number>();
@@ -131,9 +136,22 @@ const IncidentsChart = ({
131136
style={{ position: 'relative' }}
132137
data-test={DataTestIDs.IncidentsChart.ChartContainer}
133138
>
134-
<CardTitle data-test={DataTestIDs.IncidentsChart.Title}>
135-
{t('Incidents Timeline')}
136-
</CardTitle>
139+
<CardHeader>
140+
<Flex spaceItems={{ default: 'spaceItemsMd' }}>
141+
<FlexItem>
142+
<CardTitle data-test={DataTestIDs.IncidentsChart.Title}>
143+
{t('Incidents Timeline')}
144+
</CardTitle>
145+
</FlexItem>
146+
{lastRefreshTime && (
147+
<FlexItem>
148+
<span className="pf-v6-u-text-color-subtle">
149+
{t('Last updated at')} {timeFormatter.format(new Date(lastRefreshTime))}
150+
</span>
151+
</FlexItem>
152+
)}
153+
</Flex>
154+
</CardHeader>
137155
{isLoading ? (
138156
<Bullseye>
139157
<Spinner

web/src/components/Incidents/IncidentsPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ const IncidentsPage = () => {
609609
selectedGroupId={selectedGroupId}
610610
onIncidentClick={handleIncidentChartClick}
611611
currentTime={incidentsLastRefreshTime}
612+
lastRefreshTime={incidentsLastRefreshTime}
612613
/>
613614
</StackItem>
614615
<StackItem>

0 commit comments

Comments
 (0)