From 1fede17b2a8f09dfc965e8c68c18d928ebec61f0 Mon Sep 17 00:00:00 2001 From: Sina Date: Fri, 9 Aug 2024 16:33:56 +0200 Subject: [PATCH] [hotfix] fix report-summary based on the API changes (#292) --- src/locales/de-DE/messages.po | 12 ++++++------ src/locales/en-US/messages.po | 12 ++++++------ src/pages/panel/security/OverallScore.tsx | 8 ++++---- src/pages/panel/security/Overview.tsx | 2 -- .../getWorkspaceInventoryReportSummary.query.ts | 8 -------- .../responses/GetWorkspaceInventoryReportSummary.ts | 4 ---- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/locales/de-DE/messages.po b/src/locales/de-DE/messages.po index 596f4a89..0a8e592b 100644 --- a/src/locales/de-DE/messages.po +++ b/src/locales/de-DE/messages.po @@ -254,7 +254,7 @@ msgstr "Konto: {0}" msgid "Accounts" msgstr "Konten" -#: src/pages/panel/security/Overview.tsx:104 +#: src/pages/panel/security/Overview.tsx:102 msgid "Accounts Summary" msgstr "Zusammenfassung der Konten" @@ -607,7 +607,7 @@ msgstr "Änderungen" msgid "Changes In {0}" msgstr "" -#: src/pages/panel/security/Overview.tsx:43 +#: src/pages/panel/security/Overview.tsx:42 msgid "Changes in the past 7 days" msgstr "Änderungen in den letzten 7 Tagen" @@ -1188,7 +1188,7 @@ msgstr "Das Änderungsprotokoll konnte nicht abgerufen werden" msgid "Failing benchmarks" msgstr "Fehlgeschlagene Benchmarks" -#: src/pages/panel/security/Overview.tsx:93 +#: src/pages/panel/security/Overview.tsx:91 msgid "Failing Check Timeline" msgstr "Fehler bei der Überprüfung des Zeitplans" @@ -2211,7 +2211,7 @@ msgstr "Sicherheitsscan" #: src/pages/panel/inventory/InventoryPage.tsx:47 #: src/pages/panel/security/Overview.tsx:29 -#: src/pages/panel/security/Overview.tsx:53 +#: src/pages/panel/security/Overview.tsx:52 msgid "Security Score" msgstr "Sicherheitsbewertung" @@ -2494,8 +2494,8 @@ msgstr "" msgid "Top Non-Compliant Resources" msgstr "Top Ressourcen mit Compliance-Verstößen" -#: src/pages/panel/security/Overview.tsx:63 -#: src/pages/panel/security/Overview.tsx:79 +#: src/pages/panel/security/Overview.tsx:61 +#: src/pages/panel/security/Overview.tsx:77 msgid "Top Security Enhancements" msgstr "Top-Sicherheitsverbesserungen" diff --git a/src/locales/en-US/messages.po b/src/locales/en-US/messages.po index 46e69996..dcb08d08 100644 --- a/src/locales/en-US/messages.po +++ b/src/locales/en-US/messages.po @@ -254,7 +254,7 @@ msgstr "Account: {0}" msgid "Accounts" msgstr "Accounts" -#: src/pages/panel/security/Overview.tsx:104 +#: src/pages/panel/security/Overview.tsx:102 msgid "Accounts Summary" msgstr "Accounts Summary" @@ -607,7 +607,7 @@ msgstr "Changes" msgid "Changes In {0}" msgstr "Changes In {0}" -#: src/pages/panel/security/Overview.tsx:43 +#: src/pages/panel/security/Overview.tsx:42 msgid "Changes in the past 7 days" msgstr "Changes in the past 7 days" @@ -1188,7 +1188,7 @@ msgstr "Failed to retrieve changelog" msgid "Failing benchmarks" msgstr "Failing benchmarks" -#: src/pages/panel/security/Overview.tsx:93 +#: src/pages/panel/security/Overview.tsx:91 msgid "Failing Check Timeline" msgstr "Failing Check Timeline" @@ -2211,7 +2211,7 @@ msgstr "Security Scan" #: src/pages/panel/inventory/InventoryPage.tsx:47 #: src/pages/panel/security/Overview.tsx:29 -#: src/pages/panel/security/Overview.tsx:53 +#: src/pages/panel/security/Overview.tsx:52 msgid "Security Score" msgstr "Security Score" @@ -2494,8 +2494,8 @@ msgstr "Token" msgid "Top Non-Compliant Resources" msgstr "Top Non-Compliant Resources" -#: src/pages/panel/security/Overview.tsx:63 -#: src/pages/panel/security/Overview.tsx:79 +#: src/pages/panel/security/Overview.tsx:61 +#: src/pages/panel/security/Overview.tsx:77 msgid "Top Security Enhancements" msgstr "Top Security Enhancements" diff --git a/src/pages/panel/security/OverallScore.tsx b/src/pages/panel/security/OverallScore.tsx index e0681288..9a5cdfcd 100644 --- a/src/pages/panel/security/OverallScore.tsx +++ b/src/pages/panel/security/OverallScore.tsx @@ -4,18 +4,18 @@ import { Stack, useTheme } from '@mui/material' import { useRef, useState } from 'react' import { PieResourceCheckScore, createInventorySearchTo } from 'src/pages/panel/shared/utils' import { useAbsoluteNavigate } from 'src/shared/absolute-navigate' +import { sortedSeverities } from 'src/shared/constants' import { FailedChecksType } from 'src/shared/types/server' import { numberToReadableNumber } from 'src/shared/utils/numberToReadable' import { wordToUFStr } from 'src/shared/utils/snakeCaseToUFStr' interface OverallScoreProps { score: number - failedChecks: Partial failedResources: Partial availableResources: number } -export const OverallScore = ({ score, failedChecks, failedResources, availableResources }: OverallScoreProps) => { +export const OverallScore = ({ score, failedResources, availableResources }: OverallScoreProps) => { const theme = useTheme() const navigate = useAbsoluteNavigate() const [showPieChart, setShowPieChart] = useState(false) @@ -50,13 +50,13 @@ export const OverallScore = ({ score, failedChecks, failedResources, availableRe return ( ({ + data={sortedSeverities.map((name) => ({ name: wordToUFStr(name), value: failedResources[name] ?? 0, label: typeof failedResources[name] === 'number' ? numberToReadableNumber({ value: failedResources[name] ?? 0, locale }) : undefined, description: - typeof failedResources[name] === 'number' && typeof value === 'number' + typeof failedResources[name] === 'number' && typeof failedResources[name] === 'number' ? t`${wordToUFStr(name).toString()}: We've identified ${failedResources[name].toLocaleString( locale, )} non-compliant resources out of ${availableResources.toLocaleString(locale)}.` diff --git a/src/pages/panel/security/Overview.tsx b/src/pages/panel/security/Overview.tsx index abd4a6fd..9206ca56 100644 --- a/src/pages/panel/security/Overview.tsx +++ b/src/pages/panel/security/Overview.tsx @@ -30,7 +30,6 @@ export const Overview = () => { @@ -54,7 +53,6 @@ export const Overview = () => { diff --git a/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts b/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts index 073902a9..ee631d35 100644 --- a/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts +++ b/src/pages/panel/shared/queries/getWorkspaceInventoryReportSummary.query.ts @@ -6,11 +6,7 @@ import { axiosWithAuth } from 'src/shared/utils/axios' const getDefaultValue = () => ({ account_check_summary: { - available_checks: 0, - failed_checks: 0, - failed_checks_by_severity: {}, available_resources: 0, - failed_resources: 0, failed_resources_by_severity: {}, }, accounts: [], @@ -28,11 +24,7 @@ const getDefaultValue = () => since: '', }, check_summary: { - available_checks: 0, - failed_checks: 0, - failed_checks_by_severity: {}, available_resources: 0, - failed_resources: 0, failed_resources_by_severity: {}, }, overall_score: 0, diff --git a/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts b/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts index f08b6bb5..3f19f52d 100644 --- a/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts +++ b/src/shared/types/server/responses/GetWorkspaceInventoryReportSummary.ts @@ -19,11 +19,7 @@ export type WorkspaceAccountReportSummary = { } export interface WorkspaceCheckSummary { - available_checks: number available_resources: number - failed_checks: number - failed_checks_by_severity: Partial - failed_resources: number failed_resources_by_severity: Partial }