import { IconNames } from "components/icons"; import { MdmProfileStatus } from "interfaces/mdm"; import MacSettingsIndicator from "pages/hosts/details/MacSettingsIndicator"; import React from "react"; import { useQuery } from "react-query"; import paths from "router/paths"; import mdmAPI from "services/entities/mdm"; import { buildQueryStringFromParams } from "utilities/url"; const baseClass = "aggregate-mac-settings-indicators"; interface IAggregateDisplayOption { value: MdmProfileStatus; text: string; iconName: IconNames; tooltipText: string; } const AGGREGATE_STATUS_DISPLAY_OPTIONS: IAggregateDisplayOption[] = [ { value: MdmProfileStatus.VERIFYING, text: "Verifying", iconName: "success-partial", tooltipText: "Hosts that told Fleet all settings are enforced. Fleet is verifying.", }, { value: MdmProfileStatus.PENDING, text: "Pending", iconName: "pending-partial", tooltipText: "Hosts that will have settings enforced when the hosts come online.", }, { value: MdmProfileStatus.FAILED, text: "Failed", iconName: "error", tooltipText: "Hosts that failed to apply settings. Click on a host to view error(s).", }, ]; type ProfileSummaryResponse = Record; interface AggregateMacSettingsIndicatorsProps { teamId: number; } const AggregateMacSettingsIndicators = ({ teamId, }: AggregateMacSettingsIndicatorsProps) => { const { data: aggregateProfileStatusesResponse, } = useQuery( ["aggregateProfileStatuses", teamId], () => mdmAPI.getAggregateProfileStatuses(teamId), { refetchOnWindowFocus: false } ); if (!aggregateProfileStatusesResponse) return null; const indicators = AGGREGATE_STATUS_DISPLAY_OPTIONS.map((status) => { const { value, text, iconName, tooltipText } = status; const count = aggregateProfileStatusesResponse[value]; return (
{count} hosts
); }); return
{indicators}
; }; export default AggregateMacSettingsIndicators;