-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
331 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
webui/react/src/components/RemainingRetentionDaysLabelComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Loadable } from 'hew/utils/loadable'; | ||
import React from 'react'; | ||
|
||
import { pluralizer } from 'utils/string'; | ||
|
||
import Badge from './Badge'; | ||
|
||
interface Props { | ||
remainingLogDays: Loadable<number | undefined>; | ||
} | ||
|
||
const RemainingRetentionDaysLabelComponent: React.FC<Props> = ({ remainingLogDays }: Props) => { | ||
let toolTipText = ''; | ||
let badgeText = ''; | ||
const days = Loadable.getOrElse(undefined, remainingLogDays); | ||
if (days === undefined) { | ||
toolTipText = 'Days remaining to retention are not available yet.'; | ||
badgeText = '-'; | ||
} else if (days === -1) { | ||
toolTipText = 'Logs will be retained forever.'; | ||
badgeText = 'Frvr'; | ||
} else if (days === 0) { | ||
toolTipText = 'Some logs have begun to be deleted for this trial.'; | ||
badgeText = '0'; | ||
} else { | ||
toolTipText = `${days} ${pluralizer(days, 'day')} left to retain logs`; | ||
badgeText = `${days}`; | ||
} | ||
return ( | ||
<div> | ||
<span>Logs </span> | ||
<Badge tooltip={toolTipText}>{badgeText}</Badge> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RemainingRetentionDaysLabelComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.