mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
38 lines
1,001 B
TypeScript
38 lines
1,001 B
TypeScript
import React from "react";
|
|
import formatDistanceToNowStrict from "date-fns/formatDistanceToNowStrict";
|
|
import { abbreviateTimeUnits } from "utilities/helpers";
|
|
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
|
|
|
const baseClass = "component__last-updated-text";
|
|
|
|
interface ILastUpdatedTextProps {
|
|
lastUpdatedAt: string;
|
|
whatToRetrieve: string;
|
|
}
|
|
const LastUpdatedText = ({
|
|
lastUpdatedAt,
|
|
whatToRetrieve,
|
|
}: ILastUpdatedTextProps): JSX.Element => {
|
|
if (!lastUpdatedAt || lastUpdatedAt === "0001-01-01T00:00:00Z") {
|
|
lastUpdatedAt = "never";
|
|
} else {
|
|
lastUpdatedAt = abbreviateTimeUnits(
|
|
formatDistanceToNowStrict(new Date(lastUpdatedAt), {
|
|
addSuffix: true,
|
|
})
|
|
);
|
|
}
|
|
|
|
return (
|
|
<span className={baseClass}>
|
|
<TooltipWrapper
|
|
tipContent={`Fleet periodically queries all hosts <br />to retrieve ${whatToRetrieve}.`}
|
|
>
|
|
{`Updated ${lastUpdatedAt}`}
|
|
</TooltipWrapper>
|
|
</span>
|
|
);
|
|
};
|
|
|
|
export default LastUpdatedText;
|