Skip to content

Commit

Permalink
Merge pull request #808 from akto-api-security/hotfix/null_check_for_…
Browse files Browse the repository at this point in the history
…empty_collection

Fixes made for null check
  • Loading branch information
ayushaga14 authored Jan 11, 2024
2 parents 26e3828 + 8d9739c commit c6e9a22
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { useRef } from "react";
function DonutChart({data, title, size}) {
const chartComponentRef = useRef(null)

const seriesData = Object.keys(data).map((ele)=>{
return{
name: ele,
y: data[ele].text,
color: data[ele].color,
}
})
let seriesData = []
if(data && Object.keys(data).length > 0){
seriesData = Object.keys(data).map((ele)=>{
return{
name: ele,
y: data[ele].text,
color: data[ele].color,
}
})
}

const chartOptions = {
chart:{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function HomeDashboard() {
</VerticalStack>
</Card>

: <NullData text={"Issues by category"} url={"/dashboard/observe/inventory/1111111111"} urlText={"to run a test."} description={"No test categories found."} key={"subcategoryTrend"}/>
: <NullData text={"Issues by category"} url={"/dashboard/observe/inventory"} urlText={"to run a test on a collection."} description={"No test categories found."} key={"subcategoryTrend"}/>
)

const riskScoreRanges = [
Expand All @@ -157,6 +157,8 @@ function HomeDashboard() {
]

const riskScoreTrendComp = (
(Object.keys(riskScoreRangeMap).length === 0) ? <NullData text={"APIS by risk score"} url={"/dashboard/observe/inventory"} urlText={"to create a collection and upload traffic in it."} description={"No apis found."} key={"riskScoreNullTrend"}/>
:
<Card key="scoreTrend">
<VerticalStack gap={5}>
<Text variant="bodyLg" fontWeight="semibold">APIS by risk score</Text>
Expand Down Expand Up @@ -187,6 +189,9 @@ function HomeDashboard() {
)

const sensitiveDataTrendComp = (
(!sensitiveData || (!(sensitiveData.request) && !(sensitiveData.response))) ?
<NullData text={"Sensitive Data"} url={"/dashboard/observe/inventory"} urlText={"to create a collection and upload traffic in it."} description={"No sensitive data found."} key={"sensitiveNullTrend"}/>
:
<Card key="sensitiveTrend">
<VerticalStack gap={5}>
<Text variant="bodyLg" fontWeight="semibold">Sensitive Data</Text>
Expand Down Expand Up @@ -238,7 +243,7 @@ function HomeDashboard() {
</VerticalStack>
</VerticalStack>
</Card>
: <NullData text={"Issues timeline."} url={"/dashboard/observe/inventory/1111111111"} urlText={"to run a test."} description={"No issues found."} key={"issuesTrend"}/>
: <NullData text={"Issues timeline."} url={"/dashboard/observe/inventory"} urlText={"to run a test on a collection."} description={"No issues found."} key={"issuesTrend"}/>
)

const checkLoadMore = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ import ConcentricCirclesChart from '../../../components/shared/ConcentricCircles
function ChartypeComponent({data, title,charTitle, chartSubtitle, reverse, isNormal, boxHeight}) {
const maxBoxHeight = boxHeight || '200px'
let tableRows = []
Object.keys(data).forEach((key,index)=>{
let comp = [
(
<Box width='22vw'>
<div style={{display: "flex", gap: "8px", alignItems: "center"}} key={index}>
<span style={{background: data[key]?.color, borderRadius: "50%", width: "8px", height: "8px"}} />
<Text>{key}</Text>
</div>
</Box>
),
<Text>{data[key]?.text}</Text>
]
tableRows.push(comp)
})
if(data && Object.keys(data).length > 0)
{
Object.keys(data).forEach((key,index)=>{
let comp = [
(
<Box width='22vw'>
<div style={{display: "flex", gap: "8px", alignItems: "center"}} key={index}>
<span style={{background: data[key]?.color, borderRadius: "50%", width: "8px", height: "8px"}} />
<Text>{key}</Text>
</div>
</Box>
),
<Text>{data[key]?.text}</Text>
]
tableRows.push(comp)
})
}

const chartData = reverse ? Object.keys(data).reverse().reduce((acc, key) => {
acc[key] = data[key];
Expand Down

0 comments on commit c6e9a22

Please sign in to comment.