From 8dc2076a701073daecf12bccd7fc863ffab0193e Mon Sep 17 00:00:00 2001 From: Jacob Shandling <61553566+jacobshandling@users.noreply.github.com> Date: Wed, 15 Nov 2023 12:59:36 -0800 Subject: [PATCH] =?UTF-8?q?TooltipWrapper=20tipContent=20=E2=80=93=20strin?= =?UTF-8?q?gs=20=E2=80=93>=20JSX;=20small=20reorganization=20(#15126)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Update some missed TooltipWrapper content from string to JSX, reorganize some code --------- Co-authored-by: Jacob Shandling --- .../details/cards/HostSummary/HostSummary.tsx | 48 +++++++++++++++++-- frontend/utilities/helpers.tsx | 31 ------------ 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/frontend/pages/hosts/details/cards/HostSummary/HostSummary.tsx b/frontend/pages/hosts/details/cards/HostSummary/HostSummary.tsx index a39ad9a23b..6c3cb957ca 100644 --- a/frontend/pages/hosts/details/cards/HostSummary/HostSummary.tsx +++ b/frontend/pages/hosts/details/cards/HostSummary/HostSummary.tsx @@ -15,11 +15,7 @@ import Icon from "components/Icon/Icon"; import DiskSpaceGraph from "components/DiskSpaceGraph"; import { HumanTimeDiffWithFleetLaunchCutoff } from "components/HumanTimeDiffWithDateTip"; import PremiumFeatureIconWithTooltip from "components/PremiumFeatureIconWithTooltip"; -import { - getHostDiskEncryptionTooltipMessage, - humanHostMemory, - wrapFleetHelper, -} from "utilities/helpers"; +import { humanHostMemory, wrapFleetHelper } from "utilities/helpers"; import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants"; import StatusIndicator from "components/StatusIndicator"; @@ -54,6 +50,48 @@ interface IHostSummaryProps { osSettings?: IOSSettings; } +const MAC_WINDOWS_DISK_ENCRYPTION_MESSAGES = { + darwin: { + enabled: ( + <> + The disk is encrypted. The user must enter their +
password when they start their computer. + + ), + disabled: ( + <> + The disk might be encrypted, but FileVault is off. The +
disk can be accessed without entering a password. + + ), + }, + windows: { + enabled: ( + <> + The disk is encrypted. If recently turned on, +
encryption could take awhile. + + ), + disabled: "The disk is unencrypted.", + }, +}; + +const getHostDiskEncryptionTooltipMessage = ( + platform: "darwin" | "windows" | "chrome", // TODO: improve this type + diskEncryptionEnabled = false +) => { + if (platform === "chrome") { + return "Fleet does not check for disk encryption on Chromebooks, as they are encrypted by default."; + } + + if (!["windows", "darwin"].includes(platform)) { + return "Disk encryption is enabled."; + } + return MAC_WINDOWS_DISK_ENCRYPTION_MESSAGES[platform][ + diskEncryptionEnabled ? "enabled" : "disabled" + ]; +}; + const HostSummary = ({ titleData, bootstrapPackageData, diff --git a/frontend/utilities/helpers.tsx b/frontend/utilities/helpers.tsx index 42d46eb6f4..11243d7e8a 100644 --- a/frontend/utilities/helpers.tsx +++ b/frontend/utilities/helpers.tsx @@ -642,36 +642,6 @@ export const internationalTimeFormat = (date: number | Date): string => { ); }; -const MAC_WINDOWS_DISK_ENCRYPTION_MESSAGES = { - darwin: { - enabled: - "The disk is encrypted. The user must enter their
password when they start their computer.", - disabled: - "The disk might be encrypted, but FileVault is off. The
disk can be accessed without entering a password.", - }, - windows: { - enabled: - "The disk is encrypted. If recently turned on,
encryption could take awhile.", - disabled: "The disk is unencrypted.", - }, -}; - -export const getHostDiskEncryptionTooltipMessage = ( - platform: "darwin" | "windows" | "chrome", // TODO: improve this type - diskEncryptionEnabled = false -) => { - if (platform === "chrome") { - return "Fleet does not check for disk encryption on Chromebooks, as they are encrypted by default."; - } - - if (!["windows", "darwin"].includes(platform)) { - return "Disk encryption is enabled."; - } - return MAC_WINDOWS_DISK_ENCRYPTION_MESSAGES[platform][ - diskEncryptionEnabled ? "enabled" : "disabled" - ]; -}; - export const hostTeamName = (teamName: string | null): string => { if (!teamName) { return "No team"; @@ -915,7 +885,6 @@ export default { humanLastSeen, internationalTimeFormat, internallyTruncateText, - getHostDiskEncryptionTooltipMessage, hostTeamName, humanQueryLastRun, inMilliseconds,