**Related issue:** Resolves https://github.com/fleetdm/fleet/issues/46818 and https://github.com/fleetdm/fleet/issues/48524. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually ## fleetd/orbit/Fleet Desktop - [x] Verified compatibility with the latest released version of Fleet (see [Must rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md)) - [x] If the change applies to only one platform, confirmed that `runtime.GOOS` is used as needed to isolate changes - [x] Verified that fleetd runs on macOS, Linux and Windows - [x] Verified auto-update works from the released version of component to the new version (see [tools/tuf/test](../tools/tuf/test/README.md)) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Host lists and Host details now show human‑readable Apple hardware marketing names (macOS, iOS, iPadOS) where available (e.g., "MacBook Pro (16‑inch, 2021)"), replacing raw model identifiers. * Hardware model displays fall back to the original model identifier for non‑Apple or unmapped devices. * **Bug Fixes / CSV** * Exported host CSVs now align with the UI by using the marketing name for Apple devices when available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Lucas Manuel Rodriguez <lucas@fleetdm.com>
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import React from "react";
|
|
|
|
import { isAppleDevice } from "interfaces/platform";
|
|
import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants";
|
|
|
|
export const getHostStatusTooltipText = (status: string): string => {
|
|
if (status === "online") {
|
|
return "Online hosts will respond to a live report.";
|
|
}
|
|
if (status === DEFAULT_EMPTY_CELL_VALUE) {
|
|
return "Device is pending enrollment in Apple Business and status is not yet available.";
|
|
}
|
|
return "Offline hosts won't respond to a live report because they may be shut down, asleep, or not connected to the internet.";
|
|
};
|
|
|
|
export const getHostStatus = (
|
|
status: string,
|
|
mdmEnrollmentStatus?: string
|
|
): string => {
|
|
if (mdmEnrollmentStatus === "Pending") {
|
|
return DEFAULT_EMPTY_CELL_VALUE;
|
|
}
|
|
|
|
return status || DEFAULT_EMPTY_CELL_VALUE;
|
|
};
|
|
|
|
// getHardwareModelDisplay computes how a host's hardware model is presented.
|
|
// Apple devices with a known marketing name (e.g. "MacBook Pro (16-inch,
|
|
// 2021)") show it in place of the raw model and reveal the raw model in a
|
|
// tooltip; otherwise the raw model is shown with no supplemental tooltip.
|
|
// An empty field may be "" (raw API data) or DEFAULT_EMPTY_CELL_VALUE (data
|
|
// that went through normalizeEmptyValues) — both count as "no value".
|
|
export const getHardwareModelDisplay = (
|
|
platform: string,
|
|
hardwareModel: string,
|
|
hardwareMarketingName: string
|
|
): { value: string; tooltip?: JSX.Element; alwaysShowTooltip: boolean } => {
|
|
const isEmpty = (val: string) => !val || val === DEFAULT_EMPTY_CELL_VALUE;
|
|
|
|
const marketingName =
|
|
isAppleDevice(platform) && !isEmpty(hardwareMarketingName)
|
|
? hardwareMarketingName
|
|
: "";
|
|
// Only reveal the raw model on hover when we're actually showing a distinct
|
|
// marketing name in its place. When there's no mapping the marketing name is
|
|
// empty (or echoes the raw model), so we show the raw model plainly with no
|
|
// tooltip.
|
|
const showModelTooltip =
|
|
!!marketingName &&
|
|
!isEmpty(hardwareModel) &&
|
|
marketingName !== hardwareModel;
|
|
|
|
return {
|
|
value: marketingName || hardwareModel,
|
|
tooltip: showModelTooltip ? (
|
|
// Left-align to override the tooltip's default centered text.
|
|
<div style={{ textAlign: "left" }}>
|
|
<b>Model:</b> {hardwareModel}
|
|
<br />
|
|
<b>Marketing name:</b> {marketingName}
|
|
</div>
|
|
) : undefined,
|
|
alwaysShowTooltip: showModelTooltip,
|
|
};
|
|
};
|