From dab19c77d04cd49397ef1f1debcacb8eddbc0e63 Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Thu, 20 Jul 2023 12:43:09 -0400 Subject: [PATCH] Fleet UI: (Unreleased bug) When no platforms are selected, empty string platforms, show ALL platform icons in table and All in platform dropdown (#12865) --- .../QueriesTable/QueriesTableConfig.tsx | 23 +++++-------------- .../services/mock_service/mocks/responses.ts | 3 +-- frontend/utilities/constants.ts | 14 ++++++----- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTableConfig.tsx b/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTableConfig.tsx index 444edc55ae..eacbc5cfea 100644 --- a/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTableConfig.tsx +++ b/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTableConfig.tsx @@ -10,11 +10,7 @@ import permissionsUtils from "utilities/permissions"; import { IUser } from "interfaces/user"; import { secondsToDhms } from "utilities/helpers"; import { ISchedulableQuery } from "interfaces/schedulable_query"; -import { - SelectedPlatformString, - SupportedPlatform, - SUPPORTED_PLATFORMS, -} from "interfaces/platform"; +import { SupportedPlatform } from "interfaces/platform"; import Icon from "components/Icon"; import Checkbox from "components/forms/fields/Checkbox"; @@ -166,18 +162,11 @@ const generateTableHeaders = ({ accessor: "platforms", Cell: (cellProps: IPlatformCellProps): JSX.Element => { // translate the SelectedPlatformString into an array of `SupportedPlatform`s - const selectedPlatforms = - (cellProps.row.original.platform - ?.split(",") - .filter((platform) => platform !== "") as SupportedPlatform[]) ?? - []; - - const platformIconsToRender: SupportedPlatform[] = - selectedPlatforms.length === 0 - ? // User didn't select any platforms, so we render all compatible - cellProps.cell.value - : // Render the platforms the user has selected for this query - selectedPlatforms; + const platformIconsToRender = (cellProps.row.original.platform === "" + ? ["darwin", "windows", "linux", "chrome"] + : cellProps.row.original.platform + ?.split(",") + .filter((platform) => platform !== "")) as SupportedPlatform[]; return ; }, diff --git a/frontend/services/mock_service/mocks/responses.ts b/frontend/services/mock_service/mocks/responses.ts index 31edff807e..524a638ed2 100644 --- a/frontend/services/mock_service/mocks/responses.ts +++ b/frontend/services/mock_service/mocks/responses.ts @@ -486,7 +486,7 @@ const globalQueries = { query: "SELECT * FROM osquery_info", team_id: 2, interval: 604800, // Every week - platform: "Windows", + platform: "windows", min_osquery_version: "", automations_enabled: false, logging: "differential", @@ -563,7 +563,6 @@ const teamQueries = { total_executions: 1, }, performance: "Undetermined", - platforms: ["windows"], }, { created_at: "2023-06-08T15:31:35Z", diff --git a/frontend/utilities/constants.ts b/frontend/utilities/constants.ts index 06c13429aa..8034a9ba8a 100644 --- a/frontend/utilities/constants.ts +++ b/frontend/utilities/constants.ts @@ -201,8 +201,8 @@ export const PLATFORM_LABEL_DISPLAY_TYPES: Record = { interface IPlatformDropdownOptions { label: "All" | "Windows" | "Linux" | "macOS" | "ChromeOS"; - value: "all" | "windows" | "linux" | "darwin" | "chrome"; - path: string; + value: "all" | "windows" | "linux" | "darwin" | "chrome" | ""; + path?: string; } export const PLATFORM_DROPDOWN_OPTIONS: IPlatformDropdownOptions[] = [ { label: "All", value: "all", path: paths.DASHBOARD }, @@ -213,10 +213,12 @@ export const PLATFORM_DROPDOWN_OPTIONS: IPlatformDropdownOptions[] = [ ]; // Schedules does not support ChromeOS -export const SCHEDULE_PLATFORM_DROPDOWN_OPTIONS: IPlatformDropdownOptions[] = PLATFORM_DROPDOWN_OPTIONS.slice( - 0, - -1 -); +export const SCHEDULE_PLATFORM_DROPDOWN_OPTIONS: IPlatformDropdownOptions[] = [ + { label: "All", value: "" }, // API empty string runs on all platforms + { label: "macOS", value: "darwin" }, + { label: "Windows", value: "windows" }, + { label: "Linux", value: "linux" }, +]; export const PLATFORM_NAME_TO_LABEL_NAME = { all: "",