Fleet UI: (Unreleased bug) When no platforms are selected, empty string platforms, show ALL platform icons in table and All in platform dropdown (#12865)

This commit is contained in:
RachelElysia 2023-07-20 12:43:09 -04:00 committed by GitHub
parent 27a1bfd805
commit dab19c77d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 25 deletions

View file

@ -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 <PlatformCell platforms={platformIconsToRender} />;
},

View file

@ -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",

View file

@ -201,8 +201,8 @@ export const PLATFORM_LABEL_DISPLAY_TYPES: Record<string, string> = {
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: "",