From 8e49180d742d40900ce60f895abb99f984ec16c1 Mon Sep 17 00:00:00 2001 From: Sina Javaheri Date: Wed, 29 Nov 2023 17:55:44 +0100 Subject: [PATCH] fix(overall-score): fix typing problems --- src/pages/panel/home/OverallScore.tsx | 12 +++++++----- .../getWorkspaceInventoryReportSummary.query.ts | 11 +++++++++++ .../responses/GetWorkspaceInventoryReportSummary.ts | 6 +++--- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/pages/panel/home/OverallScore.tsx b/src/pages/panel/home/OverallScore.tsx index d0aeea49..c4867bc8 100644 --- a/src/pages/panel/home/OverallScore.tsx +++ b/src/pages/panel/home/OverallScore.tsx @@ -9,8 +9,8 @@ import { ToUFStr } from 'src/shared/utils/snakeCaseToUFStr' interface OverallScoreProps { score: number - failedChecks: FailedChecksType - failedResources: FailedChecksType + failedChecks: Partial + failedResources: Partial availableResources: number } @@ -48,11 +48,13 @@ export const OverallScore = ({ score, failedChecks, failedResources, availableRe ({ name: ToUFStr(name), - value: value, - label: typeof failedResources[name] === 'number' ? numberToShortHRT(failedResources[name]) : numberToShortHRT(value), + value: value ?? 0, + label: typeof failedResources[name] === 'number' ? numberToShortHRT(failedResources[name] ?? 0) : numberToShortHRT(value ?? 0), description: t`We've identified ${failedResources[ name - ]?.toLocaleString()} non-compliant resources out of ${availableResources.toLocaleString()} through ${value.toString()} ${name.toString()}-severity security checks.`, + ]?.toLocaleString()} non-compliant resources out of ${availableResources.toLocaleString()} through ${ + value?.toString() ?? 0 + } ${name.toString()}-severity security checks.`, onClick: () => navigate(createInventorySearchTo(`/security.has_issues=true and /security.severity=${name}`)), }))} hidingPieChart={hidingPieChart} diff --git a/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts b/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts index 759ac97c..74ba4b60 100644 --- a/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts +++ b/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts @@ -12,6 +12,14 @@ export const getWorkspaceInventoryReportSummaryQuery = ({ .get(endPoints.workspaces.workspace(workspaceId).inventory.reportSummary, { signal }) .then((res) => res.data) : ({ + account_check_summary: { + available_checks: 0, + failed_checks: 0, + failed_checks_by_severity: {}, + available_resources: 0, + failed_resources: 0, + failed_resources_by_severity: {}, + }, accounts: [], benchmarks: [], changed_compliant: { @@ -30,6 +38,9 @@ export const getWorkspaceInventoryReportSummaryQuery = ({ available_checks: 0, failed_checks: 0, failed_checks_by_severity: {}, + available_resources: 0, + failed_resources: 0, + failed_resources_by_severity: {}, }, overall_score: 0, top_checks: [], diff --git a/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts b/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts index c04cd708..2017ecce 100644 --- a/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts +++ b/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts @@ -24,7 +24,7 @@ export interface ChangedSitatuation { since: string accounts_selection: string[] resource_count_by_kind_selection: Record - resource_count_by_severity: FailedChecksType + resource_count_by_severity: Partial } export type WorkspaceAccountReportSummary = { @@ -39,9 +39,9 @@ export interface WorkspaceCheckSummary { available_checks: number available_resources: number failed_checks: number - failed_checks_by_severity: FailedChecksType + failed_checks_by_severity: Partial failed_resources: number - failed_resources_by_severity: FailedChecksType + failed_resources_by_severity: Partial } export interface GetWorkspaceInventoryReportSummaryResponse {