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

Fix scan history stale data after deletion #2272

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -121,6 +121,8 @@ export const AWSCloudFormation = () => {
<Link
to="https://community.deepfence.io/threatmapper/docs/v2.2/cloudscanner/aws#cloudformation"
className="text-text-link"
target="_blank"
rel="noreferrer"
>
reading our documentation
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import { MalwareScanResultsPieChart } from '@/features/malwares/components/scan-
import { MalwaresCompare } from '@/features/malwares/components/scan-results/MalwaresCompare';
import { SuccessModalContent } from '@/features/settings/components/SuccessModalContent';
import { invalidateAllQueries, queries } from '@/queries';
import { queryClient } from '@/queries/client';
import { THEME_LIGHT, useTheme } from '@/theme/ThemeContext';
import {
isCriticalSeverity,
Expand Down Expand Up @@ -277,6 +278,9 @@ const action = async ({
}
throw result.error;
}
await queryClient.invalidateQueries({
queryKey: queries.common.scanHistories._def,
});
return {
action: actionType,
success: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function MyConnectorsTable() {
</div>
);
},
header: () => 'Account Type',
header: () => 'Account type',
minSize: 100,
size: 110,
maxSize: 150,
Expand All @@ -200,7 +200,7 @@ function MyConnectorsTable() {
size: 110,
maxSize: 150,
cell: (info) => info.getValue(),
header: () => 'Connection Method',
header: () => 'Connection method',
}),
columnHelper.accessor('accountId', {
minSize: 300,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSuspenseQuery } from '@suspensive/react-query';
import { Suspense, useState } from 'react';
import { Suspense, useEffect, useState } from 'react';
import { generatePath } from 'react-router-dom';
import { Button } from 'ui-components';

Expand Down Expand Up @@ -79,7 +79,7 @@ const HistoryControls = () => {
showScanTimeModal: false,
});

const { data: historyData } = useSuspenseQuery({
const { data: historyData, refetch } = useSuspenseQuery({
...queries.common.scanHistories({
scanType: ScanTypeEnum.CloudComplianceScan,
nodeId: node_id ?? '',
Expand All @@ -88,6 +88,10 @@ const HistoryControls = () => {
}),
});

useEffect(() => {
refetch();
}, [scan_id]);

if (!node_id || !node_type || !scan_id) {
throw new Error('Scan id, Node type and Node id are required');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { toast } from 'sonner';

import { getScanResultsApiClient } from '@/api/api';
import { ModelScanResultsMaskRequestMaskActionEnum } from '@/api/generated';
import { invalidateAllQueries } from '@/queries';
import { invalidateAllQueries, queries } from '@/queries';
import { queryClient } from '@/queries/client';
import { ScanTypeEnum } from '@/types/common';
import { get403Message, getResponseErrors } from '@/utils/403';
import { apiWrapper } from '@/utils/api';
Expand Down Expand Up @@ -160,6 +161,9 @@ export const action = async ({
}
throw result.error;
}
await queryClient.invalidateQueries({
queryKey: queries.common.scanHistories._def,
});
return {
action: actionType,
success: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import {
} from '@/features/postures/utils';
import { SuccessModalContent } from '@/features/settings/components/SuccessModalContent';
import { invalidateAllQueries, queries } from '@/queries';
import { queryClient } from '@/queries/client';
import { useTheme } from '@/theme/ThemeContext';
import {
ComplianceScanNodeTypeEnum,
Expand Down Expand Up @@ -278,6 +279,9 @@ const action = async ({
}
throw result.error;
}
await queryClient.invalidateQueries({
queryKey: queries.common.scanHistories._def,
});
return {
action: actionType,
success: true,
Expand Down Expand Up @@ -634,6 +638,9 @@ const HistoryControls = () => {
}),
});

// This is required because scan history query does not depend on url parameters
// so the data in the dropdown stays stale if you switch between different scans
// using this dropdown.
useEffect(() => {
refetch();
}, [scan_id]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import { SecretScanResultsPieChart } from '@/features/secrets/components/scan-re
import { SecretsCompare } from '@/features/secrets/components/scan-results/SecretsCompare';
import { SuccessModalContent } from '@/features/settings/components/SuccessModalContent';
import { invalidateAllQueries, queries } from '@/queries';
import { queryClient } from '@/queries/client';
import { THEME_LIGHT, useTheme } from '@/theme/ThemeContext';
import {
isCriticalSeverity,
Expand Down Expand Up @@ -277,6 +278,9 @@ const action = async ({
}
throw result.error;
}
await queryClient.invalidateQueries({
queryKey: queries.common.scanHistories._def,
});
return {
action: actionType,
success: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const Filters = () => {
const appliedFilterCount = getAppliedFiltersCount(searchParams);

return (
<FilterWrapper className="mt-[6px] mx-4 pt-4 px-4 pb-3">
<FilterWrapper className="mt-[6px] mx-4 pt-4 px-4 pb-3 overflow-visible">
<div className="flex gap-2">
<Combobox
value={THREAT_TYPES.find((threatType) => {
Expand Down Expand Up @@ -277,7 +277,7 @@ const Filters = () => {
/>
</div>
{appliedFilterCount > 0 ? (
<div className="flex gap-2.5 my-4 flex-wrap items-center">
<div className="flex gap-2.5 mt-4 flex-wrap items-center">
{Array.from(searchParams)
.filter(([key]) => {
return Object.keys(FILTER_SEARCHPARAMS).includes(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import { SearchableCVEList } from '@/features/vulnerabilities/components/ScanRes
import { VulnerabilitiesCompare } from '@/features/vulnerabilities/components/ScanResults/VulnerabilitiesCompare';
import { VulnerabilityScanResultsPieChart } from '@/features/vulnerabilities/components/ScanResults/VulnerabilityScanResultsPieChart';
import { invalidateAllQueries, queries } from '@/queries';
import { queryClient } from '@/queries/client';
import { useTheme } from '@/theme/ThemeContext';
import {
isCriticalSeverity,
Expand Down Expand Up @@ -281,6 +282,9 @@ const action = async ({
}
throw result.error;
}
await queryClient.invalidateQueries({
queryKey: queries.common.scanHistories._def,
});
return {
action: actionType,
success: true,
Expand Down
Loading