mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-17 16:51:45 +01:00
* Add filter for auth mounts on history tab * Fix normalizeResponse if enabled not a key on data * Add auth filter to current tab, update clear filter behavior * Fix failing tests
24 lines
751 B
JavaScript
24 lines
751 B
JavaScript
import { helper } from '@ember/component/helper';
|
|
|
|
export default helper(function formatTtl([timestring], { removeZero = false }) {
|
|
// Expects a number followed by one of s, m, or h
|
|
// eg. 40m or 1h20m0s
|
|
if (!timestring) return timestring;
|
|
let matches = timestring?.match(/([0-9]+[h|m|s])/g);
|
|
if (!matches) {
|
|
return timestring;
|
|
}
|
|
return matches
|
|
.map((set) => {
|
|
// eslint-disable-next-line no-unused-vars
|
|
let [_, number, unit] = set.match(/([0-9]+)(h|m|s)/);
|
|
if (removeZero && number === '0') {
|
|
return null;
|
|
}
|
|
const word = { h: 'hour', m: 'minute', s: 'second' }[unit];
|
|
return `${number} ${number === '1' ? word : word + 's'}`;
|
|
})
|
|
.filter((s) => null !== s)
|
|
.join(' ');
|
|
});
|