fleet/frontend/interfaces/team.ts
Jacob Shandling 5137fe380c
17445 calendar events modal (#17717)
Addresses #17445 

Follow-up iteration:
- Finalize styling of dropdown tooltips
- All `//TODO`s

<img width="1393" alt="Screenshot 2024-03-20 at 1 43 54 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/9b792cf0-058a-4ae6-8f5f-a49eb936ebef">
<img width="1393" alt="Screenshot 2024-03-20 at 1 44 01 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/86195dcf-ec28-4cf0-ab8b-d785d12372ed">
<img width="1393" alt="Screenshot 2024-03-20 at 1 44 21 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/01effdec-ca20-49ec-a442-5fe754a5e12b">
<img width="1393" alt="Screenshot 2024-03-20 at 1 44 26 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/b6de6891-6eae-426e-bbff-b01184094ac9">
<img width="1393" alt="Screenshot 2024-03-20 at 1 44 33 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/96e167dd-752c-4b49-a1a7-69fe9b4f42ac">
<img width="1393" alt="Screenshot 2024-03-20 at 1 44 43 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/feedbda5-e915-4e5e-84ee-2316db49434a">
<img width="1393" alt="Screenshot 2024-03-20 at 1 44 47 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/c4b5ac47-3357-43ef-95ca-dd0953994f6f">
<img width="1393" alt="Screenshot 2024-03-20 at 1 45 02 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/17838415-5bf4-46f0-9bde-522deb0f0886">
<img width="1393" alt="Screenshot 2024-03-20 at 1 45 10 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/b7228484-bb9f-4119-9fbf-a60ce990ba0e">

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-03-26 13:39:37 -05:00

138 lines
3.6 KiB
TypeScript

import PropTypes from "prop-types";
import { IConfigFeatures, IWebhookSettings } from "./config";
import enrollSecretInterface, { IEnrollSecret } from "./enroll_secret";
import { ITeamIntegrations } from "./integration";
import { UserRole } from "./user";
export default PropTypes.shape({
id: PropTypes.number.isRequired,
created_at: PropTypes.string,
name: PropTypes.string.isRequired,
description: PropTypes.string,
agent_options: PropTypes.object, // eslint-disable-line react/forbid-prop-types
role: PropTypes.any, // eslint-disable-line react/forbid-prop-types
// role value is included when the team is in the context of a user
user_count: PropTypes.number,
host_count: PropTypes.number,
secrets: PropTypes.arrayOf(enrollSecretInterface),
});
/**
* The id, name, description, and host count for a team entity
*/
export interface ITeamSummary {
id: number;
name: string;
description?: string;
host_count?: number;
}
/**
* The shape of a team entity excluding integrations and webhook settings
*/
export interface ITeam extends ITeamSummary {
uuid?: string;
display_text?: string;
count?: number;
created_at?: string;
features?: IConfigFeatures;
agent_options?: {
[key: string]: any;
};
user_count?: number;
host_count?: number;
secrets?: IEnrollSecret[];
role?: UserRole; // role value is included when the team is in the context of a user
mdm?: {
enable_disk_encryption: boolean;
macos_updates: {
minimum_version: string | null;
deadline: string | null;
};
macos_settings: {
custom_settings: null; // TODO: types?
enable_disk_encryption: boolean;
};
macos_setup: {
bootstrap_package: string | null;
enable_end_user_authentication: boolean;
macos_setup_assistant: string | null; // TODO: types?
};
windows_updates: {
deadline_days: number | null;
grace_period_days: number | null;
};
};
host_expiry_settings?: {
host_expiry_enabled: boolean;
host_expiry_window: number; // days
};
}
/**
* The webhook settings of a team
*/
export type ITeamWebhookSettings = Pick<
IWebhookSettings,
"vulnerabilities_webhook" | "failing_policies_webhook" | "host_status_webhook"
>;
/**
* The integrations and webhook settings of a team
*/
export interface ITeamAutomationsConfig {
webhook_settings: ITeamWebhookSettings;
integrations: ITeamIntegrations;
}
/**
* The shape of a team entity including integrations and webhook settings
*/
export type ITeamConfig = ITeam & ITeamAutomationsConfig;
/**
* The shape of a new user to add to a team
*/
export interface INewTeamUser {
id: number;
role: UserRole;
}
/**
* The shape of the body expected from the API when adding new users to teams
*/
export interface INewTeamUsersBody {
users: INewTeamUser[];
}
export interface IRemoveTeamUserBody {
users: { id?: number }[];
}
interface INewTeamSecret {
team_id: number;
secret: string;
created_at?: string;
}
export interface INewTeamSecretBody {
secrets: INewTeamSecret[];
}
export interface IRemoveTeamSecretBody {
secrets: { secret: string }[];
}
export const API_ALL_TEAMS_ID = undefined;
export const APP_CONTEXT_ALL_TEAMS_ID = -1;
export const APP_CONTEXT_ALL_TEAMS_SUMMARY: ITeamSummary = {
id: APP_CONTEXT_ALL_TEAMS_ID,
name: "All teams",
} as const;
export const API_NO_TEAM_ID = 0;
export const APP_CONTEXT_NO_TEAM_ID = 0;
export const APP_CONTEX_NO_TEAM_SUMMARY: ITeamSummary = {
id: APP_CONTEXT_NO_TEAM_ID,
name: "No team",
} as const;
export const isAnyTeamSelected = (currentTeamId?: number) =>
currentTeamId !== undefined && currentTeamId > APP_CONTEXT_NO_TEAM_ID;