Skip to content

Commit

Permalink
Interface cleanup, casing bug, hook up os_versions API call, show os …
Browse files Browse the repository at this point in the history
…settings modal
  • Loading branch information
RachelElysia committed Jul 3, 2024
1 parent d6d5a86 commit 96af97f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classnames from "classnames";
import {
ColumnType,
IQueryTableColumn,
TableSchemaPlatforms,
TableSchemaPlatform,
} from "interfaces/osquery_table";
import TooltipWrapper from "components/TooltipWrapper";
import { buildQueryStringFromParams } from "utilities/url";
Expand Down Expand Up @@ -58,7 +58,7 @@ const renderTooltip = (
);
};

const renderPlatformFootnotes = (columnPlatforms: TableSchemaPlatforms[]) => {
const renderPlatformFootnotes = (columnPlatforms: TableSchemaPlatform[]) => {
let platformsCopy;
switch (columnPlatforms.length) {
case 1:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from "react";

import { SupportedDisplayPlatform } from "interfaces/platform";
import { PLATFORM_DISPLAY_NAMES } from "utilities/constants";
import Icon from "components/Icon";
import { TableSchemaPlatforms } from "interfaces/osquery_table";
import { TableSchemaPlatform } from "interfaces/osquery_table";

interface IPLatformListItemProps {
platform: SupportedDisplayPlatform;
platform: TableSchemaPlatform;
}

const baseClassListItem = "platform-list-item";
Expand All @@ -21,7 +20,7 @@ const PlatformListItem = ({ platform }: IPLatformListItemProps) => {
};

// TODO: remove when freebsd is removed
type IPlatformsWithFreebsd = TableSchemaPlatforms | "freebsd";
type IPlatformsWithFreebsd = TableSchemaPlatform | "freebsd";

interface IQueryTablePlatformsProps {
platforms: IPlatformsWithFreebsd[];
Expand All @@ -39,7 +38,7 @@ const QueryTablePlatforms = ({ platforms }: IQueryTablePlatformsProps) => {
return (
<PlatformListItem
key={platform}
platform={platform as SupportedDisplayPlatform} // TODO: remove when freebsd is removed
platform={platform as TableSchemaPlatform} // TODO: remove when freebsd is removed
/>
);
});
Expand Down
6 changes: 3 additions & 3 deletions frontend/interfaces/osquery_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ export type ColumnType =
| "string"; // TODO: Why do we have type string, STRING, and text in schema.json?

// TODO: Replace with one or the other once osquery_fleet_schema.json follows one type or other
export type TableSchemaPlatforms = SupportedDisplayPlatform | SupportedPlatform;
export type TableSchemaPlatform = SupportedDisplayPlatform | SupportedPlatform;
export interface IQueryTableColumn {
name: string;
description: string;
type: ColumnType;
hidden: boolean;
required: boolean;
index: boolean;
platforms?: TableSchemaPlatforms[];
platforms?: TableSchemaPlatform[];
requires_user_context?: boolean;
}

export interface IOsQueryTable {
name: string;
description: string;
url: string;
platforms: TableSchemaPlatforms[];
platforms: TableSchemaPlatform[];
evented: boolean;
cacheable: boolean;
columns: IQueryTableColumn[];
Expand Down
3 changes: 1 addition & 2 deletions frontend/pages/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
IMdmSummaryResponse,
IMdmSummaryMdmSolution,
} from "interfaces/mdm";
import { Platform, SelectedPlatform } from "interfaces/platform";
import { ISoftwareResponse, ISoftwareCountResponse } from "interfaces/software";
import { API_ALL_TEAMS_ID, ITeam } from "interfaces/team";
import { IConfig } from "interfaces/config";
Expand Down Expand Up @@ -886,7 +885,7 @@ const DashboardPage = ({ router, location }: IDashboardProps): JSX.Element => {
className={`${baseClass}__platform_dropdown`}
options={PLATFORM_DROPDOWN_OPTIONS}
searchable={false}
onChange={(value: SelectedPlatform) => {
onChange={(value: PlatformValueOptions) => {
const selectedPlatformOption = PLATFORM_DROPDOWN_OPTIONS.find(
(platform) => platform.value === value
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export const generateTableData = (
return makeWindowsRows(hostMDMData);
case "darwin":
return makeDarwinRows(hostMDMData);
case "ios":
return hostMDMData.profiles;
case "ipados":
return hostMDMData.profiles;
default:
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/services/entities/operating_systems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const OS_VERSIONS_API_SUPPORTED_PLATFORMS = [
"darwin",
"windows",
"chrome",
"ios",
"ipados",
];

export interface IGetOSVersionsQueryParams {
Expand Down
6 changes: 3 additions & 3 deletions frontend/utilities/sql_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import {
SUPPORTED_PLATFORMS,
SupportedPlatform,
} from "interfaces/platform";
import { TableSchemaPlatforms } from "interfaces/osquery_table";
import { TableSchemaPlatform } from "interfaces/osquery_table";

type IAstNode = Record<string | number | symbol, unknown>;

// TODO: Research if there are any preexisting types for osquery schema
// TODO: Is it ever possible that osquery_tables.json would be missing name or platforms?
interface IOsqueryTable {
name: string;
platforms: TableSchemaPlatforms[];
platforms: TableSchemaPlatform[];
}

type IPlatformDictionary = Record<string, TableSchemaPlatforms[]>;
type IPlatformDictionary = Record<string, TableSchemaPlatform[]>;

const platformsByTableDictionary: IPlatformDictionary = (osqueryTablesAvailable as IOsqueryTable[]).reduce(
(dictionary: IPlatformDictionary, osqueryTable) => {
Expand Down
4 changes: 3 additions & 1 deletion frontend/utilities/strings/stringUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const capitalizeRole = (str: UserRole): UserRole => {

export const STYLIZATIONS_AND_ACRONYMS = [
"macOS",
"iOS",
"iPadOS",
"osquery",
"MySQL",
"MDM",
Expand All @@ -29,7 +31,7 @@ export const STYLIZATIONS_AND_ACRONYMS = [
];

// fleetdm.com/handbook/marketing/content-style-guide#sentence-case
// * doesn't recognize proper nouns!
/** Does not recognize proper nouns! */
export const enforceFleetSentenceCasing = (s: string) => {
const resArr = s.split(" ").map((word, i) => {
if (!STYLIZATIONS_AND_ACRONYMS.includes(word)) {
Expand Down

0 comments on commit 96af97f

Please sign in to comment.