mirror of
https://github.com/fleetdm/fleet
synced 2026-05-21 16:08:47 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #34239 <img width="1765" height="1146" alt="Screenshot 2025-10-16 at 12 11 39 PM" src="https://github.com/user-attachments/assets/4735012d-6ddc-45cd-87a8-f92c9b7283b0" /> - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually
109 lines
2.7 KiB
TypeScript
109 lines
2.7 KiB
TypeScript
import PropTypes from "prop-types";
|
|
|
|
export default PropTypes.shape({
|
|
created_at: PropTypes.string,
|
|
updated_at: PropTypes.string,
|
|
id: PropTypes.oneOfType([PropTypes.number]),
|
|
name: PropTypes.string,
|
|
query: PropTypes.string,
|
|
label_type: PropTypes.oneOf(["regular", "builtin"]),
|
|
label_membership_type: PropTypes.oneOf(["dynamic", "manual"]),
|
|
hosts_count: PropTypes.number,
|
|
display_text: PropTypes.string,
|
|
count: PropTypes.number, // seems to be a repeat of hosts_count issue #1618
|
|
host_ids: PropTypes.arrayOf(PropTypes.number),
|
|
});
|
|
|
|
export type LabelType = "regular" | "builtin";
|
|
export type LabelMembershipType = "dynamic" | "manual" | "host_vitals";
|
|
export const LabelMembershipTypeToDisplayCopy: Record<
|
|
LabelMembershipType,
|
|
string
|
|
> = {
|
|
dynamic: "Dynamic",
|
|
manual: "Manual",
|
|
host_vitals: "Host vitals",
|
|
};
|
|
|
|
export type LabelHostVitalsCriterion =
|
|
| "end_user_idp_group"
|
|
| "end_user_idp_department"; // for now, may expand to be configurable
|
|
|
|
export type LabelLeafCriterion = {
|
|
vital: LabelHostVitalsCriterion;
|
|
value: string; // from user input
|
|
};
|
|
|
|
type LabelAndCriterion = {
|
|
and: LabelHostVitalsCriteria[];
|
|
};
|
|
|
|
type LabelOrCriterion = {
|
|
or: LabelHostVitalsCriteria[];
|
|
};
|
|
|
|
export type LabelHostVitalsCriteria =
|
|
| LabelLeafCriterion
|
|
| LabelAndCriterion
|
|
| LabelOrCriterion;
|
|
|
|
export interface ILabelSummary {
|
|
id: number;
|
|
name: string;
|
|
description?: string;
|
|
label_type: LabelType;
|
|
}
|
|
|
|
export interface ILabelSoftwareTitle {
|
|
id: number;
|
|
name: string;
|
|
}
|
|
|
|
export interface ILabelQuery {
|
|
id: number;
|
|
name: string;
|
|
}
|
|
|
|
export interface ILabelPolicy {
|
|
id: number;
|
|
name: string;
|
|
}
|
|
|
|
export interface ILabel extends ILabelSummary {
|
|
created_at: string;
|
|
updated_at: string;
|
|
uuid?: string;
|
|
host_count?: number; // returned for built-in labels but not custom labels
|
|
display_text: string;
|
|
count: number; // seems to be a repeat of hosts_count issue #1618
|
|
type?: "custom" | "platform" | "status" | "all";
|
|
slug?: string; // e.g., "labels/13" | "online"
|
|
target_type?: string; // e.g., "labels"
|
|
author_id?: number;
|
|
|
|
label_membership_type: LabelMembershipType;
|
|
|
|
// dynamic-specific
|
|
query: string; // does return '""' for other types
|
|
platform: string; // does return '""' for other types
|
|
|
|
// host_vitals-specific
|
|
criteria: LabelHostVitalsCriteria | null;
|
|
|
|
// manual-specific
|
|
host_ids: number[] | null;
|
|
}
|
|
|
|
// corresponding to fleet>server>fleet>labels.go>LabelSpec
|
|
export interface ILabelSpecResponse {
|
|
specs: {
|
|
id: number;
|
|
name: string;
|
|
description: string;
|
|
query: string;
|
|
platform?: string; // improve to only allow possible platforms from API
|
|
label_type?: LabelType;
|
|
label_membership_type: LabelMembershipType;
|
|
hosts?: string[];
|
|
};
|
|
}
|