fleet/frontend/interfaces/host.ts
Jacob Shandling a578e20930
UI: Add macOS settings (profiles) indicator and modal with data table (#9809)
# Addresses #9413

# Implements
https://www.loom.com/share/d1b66a3076b94bf2add4fcf8666649a4

- macOS settings indicator on host details and device user pages. Only
displayed if (1) the host is enrolled in a Fleet MDM server and (2) the
host has at least one setting (profile) enforced.
- macOS settings modal, toggled by clicking on above indicator. Contains
a data table with the name, status, and error messages, if any, of each
enforced macOS setting on the host.

# Notes
- To aid in reviewing, you'll probably want to focus on:
-
[DeviceUserPage.tsx](https://github.com/fleetdm/fleet/pull/9809/files#diff-be9f14d3cee9f345058212985c26b3452688c6d75853a5e9dcb968a69dfcbbd7)
and
[HostDetailsPage.tsx](https://github.com/fleetdm/fleet/pull/9809/files#diff-72f7403682d211fc8a84a411fc39c4a33c3eb6a33549a33f1179dd7da6a893cc)
-
[HostSummary.tsx](https://github.com/fleetdm/fleet/pull/9809/files#diff-435e720f1ad82e892bec00fbc9c14e01e9488b776ae293f9158500c66d85bd0d)
-
[MacSettingsIndicator.tsx](https://github.com/fleetdm/fleet/pull/9809/files#diff-e23079f72b13bd34eb978eded467265dad4f366a6fece60cd52c887f355f92d1)
-
[MacSettingsModal.tsx](https://github.com/fleetdm/fleet/pull/9809/files#diff-75a08aa5b66cc2b63fc616d8ba012e552376f23d3c3df01d875586857f326f53)
-
[MacSettingsTable.tsx](https://github.com/fleetdm/fleet/pull/9809/files#diff-5dc441b06f770f112bb32bb618e2140e9bbccb7ebf80d86ee57c2754e067a421)
and its associated
[MacSettingsTableConfig.tsx](https://github.com/fleetdm/fleet/pull/9809/files#diff-0ab0cb34e249e2a41bf51508d38bea018dc5e683b705308250241c42549ab093)
   
- Currently using mock data. Once #9599 is completed, #9888 will change
these components to use the real data
- 2/21 - removed mock data. Until the API returns the host.mdm.profiles
data, settings indicator and modal will not render
# Checklist

- [x] Changes file added
- [x] Manual QA
- [x] Updated testing inventory

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-02-22 08:13:12 -08:00

225 lines
5.7 KiB
TypeScript

import PropTypes from "prop-types";
import hostPolicyInterface, { IHostPolicy } from "./policy";
import hostUserInterface, { IHostUser } from "./host_users";
import labelInterface, { ILabel } from "./label";
import packInterface, { IPack } from "./pack";
import softwareInterface, { ISoftware } from "./software";
import hostQueryResult from "./campaign";
import queryStatsInterface, { IQueryStats } from "./query_stats";
import { ILicense, IDeviceGlobalConfig } from "./config";
import { IMacSettings, MdmEnrollmentStatus } from "./mdm";
export default PropTypes.shape({
created_at: PropTypes.string,
updated_at: PropTypes.string,
id: PropTypes.number,
detail_updated_at: PropTypes.string,
label_updated_at: PropTypes.string,
policy_updated_at: PropTypes.string,
last_enrolled_at: PropTypes.string,
seen_time: PropTypes.string,
refetch_requested: PropTypes.bool,
hostname: PropTypes.string,
uuid: PropTypes.string,
platform: PropTypes.string,
osquery_version: PropTypes.string,
os_version: PropTypes.string,
build: PropTypes.string,
platform_like: PropTypes.string,
code_name: PropTypes.string,
uptime: PropTypes.number,
memory: PropTypes.number,
cpu_type: PropTypes.string,
cpu_subtype: PropTypes.string,
cpu_brand: PropTypes.string,
cpu_physical_cores: PropTypes.number,
cpu_logical_cores: PropTypes.number,
hardware_vendor: PropTypes.string,
hardware_model: PropTypes.string,
hardware_version: PropTypes.string,
hardware_serial: PropTypes.string,
computer_name: PropTypes.string,
primary_ip: PropTypes.string,
primary_mac: PropTypes.string,
distributed_interval: PropTypes.number,
config_tls_refresh: PropTypes.number,
logger_tls_period: PropTypes.number,
team_id: PropTypes.number,
pack_stats: PropTypes.arrayOf(
PropTypes.shape({
pack_id: PropTypes.number,
pack_name: PropTypes.string,
query_stats: PropTypes.arrayOf(queryStatsInterface),
})
),
team_name: PropTypes.string,
additional: PropTypes.object, // eslint-disable-line react/forbid-prop-types
percent_disk_space_available: PropTypes.number,
gigs_disk_space_available: PropTypes.number,
labels: PropTypes.arrayOf(labelInterface),
packs: PropTypes.arrayOf(packInterface),
software: PropTypes.arrayOf(softwareInterface),
status: PropTypes.string,
display_name: PropTypes.string,
users: PropTypes.arrayOf(hostUserInterface),
policies: PropTypes.arrayOf(hostPolicyInterface),
query_results: PropTypes.arrayOf(hostQueryResult),
batteries: PropTypes.arrayOf(
PropTypes.shape({
cycle_count: PropTypes.number,
health: PropTypes.string,
})
),
});
export type HostStatus = "online" | "offline" | "new" | "missing";
export interface IDeviceUser {
email: string;
source: string;
}
export interface IDeviceMappingResponse {
device_mapping: IDeviceUser[];
}
export interface IMunkiData {
version: string;
}
export interface IHostMdmData {
encryption_key_available: boolean;
enrollment_status: MdmEnrollmentStatus | null;
server_url: string;
profiles?: IMacSettings;
id?: number;
name?: string;
}
export interface IMunkiIssue {
id: number;
name: string;
type: "error" | "warning";
created_at: string;
}
export interface IMacadminsResponse {
macadmins: null | {
munki: null | IMunkiData;
mobile_device_management: null | IHostMdmData;
munki_issues: IMunkiIssue[];
};
}
export interface IPackStats {
pack_id: number;
pack_name: string;
query_stats: IQueryStats[];
type: string;
}
export interface IHostPolicyQuery {
id: number;
display_name: string;
query_results?: unknown[];
status?: string;
}
interface IGeoLocation {
country_iso: string;
city_name: string;
geometry?: {
type: string;
coordinates: number[];
};
}
interface IBattery {
cycle_count: number;
health: string;
}
export interface IHostResponse {
host: IHost;
}
export interface IDeviceUserResponse {
host: IHost;
license: ILicense;
org_logo_url: string;
disk_encryption_enabled?: boolean;
platform?: string;
global_config: IDeviceGlobalConfig;
}
export interface IHostEncrpytionKeyResponse {
host_id: number;
encryption_key: {
updated_at: string;
key: string;
};
}
export interface IHost {
created_at: string;
updated_at: string;
id: number;
detail_updated_at: string;
label_updated_at: string;
policy_updated_at: string;
last_enrolled_at: string;
seen_time: string;
refetch_requested: boolean;
hostname: string;
uuid: string;
platform: string;
osquery_version: string;
os_version: string;
build: string;
platform_like: string;
code_name: string;
uptime: number;
memory: number;
cpu_type: string;
cpu_subtype: string;
cpu_brand: string;
cpu_physical_cores: number;
cpu_logical_cores: number;
hardware_vendor: string;
hardware_model: string;
hardware_version: string;
hardware_serial: string;
computer_name: string;
public_ip: string;
primary_ip: string;
primary_mac: string;
distributed_interval: number;
config_tls_refresh: number;
logger_tls_period: number;
team_id: number | null;
pack_stats: IPackStats[] | null;
team_name: string | null;
additional?: object; // eslint-disable-line @typescript-eslint/ban-types
percent_disk_space_available: number;
gigs_disk_space_available: number;
labels: ILabel[];
packs: IPack[];
software: ISoftware[];
issues: {
total_issues_count: number;
failing_policies_count: number;
};
status: HostStatus;
display_text: string;
display_name: string;
target_type?: string;
users: IHostUser[];
device_users?: IDeviceUser[];
munki?: IMunkiData;
mdm: IHostMdmData;
policies: IHostPolicy[];
query_results?: unknown[];
geolocation?: IGeoLocation;
batteries?: IBattery[];
disk_encryption_enabled?: boolean;
}