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