Skip to content

Commit

Permalink
update time format in notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
rikimaru0345 committed Aug 10, 2022
1 parent efab801 commit dc4e1ea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(),
};
});
Expand All @@ -383,7 +389,7 @@ class LicenseNotification extends Component {
{warnings.map(e =>
<div key={e.source}>
<div>
Your Redpanda Enterprise license (<span className="source">{e.sourceDisplayName}</span>) &nbsp;
Your Redpanda Enterprise license (<span className="source">{e.sourceDisplayName}</span>)
{e.isExpired
? <> has expired <span className="date">{e.prettyDateTime}</span> ({e.prettyDuration} ago)</>
: <> will expire <span className="date">{e.prettyDateTime}</span> ({e.prettyDuration} remaining)</>
Expand Down

0 comments on commit dc4e1ea

Please sign in to comment.