From 746a254362d375ef7cc734fa3b63bade5177dc59 Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Tue, 26 Mar 2024 16:38:53 +0000 Subject: [PATCH] fix ui bug for showing os updates table with no team (#17862) quick fix to correctly show the os versions for "no teams" on os updates page **before:** image **after:** image - [x] Manual QA for all new/changed functionality --- .../CurrentVersionSection.tsx | 9 +++++---- .../CurrentVersionSection/_styles.scss | 4 ++++ frontend/services/entities/operating_systems.ts | 17 ++++++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/CurrentVersionSection.tsx b/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/CurrentVersionSection.tsx index 6253acf923..a77aec7b04 100644 --- a/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/CurrentVersionSection.tsx +++ b/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/CurrentVersionSection.tsx @@ -55,20 +55,21 @@ const CurrentVersionSection = ({ ); }; - if (!data) { - return null; - } - const renderTable = () => { if (isError) { return ( ); } + if (!data) { + return null; + } + if (!data.os_versions) { return ; } diff --git a/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/_styles.scss b/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/_styles.scss index 41163be448..4fd04a2e4f 100644 --- a/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/_styles.scss +++ b/frontend/pages/ManageControlsPage/OSUpdates/components/CurrentVersionSection/_styles.scss @@ -15,4 +15,8 @@ font-size: 18px; } } + + &__error { + padding: $pad-xxlarge; + } } diff --git a/frontend/services/entities/operating_systems.ts b/frontend/services/entities/operating_systems.ts index f58d666048..29ba06b141 100644 --- a/frontend/services/entities/operating_systems.ts +++ b/frontend/services/entities/operating_systems.ts @@ -4,6 +4,7 @@ import endpoints from "utilities/endpoints"; import { IOperatingSystemVersion } from "interfaces/operating_system"; import { OsqueryPlatform } from "interfaces/platform"; import { buildQueryStringFromParams } from "utilities/url"; +import { API_NO_TEAM_ID } from "interfaces/team"; // TODO: add platforms to this constant as new ones are supported export const OS_VERSIONS_API_SUPPORTED_PLATFORMS = [ @@ -49,6 +50,11 @@ export interface IOSVersionResponse { os_version: IOperatingSystemVersion; } +type IGetOSVersionsRequestQueryParams = Record< + string, + string | number | undefined +>; + export const getOSVersions = ({ platform, teamId, @@ -62,16 +68,21 @@ export const getOSVersions = ({ const { OS_VERSIONS } = endpoints; let path = OS_VERSIONS; - const queryString = buildQueryStringFromParams({ + const params: IGetOSVersionsRequestQueryParams = { platform, - team_id: teamId, os_name, os_version, order_key, order_direction, page, per_page, - }); + }; + + if (teamId !== API_NO_TEAM_ID) { + params.team_id = teamId; + } + + const queryString = buildQueryStringFromParams(params); if (queryString) path += `?${queryString}`;