Fleet UI: Update software updated time tooltip (#20029)

This commit is contained in:
RachelElysia
2024-06-27 09:41:35 -04:00
committed by GitHub
parent 3c02ac1278
commit 7173727f22
5 changed files with 46 additions and 14 deletions
+1
View File
@@ -0,0 +1 @@
* Update software updated timestamp tooltip
@@ -6,14 +6,27 @@ import TooltipWrapper from "components/TooltipWrapper";
const baseClass = "component__last-updated-text";
interface ILastUpdatedTextProps {
interface ILastUpdatedTextBase {
lastUpdatedAt?: string;
}
interface ILastUpdatedTextWithCustomTooltip extends ILastUpdatedTextBase {
customTooltipText: React.ReactNode;
whatToRetrieve?: never;
}
interface ILastUpdatedTextWithWhatToRetrieve extends ILastUpdatedTextBase {
customTooltipText?: never;
whatToRetrieve: string;
}
const LastUpdatedText = ({
lastUpdatedAt,
whatToRetrieve,
}: ILastUpdatedTextProps): JSX.Element => {
customTooltipText,
}:
| ILastUpdatedTextWithCustomTooltip
| ILastUpdatedTextWithWhatToRetrieve): JSX.Element => {
if (!lastUpdatedAt || lastUpdatedAt === "0001-01-01T00:00:00Z") {
lastUpdatedAt = "never";
} else {
@@ -24,16 +37,16 @@ const LastUpdatedText = ({
);
}
const tooltipContent = customTooltipText || (
<>
Fleet periodically queries all hosts <br />
to retrieve {whatToRetrieve}.
</>
);
return (
<span className={baseClass}>
<TooltipWrapper
tipContent={
<>
Fleet periodically queries all hosts <br />
to retrieve {whatToRetrieve}.
</>
}
>
<TooltipWrapper tipContent={tooltipContent}>
{`Updated ${lastUpdatedAt}`}
</TooltipWrapper>
</span>
@@ -1,6 +1,6 @@
/** software/os OS tab > Table */
import React, { useCallback, useContext, useMemo } from "react";
import React, { useCallback, useMemo } from "react";
import { InjectedRouter } from "react-router";
import { Row } from "react-table";
@@ -137,7 +137,13 @@ const SoftwareOSTable = ({
{data?.os_versions && data?.counts_updated_at && (
<LastUpdatedText
lastUpdatedAt={data.counts_updated_at}
whatToRetrieve="vulnerabilities"
customTooltipText={
<>
The last time software data was <br />
updated, including vulnerabilities <br />
and host counts.
</>
}
/>
)}
</>
@@ -270,7 +270,13 @@ const SoftwareTable = ({
{tableData && data?.counts_updated_at && (
<LastUpdatedText
lastUpdatedAt={data.counts_updated_at}
whatToRetrieve="software"
customTooltipText={
<>
The last time software data was <br />
updated, including vulnerabilities <br />
and host counts.
</>
}
/>
)}
</>
@@ -189,7 +189,13 @@ const SoftwareVulnerabilitiesTable = ({
{data?.vulnerabilities && data?.counts_updated_at && (
<LastUpdatedText
lastUpdatedAt={data.counts_updated_at}
whatToRetrieve="vulnerabilities"
customTooltipText={
<>
The last time software data was <br />
updated, including vulnerabilities <br />
and host counts.
</>
}
/>
)}
</>