Skip to content

Commit

Permalink
[hotfix] fix report-summary based on the API changes (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
sijav authored Aug 9, 2024
1 parent 24285a1 commit 1fede17
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 30 deletions.
12 changes: 6 additions & 6 deletions src/locales/de-DE/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down
12 changes: 6 additions & 6 deletions src/locales/en-US/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions src/pages/panel/security/OverallScore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<FailedChecksType>
failedResources: Partial<FailedChecksType>
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)
Expand Down Expand Up @@ -50,13 +50,13 @@ export const OverallScore = ({ score, failedChecks, failedResources, availableRe
return (
<Stack mb={4} direction="row" justifyContent="center">
<PieResourceCheckScore
data={Object.entries(failedChecks).map(([name, value]) => ({
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)}.`
Expand Down
2 changes: 0 additions & 2 deletions src/pages/panel/security/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const Overview = () => {
</Typography>
<OverallScore
score={data.overall_score}
failedChecks={data.check_summary.failed_checks_by_severity}
failedResources={data.check_summary.failed_resources_by_severity}
availableResources={data.check_summary.available_resources}
/>
Expand All @@ -54,7 +53,6 @@ export const Overview = () => {
</Typography>
<OverallScore
score={data.overall_score}
failedChecks={data.check_summary.failed_checks_by_severity}
failedResources={data.check_summary.failed_resources_by_severity}
availableResources={data.check_summary.available_resources}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export type WorkspaceAccountReportSummary = {
}

export interface WorkspaceCheckSummary {
available_checks: number
available_resources: number
failed_checks: number
failed_checks_by_severity: Partial<FailedChecksType>
failed_resources: number
failed_resources_by_severity: Partial<FailedChecksType>
}

Expand Down

0 comments on commit 1fede17

Please sign in to comment.