import React from "react"; import { DisplayPlatform, QueryableDisplayPlatform, QueryablePlatform, } from "interfaces/platform"; import { PLATFORM_DISPLAY_NAMES } from "utilities/constants"; import TooltipWrapper from "components/TooltipWrapper"; import Icon from "components/Icon"; interface IPlatformCompatibilityProps { compatiblePlatforms: any[] | null; error: Error | null; } const baseClass = "platform-compatibility"; const DISPLAY_ORDER = [ "macOS", "Windows", "Linux", "ChromeOS", ] as QueryableDisplayPlatform[]; const ERROR_NO_COMPATIBLE_TABLES = Error("no tables in query"); const formatPlatformsForDisplay = ( compatiblePlatforms: QueryablePlatform[] ): DisplayPlatform[] => { return compatiblePlatforms.map((str) => PLATFORM_DISPLAY_NAMES[str] || str); }; const displayIncompatibilityText = (err: Error) => { switch (err) { case ERROR_NO_COMPATIBLE_TABLES: return ( No platforms (check your query for invalid tables or tables that are supported on different platforms) ); default: return ( No platforms (check your query for a possible syntax error) ); } }; // const tipContent = ( // <> // Estimated compatibility based on the
// tables used in the query. Querying
// iPhones, iPads, and Android hosts is not
// supported. // // ); // TODO(android): replace with the above tipContent when Android feature flag is removed const tipContent = ( <> Estimated compatibility based on the
tables used in the query. Check the
table documentation (schema) to verify
compatibility of individual columns.

Only live queries are supported on ChromeOS.

Querying iPhones & iPads is not supported. ); const PlatformCompatibility = ({ compatiblePlatforms, error, }: IPlatformCompatibilityProps): JSX.Element | null => { if (!compatiblePlatforms) { return null; } const displayPlatforms = formatPlatformsForDisplay(compatiblePlatforms); const renderCompatiblePlatforms = () => { if (error || !compatiblePlatforms?.length) { return displayIncompatibilityText(error || ERROR_NO_COMPATIBLE_TABLES); } return DISPLAY_ORDER.map((platform) => { const isCompatible = displayPlatforms.includes(platform); return ( {platform} ); }); }; return (
Compatible with: {renderCompatiblePlatforms()}
); }; export default PlatformCompatibility;