fleet/frontend/pages/ManageControlsPage/MacOSSettings/AggregateMacSettingsIndicators/AggregateMacSettingsIndicators.tsx
Gabriel Hernandez e822132590
Feat/disk encryption page (#10288)
related to #9402 and #9404

Implements UI for toggling off and on fleet mdm disk encryption
management and also the disk encryption aggregate data tables.

**Toggling disk encryption:**


![image](https://user-images.githubusercontent.com/1153709/222773636-2943521b-6e88-4154-980b-92e1122aebfc.png)

**disk encryption aggregate:**


![image](https://user-images.githubusercontent.com/1153709/222773592-0781fe1b-7808-4e50-b7de-03c6817c612f.png)

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
- [x] Manual QA for all new/changed functionality
2023-03-14 13:03:02 -07:00

84 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { IAggregateMacSettingsStatus } 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 AggregateMacSettingsIndicatorsProps {
teamId: number;
}
const AggregateMacSettingsIndicators = ({
teamId,
}: AggregateMacSettingsIndicatorsProps) => {
const AGGREGATE_STATUS_DISPLAY_OPTIONS = {
latest: {
text: "Latest",
iconName: "success",
tooltipText: "Hosts that applied the latest settings.",
},
pending: {
text: "Pending",
iconName: "pending",
tooltipText:
"Hosts that havent applied the latest settings because they are asleep, disconnected from the internet, or require action.",
},
failing: {
text: "Failing",
iconName: "error",
tooltipText:
"Hosts that failed to apply the latest settings. View hosts to see errors.",
},
} as const;
const {
data: aggregateProfileStatusesResponse,
} = useQuery<IAggregateMacSettingsStatus>(
["aggregateProfileStatuses", teamId],
() => mdmAPI.getAggregateProfileStatuses(teamId),
{ refetchOnWindowFocus: false }
);
const DISPLAY_ORDER = ["latest", "pending", "failing"] as const;
const orderedResponseKVArr: [
keyof IAggregateMacSettingsStatus,
number
][] = aggregateProfileStatusesResponse
? DISPLAY_ORDER.map((key) => {
return [key, aggregateProfileStatusesResponse[key]];
})
: [];
const indicators = orderedResponseKVArr.map(([status, count]) => {
const { text, iconName, tooltipText } = AGGREGATE_STATUS_DISPLAY_OPTIONS[
status
];
return (
<div className="aggregate-mac-settings-indicator">
{/* NOTE - below will be renamed as a general component and moved into the components dir by Gabe */}
<MacSettingsIndicator
indicatorText={text}
iconName={iconName}
tooltip={{ tooltipText, position: "top" }}
/>
<a
href={`${paths.MANAGE_HOSTS}?${buildQueryStringFromParams({
team_id: teamId,
macos_settings: status,
})}`}
>
{count} hosts
</a>
</div>
);
});
return <div className={baseClass}>{indicators}</div>;
};
export default AggregateMacSettingsIndicators;