Skip to content

Commit

Permalink
fix(overall-score): fix typing problems
Browse files Browse the repository at this point in the history
  • Loading branch information
sijav committed Nov 29, 2023
1 parent c1fb64d commit 8e49180
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/pages/panel/home/OverallScore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { ToUFStr } from 'src/shared/utils/snakeCaseToUFStr'

interface OverallScoreProps {
score: number
failedChecks: FailedChecksType
failedResources: FailedChecksType
failedChecks: Partial<FailedChecksType>
failedResources: Partial<FailedChecksType>
availableResources: number
}

Expand Down Expand Up @@ -48,11 +48,13 @@ export const OverallScore = ({ score, failedChecks, failedResources, availableRe
<PieResourceCheckScore
data={Object.entries(failedChecks).map(([name, value]) => ({
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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export const getWorkspaceInventoryReportSummaryQuery = ({
.get<GetWorkspaceInventoryReportSummaryResponse>(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: {
Expand All @@ -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: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ChangedSitatuation {
since: string
accounts_selection: string[]
resource_count_by_kind_selection: Record<string, number>
resource_count_by_severity: FailedChecksType
resource_count_by_severity: Partial<FailedChecksType>
}

export type WorkspaceAccountReportSummary = {
Expand All @@ -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<FailedChecksType>
failed_resources: number
failed_resources_by_severity: FailedChecksType
failed_resources_by_severity: Partial<FailedChecksType>
}

export interface GetWorkspaceInventoryReportSummaryResponse {
Expand Down

0 comments on commit 8e49180

Please sign in to comment.