fleet/frontend/components/TableContainer/DataTable/PlatformCell/PlatformCell.tsx
Jacob Shandling 266e9bf2e0
UI – Update platforms column to only display compatible platforms (#13003)
## Addresses #12999 

<img width="1282" alt="Screenshot 2023-07-27 at 11 59 01 AM"
src="https://github.com/fleetdm/fleet/assets/61553566/b60d3b41-3d7b-4550-ba7c-8615bae085a6">


# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/`
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-07-27 12:10:22 -07:00

54 lines
1.3 KiB
TypeScript

import React from "react";
import Icon from "components/Icon";
import { SupportedPlatform } from "interfaces/platform";
import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants";
interface IPlatformCellProps {
platforms: SupportedPlatform[];
}
const baseClass = "platform-cell";
const ICONS: Record<string, "darwin" | "windows" | "linux" | "chrome"> = {
darwin: "darwin",
windows: "windows",
linux: "linux",
chrome: "chrome",
};
const DISPLAY_ORDER: SupportedPlatform[] = [
"darwin",
"windows",
"linux",
"chrome",
// "None",
// "Invalid query",
];
const PlatformCell = ({ platforms }: IPlatformCellProps): JSX.Element => {
const orderedList = DISPLAY_ORDER.filter((platform) =>
platforms.includes(platform)
);
return (
<span className={`${baseClass}__wrapper`}>
{orderedList.length ? (
orderedList.map((platform) => {
return ICONS[platform] ? (
<Icon
className={`${baseClass}__icon`}
name={ICONS[platform]}
size="small"
key={ICONS[platform]}
/>
) : null;
})
) : (
<span className={`${baseClass}__muted`}>
{DEFAULT_EMPTY_CELL_VALUE}
</span>
)}
</span>
);
};
export default PlatformCell;