Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pending todo #2164

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export interface ReactEChartsProps {
style?: CSSProperties;
settings?: SetOptionOpts;
loading?: boolean;
theme?: Mode; // TODO: Remove theme prop
onChartClick?: (data: {
name: string;
value: string | number | Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,14 @@ const ToggleControl = ({
nodeId,
nodeType,
checkType,
fetcher,
}: {
checked: boolean;
controlId: string[];
nodeId: string;
nodeType: string;
checkType: string;
fetcher: FetcherWithComponents<ControlActionDta>;
}) => {
// TODO: should show loader indicator here
const fetcher = useFetcher();
if (fetcher.state !== 'idle') {
return <CircleSpinner size="sm" />;
}
Expand Down Expand Up @@ -340,14 +338,14 @@ const ControlTable = ({
cell: (info) => {
return (
<ToggleControl
key={info.row.original?.control_id}
nodeId={nodeIds[0]}
nodeType={_nodeType}
checkType={selectedTab.toLowerCase()}
checked={!!info.row.original.enabled}
controlId={
info.row.original?.control_id ? [info.row.original.control_id] : ['']
}
fetcher={fetcher}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const getSeverityChartInnerColorMap = (theme: Mode) => {
};
};

// TODO: take theme into account
export function getColorForCVSSScore(theme: Mode, score: number | undefined): string {
const color = colors[theme === 'light' ? 'variables' : 'darkVariables'].DEFAULT;
if (!score) return color['df-gray']['600'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const TopRisksContent = ({
<div className="flex-1 flex flex-col items-center py-1.5">
<div className="max-w-[162px] max-h-[162px] h-[162px] w-[162px]">
<ReactECharts
theme="dark"
option={chartOptions}
onChartClick={({ name }: { name: string; value: string | number | Date }) => {
navigate(`${to}?severity=${name.toLowerCase()}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ const DummyDonutChart = () => {
},
],
};
return <ReactECharts theme={mode} option={option} />;
return <ReactECharts option={option} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ const action = async ({ request, params }: ActionFunctionArgs): Promise<ActionDa
_filters.fields_filters.contains_filter.filter_in = newFilter;
}

/**
* this filter may not be needed anymore
*/
if (intervalFilter) {
// TODO Add filters
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ const TopNCardContent = ({ type }: { type: 'host' | 'container' | 'image' }) =>
<div className="pb-2 h-[300px] flex items-center justify-center">
{data.length ? (
<ReactECharts
theme="dark"
option={chartOptions}
onChartClick={({ id }: { id?: string }) => {
if (!id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ export const MalwareScanResultsPieChart = ({
return null;
}
const options = getChartOptions({ data, theme: mode });
return <ReactECharts theme="dark" option={options} onChartClick={onChartClick} />;
return <ReactECharts option={options} onChartClick={onChartClick} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ const CardContent = ({ data, to }: { data: MalwaresCountsCardData; to: string })
<div className="flex-1 flex flex-col items-center min-h-[180px]">
<div className="h-[180px] w-[180px]">
<ReactECharts
theme={mode}
option={chartOptions}
onChartClick={({ name }: { name: string; value: string | number | Date }) => {
navigate(`${to}?severity=${name.toLowerCase()}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ export const PostureScanResultsPieChart = ({
return null;
}
const options = getChartOptions({ data, theme: mode });
return <ReactECharts theme="dark" option={options} onChartClick={onChartClick} />;
return <ReactECharts option={options} onChartClick={onChartClick} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ const CardContent = ({ data, to }: { data: SecretsCountsCardData; to: string })
<div className="flex-1 flex flex-col items-center min-h-[180px]">
<div className="h-[180px] w-[180px]">
<ReactECharts
theme={mode}
option={chartOptions}
onChartClick={({ name }: { name: string; value: string | number | Date }) => {
navigate(`${to}?severity=${name.toLowerCase()}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ const TopNCardContent = ({ type }: { type: 'host' | 'container' | 'image' }) =>
<div className="pb-2 h-[300px] flex items-center justify-center">
{data.length ? (
<ReactECharts
theme="dark"
option={chartOptions}
onChartClick={({ id }: { id?: string }) => {
if (!id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ export const SecretScanResultsPieChart = ({
return null;
}
const options = getChartOptions({ data, theme: mode });
return <ReactECharts theme="dark" option={options} onChartClick={onChartClick} />;
return <ReactECharts option={options} onChartClick={onChartClick} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ export const AvailabilityCharts = ({
<div className="flex flex-col justify-center">
<div className="h-[220px]">
{cpuMax ? (
<ReactECharts
theme="dark"
option={getChartOption(mode, cpuUsage, cpuMax, 'cpu')}
/>
<ReactECharts option={getChartOption(mode, cpuUsage, cpuMax, 'cpu')} />
) : (
<div className="flex items-center justify-center h-full w-full gap-2">
<div className="h-6 w-6 shrink-0 text-text-icon">
Expand All @@ -139,7 +136,6 @@ export const AvailabilityCharts = ({
<div className="h-[220px]">
{memoryMax ? (
<ReactECharts
theme="dark"
option={getChartOption(mode, memoryUsage, memoryMax, 'memory')}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ export const VulnerabilityScanResultsPieChart = ({
return null;
}
const options = getChartOptions({ data, theme: mode });
return <ReactECharts theme="dark" option={options} onChartClick={onChartClick} />;
return <ReactECharts option={options} onChartClick={onChartClick} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ const TopNCardContent = ({ type }: { type: 'host' | 'container' | 'image' }) =>
<div className="px-2 h-[300px] flex items-center justify-center">
{data.length ? (
<ReactECharts
theme="dark"
option={chartOptions}
onChartClick={({ id }: { id?: string }) => {
if (!id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ const CardContent = ({
<div className="flex-1 flex flex-col items-center min-h-[180px] ">
<div className="h-[180px] w-[180px]">
<ReactECharts
theme={mode}
option={chartOptions}
onChartClick={({ name }: { name: string; value: string | number | Date }) => {
navigate(`${to}?severity=${name.toLowerCase()}`);
Expand Down
35 changes: 5 additions & 30 deletions deepfence_frontend/apps/dashboard/src/queries/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,8 @@ export const commonQueries = createQueryKeys('common', {
throw response.error;
}

if (response.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting host filters');
}

return {
data: response.value.possible_values?.slice(0, size) || [],
data: response.value?.possible_values?.slice(0, size) || [],
};
},
};
Expand Down Expand Up @@ -167,13 +162,8 @@ export const commonQueries = createQueryKeys('common', {
throw response.error;
}

if (response.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting completion pods info');
}

return {
data: response.value.possible_values?.slice(0, size) || [],
data: response.value?.possible_values?.slice(0, size) || [],
};
},
};
Expand Down Expand Up @@ -208,13 +198,8 @@ export const commonQueries = createQueryKeys('common', {
throw response.error;
}

if (response.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting completion containers info');
}

return {
data: response.value.possible_values?.slice(0, size) || [],
data: response.value?.possible_values?.slice(0, size) || [],
};
},
};
Expand Down Expand Up @@ -251,13 +236,8 @@ export const commonQueries = createQueryKeys('common', {
throw response.error;
}

if (response.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting test number filters');
}

return {
data: response.value.possible_values?.slice(0, size) || [],
data: response.value?.possible_values?.slice(0, size) || [],
};
},
};
Expand Down Expand Up @@ -294,13 +274,8 @@ export const commonQueries = createQueryKeys('common', {
throw response.error;
}

if (response.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting control filters');
}

return {
data: response.value.possible_values?.slice(0, size) || [],
data: response.value?.possible_values?.slice(0, size) || [],
};
},
};
Expand Down
33 changes: 11 additions & 22 deletions deepfence_frontend/apps/dashboard/src/queries/malware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,8 @@ export const malwareQueries = createQueryKeys('malware', {
throw resultMalwareScanResponse.error;
}

if (resultMalwareScanResponse.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting scan results');
}
const totalSeverity = Object.values(
resultMalwareScanResponse.value.severity_counts ?? {},
resultMalwareScanResponse.value?.severity_counts ?? {},
).reduce((acc, value) => {
acc = acc + value;
return acc;
Expand All @@ -491,14 +487,14 @@ export const malwareQueries = createQueryKeys('malware', {
totalSeverity,
severityCounts: {
critical:
resultMalwareScanResponse.value.severity_counts?.['critical'] ?? 0,
high: resultMalwareScanResponse.value.severity_counts?.['high'] ?? 0,
medium: resultMalwareScanResponse.value.severity_counts?.['medium'] ?? 0,
low: resultMalwareScanResponse.value.severity_counts?.['low'] ?? 0,
unknown: resultMalwareScanResponse.value.severity_counts?.['unknown'] ?? 0,
resultMalwareScanResponse.value?.severity_counts?.['critical'] ?? 0,
high: resultMalwareScanResponse.value?.severity_counts?.['high'] ?? 0,
medium: resultMalwareScanResponse.value?.severity_counts?.['medium'] ?? 0,
low: resultMalwareScanResponse.value?.severity_counts?.['low'] ?? 0,
unknown: resultMalwareScanResponse.value?.severity_counts?.['unknown'] ?? 0,
},
tableData: resultMalwareScanResponse.value.malwares ?? [],
dockerImageName: resultMalwareScanResponse.value.docker_image_name,
tableData: resultMalwareScanResponse.value?.malwares ?? [],
dockerImageName: resultMalwareScanResponse.value?.docker_image_name ?? '',
pagination: {
currentPage: page,
totalRows: page * pageSize + resultCounts.value.count,
Expand Down Expand Up @@ -576,13 +572,8 @@ export const malwareQueries = createQueryKeys('malware', {
throw resultMalwareScanResponse.error;
}

if (resultMalwareScanResponse.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting scan results');
}

return {
data: resultMalwareScanResponse.value.malwares,
data: resultMalwareScanResponse.value?.malwares ?? [],
};
},
};
Expand Down Expand Up @@ -770,8 +761,7 @@ export const malwareQueries = createQueryKeys('malware', {
});

if (!uniqueMalwareCounts.ok) {
// TODO handle error
return defaultResults;
throw new Error('Error getting unique malware counts');
}

return {
Expand Down Expand Up @@ -835,8 +825,7 @@ export const malwareQueries = createQueryKeys('malware', {
},
});
if (!mostExploitableMalwareCounts.ok) {
// TODO handle error
return defaultResults;
throw new Error('Error getting most exploitable count');
}

return {
Expand Down
8 changes: 2 additions & 6 deletions deepfence_frontend/apps/dashboard/src/queries/secret.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ export const secretQueries = createQueryKeys('secret', {
}

if (resultSecretScanResponse.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting scan results');
}
const totalSeverity = Object.values(
Expand Down Expand Up @@ -563,7 +562,6 @@ export const secretQueries = createQueryKeys('secret', {
}

if (resultSecretScanResponse.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting scan results');
}

Expand Down Expand Up @@ -755,8 +753,7 @@ export const secretQueries = createQueryKeys('secret', {
});

if (!uniqueSecretsCounts.ok) {
// TODO handle error
return defaultResults;
throw new Error('Error getting unique secret count');
}

return {
Expand Down Expand Up @@ -820,8 +817,7 @@ export const secretQueries = createQueryKeys('secret', {
},
});
if (!mostExploitableSecretCounts.ok) {
// TODO handle error
return defaultResults;
throw new Error('Error getting most exploitable count');
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ export const vulnerabilityQueries = createQueryKeys('vulnerability', {
}

if (resultVulnerabilityScanResponse.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting scan results');
}
const totalSeverity = Object.values(
Expand Down Expand Up @@ -644,7 +643,6 @@ export const vulnerabilityQueries = createQueryKeys('vulnerability', {
}

if (resultVulnerabilityScanResponse.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting scan results');
}

Expand Down Expand Up @@ -1209,8 +1207,7 @@ export const vulnerabilityQueries = createQueryKeys('vulnerability', {
},
});
if (!mostExploitableVulenrabilityCounts.ok) {
// TODO handle error
return defaultResults;
throw new Error('Error getting most exploitable count');
}

return {
Expand Down Expand Up @@ -1268,8 +1265,7 @@ export const vulnerabilityQueries = createQueryKeys('vulnerability', {
});

if (!uniqueVulenrabilityCounts.ok) {
// TODO handle error
return defaultResults;
throw new Error('Error getting unique vulnerability count');
}

return {
Expand Down Expand Up @@ -1494,7 +1490,6 @@ export const vulnerabilityQueries = createQueryKeys('vulnerability', {
}

if (response.value === null) {
// TODO: handle this case with 404 status maybe
throw new Error('Error getting scan results filters');
}

Expand Down
Loading
Loading