mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 14:27:27 -08:00
Fix inconsistent display of word 'ago' on rules page (#8566)
* Fix inconsistent display of word 'ago' in last evaluation column on rules page Signed-off-by: Alex Petrov <alex.petrov.vt@gmail.com> * Extract adding word 'ago' to relativeDuration util function Signed-off-by: Alex Petrov <alex.petrov.vt@gmail.com>
This commit is contained in:
parent
8d2a8f4939
commit
4f03df8c55
|
@ -65,7 +65,7 @@ export const RulesContent: FC<RouteComponentProps & RulesContentProps> = ({ resp
|
|||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<h2>{formatRelative(g.lastEvaluation, now())} ago</h2>
|
||||
<h2>{formatRelative(g.lastEvaluation, now())}</h2>
|
||||
</td>
|
||||
<td>
|
||||
<h2>{humanizeDuration(parseFloat(g.evaluationTime) * 1000)}</h2>
|
||||
|
@ -120,7 +120,7 @@ export const RulesContent: FC<RouteComponentProps & RulesContentProps> = ({ resp
|
|||
<Badge color={getBadgeColor(r.health)}>{r.health.toUpperCase()}</Badge>
|
||||
</td>
|
||||
<td>{r.lastError ? <Alert color="danger">{r.lastError}</Alert> : null}</td>
|
||||
<td>{formatRelative(r.lastEvaluation, now())} ago</td>
|
||||
<td>{formatRelative(r.lastEvaluation, now())}</td>
|
||||
<td>{humanizeDuration(parseFloat(r.evaluationTime) * 1000)}</td>
|
||||
</tr>
|
||||
);
|
||||
|
|
|
@ -155,7 +155,7 @@ export const formatRelative = (startStr: string, end: number): string => {
|
|||
if (start < 0) {
|
||||
return 'Never';
|
||||
}
|
||||
return humanizeDuration(end - start);
|
||||
return humanizeDuration(end - start) + ' ago';
|
||||
};
|
||||
|
||||
const paramFormat = /^g\d+\..+=.+$/;
|
||||
|
|
|
@ -192,10 +192,10 @@ describe('Utils', () => {
|
|||
});
|
||||
it('renders a humanized duration for sane durations', () => {
|
||||
expect(formatRelative('2019-11-04T09:15:29.578701-07:00', parseTime('2019-11-04T09:15:35.8701-07:00'))).toEqual(
|
||||
'6.292s'
|
||||
'6.292s ago'
|
||||
);
|
||||
expect(formatRelative('2019-11-04T09:15:35.8701-07:00', parseTime('2019-11-04T09:15:29.578701-07:00'))).toEqual(
|
||||
'-6.292s'
|
||||
'-6.292s ago'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue