From dc4e1eaccd5301fc04f5c8d0abe4f79c14328050 Mon Sep 17 00:00:00 2001 From: rikimaru0345 Date: Wed, 10 Aug 2022 16:33:08 +0200 Subject: [PATCH] update time format in notifications --- frontend/src/components/App.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/App.tsx b/frontend/src/components/App.tsx index 275b8e852..3ef214bdc 100644 --- a/frontend/src/components/App.tsx +++ b/frontend/src/components/App.tsx @@ -362,6 +362,12 @@ class LicenseNotification extends Component { const withRemainingTime = api.licenses.map(x => { const remainingSec = x.expiresAt - unixNow; const remainingDays = remainingSec / (60 * 60 * 24); + + const expiredForMoreThanAYear = (remainingSec < 0 && remainingDays < -365); + const prettyDuration = expiredForMoreThanAYear + ? 'over a year' + : prettyMilliseconds(Math.abs(remainingSec) * 1000, { unitCount: 2, verbose: true, secondsDecimalDigits: 0 }); + return { ...x, remainingSec, @@ -370,7 +376,7 @@ class LicenseNotification extends Component { isExpired: remainingSec <= 0, sourceDisplayName: sourceNames[x.source] ?? x.source, typeDisplayName: typeNames[x.type] ?? x.type, - prettyDuration: prettyMilliseconds(remainingSec * 1000, { unitCount: 2, verbose: true }), + prettyDuration, prettyDateTime: new Date(x.expiresAt * 1000).toLocaleDateString(), }; }); @@ -383,7 +389,7 @@ class LicenseNotification extends Component { {warnings.map(e =>
- Your Redpanda Enterprise license ({e.sourceDisplayName})   + Your Redpanda Enterprise license ({e.sourceDisplayName}) {e.isExpired ? <> has expired {e.prettyDateTime} ({e.prettyDuration} ago) : <> will expire {e.prettyDateTime} ({e.prettyDuration} remaining)