**Related issue:** Resolves #49419 Adds the UI for patching Fleet-maintained apps when the app is closed. The patch toggle becomes a Deploy control with Force install and Patch checkboxes. Checking Patch reveals a radio group: Patch when app is closed, Force patch, or End user initiated. The control appears in the Add software flow, a new Deploy modal, and the edit-policy page. The change also adds skipped-install copy in the activity feed and install details, a Self-service toggle for Fleet-maintained apps, and GitOps and Premium gating. The PR also includes backend changes that expose the patch policy's continuous-automation state and a Fleet-maintained app's install query in the API. The UI reads both to show the correct Deploy options, so they ship in one PR. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually Eng QA walkthrough [part 1](https://drive.google.com/file/d/1Un-Z4QoTk2eXslQ_b8t95cE11QYq1SUt/view?usp=drive_link), [part 2](https://drive.google.com/file/d/12_1Eh_RHOJ7RTjXBxFgas0VhKWvhLS0r/view?usp=drive_link)
179 lines
5.3 KiB
TypeScript
179 lines
5.3 KiB
TypeScript
import PropTypes from "prop-types";
|
|
import { CommaSeparatedPlatformString } from "interfaces/platform";
|
|
import type { ActivityType, IActivityDetails } from "interfaces/activity";
|
|
import { IScript } from "./script";
|
|
import { ILabelPolicy } from "./label";
|
|
|
|
// Legacy PropTypes used on host interface
|
|
export default PropTypes.shape({
|
|
author_email: PropTypes.string.isRequired,
|
|
author_id: PropTypes.number.isRequired,
|
|
author_name: PropTypes.string.isRequired,
|
|
created_at: PropTypes.string.isRequired,
|
|
description: PropTypes.string.isRequired,
|
|
id: PropTypes.number.isRequired,
|
|
name: PropTypes.string.isRequired,
|
|
query: PropTypes.string.isRequired,
|
|
resolution: PropTypes.string.isRequired,
|
|
critical: PropTypes.bool,
|
|
response: PropTypes.string,
|
|
team_id: PropTypes.number,
|
|
updated_at: PropTypes.string.isRequired,
|
|
});
|
|
|
|
export type OtherAutomationType = "webhook" | "ticket";
|
|
|
|
export type TicketOrWebhookState = OtherAutomationType | "disabled";
|
|
|
|
export interface IStoredPolicyResponse {
|
|
policy: IPolicy;
|
|
}
|
|
|
|
export interface IPoliciesCountResponse {
|
|
count: number;
|
|
inherited_policy_count?: number;
|
|
}
|
|
|
|
export type PolicyAutomationActivityStatus = "error" | "success";
|
|
|
|
export interface IPolicyAutomationActivity {
|
|
id: number;
|
|
created_at: string;
|
|
type: ActivityType;
|
|
fleet_initiated: boolean;
|
|
details: IActivityDetails;
|
|
host_id: number;
|
|
host_display_name: string;
|
|
status: PolicyAutomationActivityStatus;
|
|
output: string | null;
|
|
pre_install_output: string | null;
|
|
post_install_output: string | null;
|
|
}
|
|
|
|
export interface IPolicy {
|
|
id: number;
|
|
name: string;
|
|
query: string;
|
|
description: string;
|
|
author_id: number;
|
|
author_name: string;
|
|
author_email: string;
|
|
resolution: string;
|
|
platform: CommaSeparatedPlatformString;
|
|
team_id: number | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
// A critical policy cannot be "resolved later" if Okta conditional access is enabled for it
|
|
critical: boolean;
|
|
calendar_events_enabled: boolean;
|
|
conditional_access_enabled: boolean;
|
|
type: string;
|
|
install_software?: IPolicySoftwareToInstall;
|
|
run_script?: Pick<IScript, "id" | "name">;
|
|
patch_software?: IPolicySoftwareToInstall;
|
|
continuous_automations_enabled?: boolean;
|
|
patch_when_closed?: boolean;
|
|
labels_include_any?: ILabelPolicy[];
|
|
labels_include_all?: ILabelPolicy[];
|
|
labels_exclude_any?: ILabelPolicy[];
|
|
labels_exclude_all?: ILabelPolicy[];
|
|
}
|
|
export interface IPolicySoftwareToInstall {
|
|
name: string;
|
|
display_name?: string;
|
|
software_title_id: number;
|
|
icon_url?: string | null;
|
|
/** Present when the policy pins a specific package on a multi-package
|
|
* title. Absent for VPP-backed policies. When absent the automations UI
|
|
* falls back to auto-selecting the title's first-added package. */
|
|
software_installer_id?: number;
|
|
}
|
|
|
|
// Used on the manage hosts page and other places where aggregate stats are displayed
|
|
export interface IPolicyStats extends IPolicy {
|
|
passing_host_count: number;
|
|
failing_host_count: number;
|
|
host_count_updated_at: string;
|
|
webhook: string;
|
|
has_run: boolean;
|
|
next_update_ms: number;
|
|
}
|
|
|
|
export interface IPolicyWebhookPreviewPayload {
|
|
id: number;
|
|
name: string;
|
|
query: string;
|
|
description: string;
|
|
author_id: number;
|
|
author_name: string;
|
|
author_email: string;
|
|
resolution: string;
|
|
passing_host_count: number;
|
|
failing_host_count: number;
|
|
critical?: boolean;
|
|
}
|
|
|
|
export type PolicyStatusResponse = "pass" | "fail" | "";
|
|
|
|
// Used on the host details page and other places where the status of individual hosts are displayed
|
|
export interface IHostPolicy extends IPolicy {
|
|
response: PolicyStatusResponse;
|
|
}
|
|
|
|
// Policies API can return {}
|
|
export interface ILoadAllPoliciesResponse {
|
|
policies?: IPolicyStats[];
|
|
}
|
|
|
|
// Team policies API can return {}
|
|
export interface ILoadTeamPoliciesResponse {
|
|
policies?: IPolicyStats[];
|
|
}
|
|
|
|
export interface ILoadTeamPolicyResponse {
|
|
policy: IPolicyStats;
|
|
}
|
|
|
|
export interface IPolicyFormData {
|
|
description?: string | number | boolean | undefined;
|
|
resolution?: string | number | boolean | undefined;
|
|
// A critical policy cannot be "resolved later" if Okta conditional access is enabled for it
|
|
critical?: boolean;
|
|
platform?: CommaSeparatedPlatformString;
|
|
name?: string | number | boolean | undefined;
|
|
query?: string | number | boolean | undefined;
|
|
team_id?: number | null;
|
|
id?: number;
|
|
calendar_events_enabled?: boolean;
|
|
conditional_access_enabled?: boolean;
|
|
continuous_automations_enabled?: boolean;
|
|
patch_when_closed?: boolean;
|
|
software_title_id?: number | null;
|
|
/** Pins the policy to a specific package on a multi-package title. `null`
|
|
* on PATCH lets the backend fall back to the title's first-added package
|
|
* (mirrors `software_title_id`'s unset asymmetry). */
|
|
software_installer_id?: number | null;
|
|
// null for PATCH to unset - note asymmetry with GET/LIST - see IPolicy.run_script
|
|
script_id?: number | null;
|
|
labels_include_any?: string[];
|
|
labels_include_all?: string[];
|
|
labels_exclude_any?: string[];
|
|
labels_exclude_all?: string[];
|
|
/** Required for creating patch policy */
|
|
type?: "dynamic" | "patch";
|
|
/** Required for creating patch policy */
|
|
patch_software_title_id?: number;
|
|
}
|
|
|
|
export interface IPolicyNew {
|
|
id?: number;
|
|
key?: number;
|
|
name: string;
|
|
description: string;
|
|
query: string;
|
|
resolution: string;
|
|
critical: boolean;
|
|
platform: CommaSeparatedPlatformString;
|
|
mdm_required?: boolean;
|
|
}
|