Alerting: misc rule list fixes (#34400)

* misc rule table fixes

* rule stats for all rules

* inactive -> normal

* always show tooltip for rule error
This commit is contained in:
Domas
2021-05-19 18:54:03 +03:00
committed by GitHub
parent 22043d7872
commit eaf964a827
12 changed files with 320 additions and 90 deletions
@@ -12,10 +12,18 @@ const durationMap: { [key in Required<keyof Duration>]: string[] } = {
seconds: ['s', 'S', 'seconds'],
};
export function intervalToAbbreviatedDurationString(interval: Interval): string {
/**
* intervalToAbbreviatedDurationString convers interval to readable duration string
*
* @param interval - interval to convert
* @param includeSeconds - optional, default true. If false, will not include seconds unless interval is less than 1 minute
*
* @public
*/
export function intervalToAbbreviatedDurationString(interval: Interval, includeSeconds = true): string {
const duration = intervalToDuration(interval);
return (Object.entries(duration) as Array<[keyof Duration, number | undefined]>).reduce((str, [unit, value]) => {
if (value && value !== 0) {
if (value && value !== 0 && !(unit === 'seconds' && !includeSeconds && str)) {
const padding = str !== '' ? ' ' : '';
return str + `${padding}${value}${durationMap[unit][0]}`;
}