fleet/frontend/utilities/constants.ts
Gabriel Hernandez 2bdf0000c8
implement UI sorting hosts by disk encryption status (#10909)
relates to #9407

# Checklist for submitter

implemented UI for filtering disk encryption. This includes the view all
hosts link and the filtering pills on the manage host page.

**view all hosts link**


![image](https://user-images.githubusercontent.com/1153709/229105429-6f813d01-2358-4176-9ba4-c50168fb36b8.png)

**Filtering manage host page**


![image](https://user-images.githubusercontent.com/1153709/229105491-ec29c9a1-f465-4548-87a6-a493ab0b817f.png)


- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Manual QA for all new/changed functionality
2023-04-05 19:34:30 +01:00

250 lines
7.0 KiB
TypeScript

import URL_PREFIX from "router/url_prefix";
import { IOsqueryPlatform } from "interfaces/platform";
import paths from "router/paths";
const { origin } = global.window.location;
export const BASE_URL = `${origin}${URL_PREFIX}/api`;
export enum PolicyResponse {
PASSING = "passing",
FAILING = "failing",
}
export enum DiskEncryptionStatus {
APPLIED = "applied",
ACTION_REQUIRED = "action_required",
ENFORCING = "enforcing",
FAILED = "failed",
REMOVING_ENFORCEMENT = "removing_enforcement",
}
export const DEFAULT_GRAVATAR_LINK =
"https://fleetdm.com/images/permanent/icon-avatar-default-transparent-64x64%402x.png";
export const DEFAULT_GRAVATAR_LINK_DARK =
"https://fleetdm.com/images/permanent/icon-avatar-default-dark-24x24%402x.png";
export const DEFAULT_GRAVATAR_LINK_FALLBACK =
"/assets/images/icon-avatar-default-transparent-64x64%402x.png";
export const DEFAULT_GRAVATAR_LINK_DARK_FALLBACK =
"/assets/images/icon-avatar-default-dark-24x24%402x.png";
export const FREQUENCY_DROPDOWN_OPTIONS = [
{ value: 900, label: "Every 15 minutes" },
{ value: 3600, label: "Every hour" },
{ value: 21600, label: "Every 6 hours" },
{ value: 43200, label: "Every 12 hours" },
{ value: 86400, label: "Every day" },
{ value: 604800, label: "Every week" },
];
export const GITHUB_NEW_ISSUE_LINK =
"https://github.com/fleetdm/fleet/issues/new?assignees=&labels=bug%2C%3Areproduce&template=bug-report.md";
export const LOGGING_TYPE_OPTIONS = [
{ label: "Snapshot", value: "snapshot" },
{ label: "Differential", value: "differential" },
{
label: "Differential (ignore removals)",
value: "differential_ignore_removals",
},
];
export const MAX_OSQUERY_SCHEDULED_QUERY_INTERVAL = 604800;
export const MIN_OSQUERY_VERSION_OPTIONS = [
{ label: "All", value: "" },
{ label: "5.4.0 +", value: "5.4.0" },
{ label: "5.3.0 +", value: "5.3.0" },
{ label: "5.2.3 +", value: "5.2.4" },
{ label: "5.2.2 +", value: "5.2.2" },
{ label: "5.2.1 +", value: "5.2.1" },
{ label: "5.2.0 +", value: "5.2.0" },
{ label: "5.1.0 +", value: "5.1.0" },
{ label: "5.0.1 +", value: "5.0.1" },
{ label: "5.0.0 +", value: "5.0.0" },
{ label: "4.9.0 +", value: "4.9.0" },
{ label: "4.8.0 +", value: "4.8.0" },
{ label: "4.7.0 +", value: "4.7.0" },
{ label: "4.6.0 +", value: "4.6.0" },
{ label: "4.5.1 +", value: "4.5.1" },
{ label: "4.5.0 +", value: "4.5.0" },
{ label: "4.4.0 +", value: "4.4.0" },
{ label: "4.3.0 +", value: "4.3.0" },
{ label: "4.2.0 +", value: "4.2.0" },
{ label: "4.1.2 +", value: "4.1.2" },
{ label: "4.1.1 +", value: "4.1.1" },
{ label: "4.1.0 +", value: "4.1.0" },
{ label: "4.0.2 +", value: "4.0.2" },
{ label: "4.0.1 +", value: "4.0.1" },
{ label: "4.0.0 +", value: "4.0.0" },
{ label: "3.4.0 +", value: "3.4.0" },
{ label: "3.3.2 +", value: "3.3.2" },
{ label: "3.3.1 +", value: "3.3.1" },
{ label: "3.2.6 +", value: "3.2.6" },
{ label: "2.2.1 +", value: "2.2.1" },
{ label: "2.2.0 +", value: "2.2.0" },
{ label: "2.1.2 +", value: "2.1.2" },
{ label: "2.1.1 +", value: "2.1.1" },
{ label: "2.0.0 +", value: "2.0.0" },
{ label: "1.8.2 +", value: "1.8.2" },
{ label: "1.8.1 +", value: "1.8.1" },
];
export const QUERIES_PAGE_STEPS = {
1: "EDITOR",
2: "TARGETS",
3: "RUN",
};
export const DEFAULT_QUERY = {
description: "",
name: "",
query: "SELECT * FROM osquery_info;",
id: 0,
interval: 0,
last_excuted: "",
observer_can_run: false,
author_name: "",
updated_at: "",
created_at: "",
saved: false,
author_id: 0,
packs: [],
};
export const DEFAULT_CAMPAIGN = {
created_at: "",
errors: [],
hosts: [],
hosts_count: {
total: 0,
successful: 0,
failed: 0,
},
id: 0,
query_id: 0,
query_results: [],
status: "",
totals: {
count: 0,
missing_in_action: 0,
offline: 0,
online: 0,
},
updated_at: "",
user_id: 0,
};
export const DEFAULT_CAMPAIGN_STATE = {
observerShowSql: false,
queryIsRunning: false,
queryPosition: {},
queryResultsToggle: null,
runQueryMilliseconds: 0,
selectRelatedHostTarget: false,
targetsCount: 0,
targetsError: null,
campaign: { ...DEFAULT_CAMPAIGN },
};
export const PLATFORM_DISPLAY_NAMES: Record<string, IOsqueryPlatform> = {
darwin: "macOS",
linux: "Linux",
windows: "Windows",
};
// as returned by the TARGETS API; based on display_text
export const PLATFORM_LABEL_DISPLAY_NAMES: Record<string, string> = {
"All Hosts": "All hosts",
"All Linux": "Linux",
"CentOS Linux": "CentOS Linux",
macOS: "macOS",
"MS Windows": "Windows",
"Red Hat Linux": "Red Hat Linux",
"Ubuntu Linux": "Ubuntu Linux",
};
export const PLATFORM_LABEL_DISPLAY_ORDER = [
"macOS",
"All Linux",
"CentOS Linux",
"Red Hat Linux",
"Ubuntu Linux",
"MS Windows",
];
export const PLATFORM_LABEL_DISPLAY_TYPES: Record<string, string> = {
"All Hosts": "all",
"All Linux": "platform",
"CentOS Linux": "platform",
macOS: "platform",
"MS Windows": "platform",
"Red Hat Linux": "platform",
"Ubuntu Linux": "platform",
};
interface IPlatformDropdownOptions {
label: "All" | "Windows" | "Linux" | "macOS";
value: "all" | "windows" | "linux" | "darwin";
path: string;
}
export const PLATFORM_DROPDOWN_OPTIONS: IPlatformDropdownOptions[] = [
{ label: "All", value: "all", path: paths.DASHBOARD },
{ label: "Windows", value: "windows", path: paths.DASHBOARD_WINDOWS },
{ label: "Linux", value: "linux", path: paths.DASHBOARD_LINUX },
{ label: "macOS", value: "darwin", path: paths.DASHBOARD_MAC },
];
export const PLATFORM_NAME_TO_LABEL_NAME = {
all: "",
darwin: "macOS",
windows: "MS Windows",
linux: "All Linux",
};
export const HOSTS_SEARCH_BOX_PLACEHOLDER =
"Search name, hostname, UUID, serial number, or private IP address";
export const HOSTS_SEARCH_BOX_TOOLTIP =
"Search hosts by name, hostname, UUID, serial number, or private IP address";
export const VULNERABLE_DROPDOWN_OPTIONS = [
{
disabled: false,
label: "All software",
value: false,
helpText: "All software installed on your hosts.",
},
{
disabled: false,
label: "Vulnerable software",
value: true,
helpText:
"All software installed on your hosts with detected vulnerabilities.",
},
];
// Keys from API
export const MDM_STATUS_TOOLTIP: Record<string, string> = {
"On (automatic)": `<span>MDM was turned on automatically using Apple Automated Device Enrollment (DEP) or Windows Autopilot. Administrators can block end users from turning MDM off.</span>`,
"On (manual)": `<span>MDM was turned on manually. End users can turn MDM off.</span>`,
Off: `<span>Hosts with MDM off don&apos;t receive macOS <br /> settings and macOS update encouragement.</span>`,
Pending: `<span>Hosts ordered via Apple Business Manager <br /> (ABM). These will automatically enroll to Fleet <br /> and turn on MDM when they&apos;re unboxed.</span>`,
};
export const DEFAULT_CREATE_USER_ERRORS = {
email: "",
name: "",
password: "",
sso_enabled: null,
};
/** Must pass agent options config as empty object */
export const EMPTY_AGENT_OPTIONS = {
config: {},
};
export const DEFAULT_EMPTY_CELL_VALUE = "---";