Skip to content

Commit

Permalink
Update pending todo (#2164)
Browse files Browse the repository at this point in the history
* remove theme props from react echart

* Update commented some of pending todo
  • Loading branch information
milan-deepfence authored Jun 10, 2024
1 parent 1d04577 commit 9f07164
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,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 @@ -361,14 +359,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
1 change: 0 additions & 1 deletion deepfence_frontend/apps/dashboard/src/constants/charts.ts
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 @@ -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
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
23 changes: 6 additions & 17 deletions deepfence_frontend/apps/dashboard/src/queries/malware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,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 Down Expand Up @@ -497,8 +493,8 @@ export const malwareQueries = createQueryKeys('malware', {
resultMalwareScanResponse.value.severity_counts?.[SeverityEnum.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 @@ -457,7 +457,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 @@ -564,7 +563,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 @@ -756,8 +754,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 @@ -821,8 +818,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 @@ -510,7 +510,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 @@ -646,7 +645,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 @@ -1211,8 +1209,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 @@ -1281,8 +1278,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 @@ -1510,7 +1506,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
34 changes: 4 additions & 30 deletions deepfence_frontend/packages/tailwind-preset/src/cn.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,14 @@
import classNames from 'classnames';
import { twMerge, extendTailwindMerge } from 'tailwind-merge';
import { preset } from './preset';

// https://github.com/dcastil/tailwind-merge/issues/217
// TODO: make importing tailwind-preset work here and add keys from there
export const dfTwMerge: typeof twMerge = extendTailwindMerge({
extend: {
classGroups: {
'font-size': [
'text-h1',
'text-h2',
'text-h3',
'text-h4',
'text-h5',
'text-h6',
'text-p1',
'text-p1a',
'text-p2',
'text-p3',
'text-p4',
'text-p4a',
'text-p5',
'text-p6',
'text-p7',
'text-p7a',
'text-p8',
'text-p9',
'text-p10',
'text-p11',
'text-p12',
'text-p13',
'text-t1',
'text-t2',
'text-t3',
'text-t4',
'text-t5',
],
'font-size': Object.keys(preset.theme.extend.fontSize).map((key) => {
return `text-${key}`;
}),
},
},
});
Expand Down

0 comments on commit 9f07164

Please sign in to comment.