fleet/frontend/components/TableContainer/DataTable/PlatformCell/PlatformCell.tsx

53 lines
1.3 KiB
TypeScript
Raw Normal View History

import React from "react";
2022-11-18 17:21:13 +00:00
import Icon from "components/Icon";
import TextCell from "components/TableContainer/DataTable/TextCell";
import { QueryablePlatform } from "interfaces/platform";
interface IPlatformCellProps {
platforms: QueryablePlatform[];
}
const baseClass = "platform-cell";
const ICONS: Record<string, QueryablePlatform> = {
2022-11-18 17:21:13 +00:00
darwin: "darwin",
windows: "windows",
linux: "linux",
chrome: "chrome",
};
const DISPLAY_ORDER: QueryablePlatform[] = [
"darwin",
"windows",
"linux",
// Chrome is supported for queries, but unsupported for scheduled queries
// which are currently not supported in ChromeOS.
"chrome",
];
const PlatformCell = ({ platforms }: IPlatformCellProps): JSX.Element => {
let orderedList: QueryablePlatform[] = [];
if (!platforms.length) {
return <TextCell value="---" grey />;
}
orderedList = DISPLAY_ORDER.filter((platform) =>
platforms.includes(platform)
);
return (
2023-08-28 17:09:21 +00:00
<span className={`${baseClass}__wrapper`} data-testid="icons">
{orderedList.map((platform) => {
return ICONS[platform] ? (
<Icon
className={`${baseClass}__icon`}
name={ICONS[platform]}
size="small"
key={ICONS[platform]}
/>
) : null;
})}
</span>
);
};
export default PlatformCell;