diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/SummaryInfo.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/SummaryInfo.jsx index efc03ca740..87aaefe824 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/SummaryInfo.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/SummaryInfo.jsx @@ -57,7 +57,7 @@ const SummaryInfo = ({ startTimestamp, endTimestamp }) => { smoothChartComponent: () }, { - title: 'High', + title: 'Critical', data: criticalIssues[criticalIssues.length-1], variant: 'heading2xl', color: 'critical', diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestRunsPage.js b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestRunsPage.js index 2e9d70171d..f1a7c2be95 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestRunsPage.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestRunsPage.js @@ -2,6 +2,7 @@ import GithubServerTable from "../../../components/tables/GithubServerTable"; import {Text,IndexFiltersMode, LegacyCard, HorizontalStack, Button, Collapsible, HorizontalGrid, Box, Divider} from '@shopify/polaris'; import { ChevronDownMinor , ChevronUpMinor } from '@shopify/polaris-icons'; import api from "../api"; +import testingApi from "../../testing/api"; import { useEffect, useReducer, useState } from 'react'; import transform from "../transform"; import PageWithMultipleCards from "../../../components/layouts/PageWithMultipleCards"; @@ -148,12 +149,7 @@ const [selected, setSelected] = useState(initialTabIdx) const tableCountObj = func.getTabsCount(definedTableTabs, {}, initialCount) const tableTabs = func.getTableTabsContent(definedTableTabs, tableCountObj, setCurrentTab, currentTab, tabsInfo) -const [severityCountMap, setSeverityCountMap] = useState({ - CRITICAL: {text : 0, color: func.getHexColorForSeverity("CRITICAL")}, - HIGH: {text : 0, color: func.getHexColorForSeverity("HIGH")}, - MEDIUM: {text : 0, color: func.getHexColorForSeverity("MEDIUM")}, - LOW: {text : 0, color: func.getHexColorForSeverity("LOW")}, -}) +const [severityMap, setSeverityMap] = useState({}) const [subCategoryInfo, setSubCategoryInfo] = useState({}) const [collapsible, setCollapsible] = useState(true) const [hasUserInitiatedTestRuns, setHasUserInitiatedTestRuns] = useState(false) @@ -249,12 +245,43 @@ function processData(testingRuns, latestTestingRunResultSummaries, cicd){ await api.getSummaryInfo(startTimestamp, endTimestamp).then((resp)=>{ const severityObj = transform.convertSubIntoSubcategory(resp) setSubCategoryInfo(severityObj.subCategoryMap) - const severityMap = severityObj.countMap; - let tempMap = JSON.parse(JSON.stringify(severityCountMap)) - Object.keys(tempMap).forEach((key) => { - tempMap[key].text = severityMap[key] - }) - setSeverityCountMap(tempMap) + }) + await testingApi.fetchSeverityInfoForIssues({}, [], 0).then(({ severityInfo }) => { + const countMap = { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 } + + if (severityInfo && severityInfo != undefined && severityInfo != null && severityInfo instanceof Object) { + for (const apiCollectionId in severityInfo) { + let temp = severityInfo[apiCollectionId] + for (const key in temp) { + countMap[key] += temp[key] + } + } + } + + const result = { + "CRITICAL": { + "text": countMap.CRITICAL || 0, + "color": func.getHexColorForSeverity("CRITICAL"), + "filterKey": "Critical" + }, + "HIGH": { + "text": countMap.HIGH || 0, + "color": func.getHexColorForSeverity("HIGH"), + "filterKey": "High" + }, + "MEDIUM": { + "text": countMap.MEDIUM || 0, + "color": func.getHexColorForSeverity("MEDIUM"), + "filterKey": "Medium" + }, + "LOW": { + "text": countMap.LOW || 0, + "color": func.getHexColorForSeverity("LOW"), + "filterKey": "Low" + } + } + + setSeverityMap(result) }) } @@ -282,7 +309,7 @@ function processData(testingRuns, latestTestingRunResultSummaries, cicd){ const iconSource = collapsible ? ChevronUpMinor : ChevronDownMinor const SummaryCardComponent = () =>{ - let totalVulnerabilities = severityCountMap?.HIGH?.text + severityCountMap?.MEDIUM?.text + severityCountMap?.LOW?.text + let totalVulnerabilities = severityMap?.CRITICAL?.text + severityMap?.HIGH?.text + severityMap?.MEDIUM?.text + severityMap?.LOW?.text return( Vulnerabilities}> @@ -296,9 +323,8 @@ const SummaryCardComponent = () =>{ - {/* */}