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

Change made to refer created at field instead of updated at field #1961

Merged
merged 2 commits into from
Feb 15, 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 @@ -136,7 +136,7 @@ const InputForm = ({
valueKey="nodeId"
onChange={(data: ISelected) => {
setToScanData({
toScanTime: data.updatedAt,
toScanTime: data.createdAt,
toScanId: data.scanId,
});
}}
Expand All @@ -153,7 +153,7 @@ const InputForm = ({
valueKey="nodeId"
onChange={(data: ISelected) => {
setToScanData({
toScanTime: data.updatedAt,
toScanTime: data.createdAt,
toScanId: data.scanId,
});
}}
Expand Down Expand Up @@ -183,7 +183,7 @@ export const CompareScanInputModal = ({
showDialog: boolean;
setShowDialog: React.Dispatch<React.SetStateAction<boolean>>;
scanHistoryData: {
updatedAt: number;
createdAt: number;
scanId: string;
status: string;
}[];
Expand Down Expand Up @@ -238,12 +238,12 @@ export const CompareScanInputModal = ({
disabled={!toScanData.toScanTime}
onClick={() => {
const baseScan = scanHistoryData.find((data) => {
return data.updatedAt === compareInput.baseScanTime;
return data.createdAt === compareInput.baseScanTime;
});
setCompareInput({
baseScanId: baseScan?.scanId ?? '',
toScanId: toScanData?.toScanId ?? '',
baseScanTime: baseScan?.updatedAt ?? 0,
baseScanTime: baseScan?.createdAt ?? 0,
toScanTime: toScanData?.toScanTime ?? 0,
showScanTimeModal: false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface TimeListProps {
}

export interface ISelected {
updatedAt: number;
createdAt: number;
scanId: string;
}

Expand Down Expand Up @@ -91,7 +91,7 @@ const ScanTime = ({
placeholder="Scan time"
value={selectedTime as unknown as ISelected}
onChange={(value: ISelected) => {
setSelectedTime(value.updatedAt);
setSelectedTime(value.createdAt);
onChange?.(value);
}}
clearAll="Clear"
Expand All @@ -109,20 +109,21 @@ const ScanTime = ({
return page.data;
})
.filter(
(scan) => scan.updatedAt !== skipScanTime && isScanComplete(scan.status),
(scan) => scan.createdAt !== skipScanTime && isScanComplete(scan.status),
)
.reverse()
?.map?.((scan) => {
return (
<ListboxOption
key={scan.updatedAt}
key={scan.createdAt}
value={
{
updatedAt: scan.updatedAt,
createdAt: scan.createdAt,
scanId: scan.scanId,
} as ISelected
}
>
{formatMilliseconds(scan.updatedAt)}
{formatMilliseconds(scan.createdAt)}
</ListboxOption>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ const HistoryControls = () => {
const [isSubmitting, setIsSubmitting] = useState(false);
const { data, fetchStatus } = useScanResults();
const { scanStatusResult } = data;
const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {};
const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {};
const { navigate, goBack } = usePageNavigation();
const { downloadScan } = useDownloadScan((state) => {
setIsSubmitting(state === 'submitting');
Expand All @@ -604,7 +604,7 @@ const HistoryControls = () => {
}>({
baseScanId: '',
toScanId: '',
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
toScanTime: 0,
showScanTimeModal: false,
});
Expand All @@ -625,7 +625,7 @@ const HistoryControls = () => {
if (!scan_id || !node_id || !node_type) {
throw new Error('Scan Type, Node Type and Node Id are required');
}
if (!updated_at) {
if (!created_at) {
return null;
}

Expand Down Expand Up @@ -680,7 +680,7 @@ const HistoryControls = () => {
id: item.scanId,
isCurrent: item.scanId === scan_id,
status: item.status,
timestamp: item.updatedAt,
timestamp: item.createdAt,
showScanCompareButton: true,
onScanTimeCompareButtonClick: onCompareScanClick,
onDeleteClick: (id) => {
Expand All @@ -704,7 +704,7 @@ const HistoryControls = () => {
);
},
}))}
currentTimeStamp={formatMilliseconds(updated_at)}
currentTimeStamp={formatMilliseconds(created_at)}
/>

{scanIdToDelete && (
Expand Down Expand Up @@ -784,7 +784,7 @@ const HistoryControls = () => {
onClick={() => {
setCompareInput({
...compareInput,
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
showScanTimeModal: true,
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ const ScansTable = ({
size: 240,
maxSize: 250,
}),
columnHelper.accessor('updated_at', {
columnHelper.accessor('created_at', {
cell: (info) => <TruncatedText text={formatMilliseconds(info.getValue())} />,
header: () => <TruncatedText text="Timestamp" />,
minSize: 140,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ const HistoryControls = () => {
});

const [openStopScanModal, setOpenStopScanModal] = useState(false);
const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {};
const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {};

const [showScanCompareModal, setShowScanCompareModal] = useState<boolean>(false);

Expand All @@ -597,7 +597,7 @@ const HistoryControls = () => {
}>({
baseScanId: '',
toScanId: '',
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
toScanTime: 0,
showScanTimeModal: false,
});
Expand Down Expand Up @@ -670,7 +670,7 @@ const HistoryControls = () => {
id: item.scanId,
isCurrent: item.scanId === scan_id,
status: item.status,
timestamp: item.updatedAt,
timestamp: item.createdAt,
showScanCompareButton: true,
onScanTimeCompareButtonClick: onCompareScanClick,
onDeleteClick: (id) => {
Expand All @@ -695,7 +695,7 @@ const HistoryControls = () => {
);
},
}))}
currentTimeStamp={formatMilliseconds(updated_at ?? '')}
currentTimeStamp={formatMilliseconds(created_at ?? '')}
/>

{scanIdToDelete && (
Expand Down Expand Up @@ -775,7 +775,7 @@ const HistoryControls = () => {
onClick={() => {
setCompareInput({
...compareInput,
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
showScanTimeModal: true,
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ const HistoryControls = () => {
const { data, fetchStatus } = useScanResults();
const { nodeType = '' } = useParams();
const { scanStatusResult } = data;
const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {};
const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {};
const { navigate, goBack } = usePageNavigation();
const { downloadScan } = useDownloadScan((state) => {
setIsSubmitting(state === 'submitting');
Expand All @@ -592,7 +592,7 @@ const HistoryControls = () => {
}>({
baseScanId: '',
toScanId: '',
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
toScanTime: 0,
showScanTimeModal: false,
});
Expand Down Expand Up @@ -665,7 +665,7 @@ const HistoryControls = () => {
id: item.scanId,
isCurrent: item.scanId === scan_id,
status: item.status,
timestamp: item.updatedAt,
timestamp: item.createdAt,
showScanCompareButton: true,
onScanTimeCompareButtonClick: onCompareScanClick,
onDeleteClick: (id) => {
Expand All @@ -690,7 +690,7 @@ const HistoryControls = () => {
);
},
}))}
currentTimeStamp={formatMilliseconds(updated_at ?? '')}
currentTimeStamp={formatMilliseconds(created_at ?? '')}
/>

{scanIdToDelete && (
Expand Down Expand Up @@ -770,7 +770,7 @@ const HistoryControls = () => {
onClick={() => {
setCompareInput({
...compareInput,
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
showScanTimeModal: true,
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ const HistoryControls = () => {
const [isSubmitting, setIsSubmitting] = useState(false);
const { data, fetchStatus } = useScanResults();
const { scanStatusResult } = data;
const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {};
const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {};
const { navigate, goBack } = usePageNavigation();
const { downloadScan } = useDownloadScan((state) => {
setIsSubmitting(state === 'submitting');
Expand All @@ -604,7 +604,7 @@ const HistoryControls = () => {
}>({
baseScanId: '',
toScanId: '',
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
toScanTime: 0,
showScanTimeModal: false,
});
Expand All @@ -625,7 +625,7 @@ const HistoryControls = () => {
if (!scan_id || !node_id || !node_type) {
throw new Error('Scan Type, Node Type and Node Id are required');
}
if (!updated_at) {
if (!created_at) {
return null;
}
const onCompareScanClick = (baseScanTime: number) => {
Expand Down Expand Up @@ -679,7 +679,7 @@ const HistoryControls = () => {
id: item.scanId,
isCurrent: item.scanId === scan_id,
status: item.status,
timestamp: item.updatedAt,
timestamp: item.createdAt,
showScanCompareButton: true,
onScanTimeCompareButtonClick: onCompareScanClick,
onDeleteClick: (id) => {
Expand All @@ -703,7 +703,7 @@ const HistoryControls = () => {
);
},
}))}
currentTimeStamp={formatMilliseconds(updated_at)}
currentTimeStamp={formatMilliseconds(created_at)}
/>

{scanIdToDelete && (
Expand Down Expand Up @@ -783,7 +783,7 @@ const HistoryControls = () => {
onClick={() => {
setCompareInput({
...compareInput,
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
showScanTimeModal: true,
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ const ScansTable = ({
size: 240,
maxSize: 250,
}),
columnHelper.accessor('updated_at', {
columnHelper.accessor('created_at', {
cell: (info) => <TruncatedText text={formatMilliseconds(info.getValue())} />,
header: () => <TruncatedText text="Timestamp" />,
minSize: 140,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ const HistoryControls = () => {
const [isSubmitting, setIsSubmitting] = useState(false);
const { data, fetchStatus } = useScanResults();
const { scanStatusResult } = data;
const { scan_id, node_id, node_type, updated_at, status, node_name } =
const { scan_id, node_id, node_type, created_at, status, node_name } =
scanStatusResult ?? {};
const { navigate, goBack } = usePageNavigation();
const { downloadScan } = useDownloadScan((state) => {
Expand All @@ -567,7 +567,7 @@ const HistoryControls = () => {
}>({
baseScanId: '',
toScanId: '',
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
toScanTime: 0,
showScanTimeModal: false,
});
Expand All @@ -588,7 +588,7 @@ const HistoryControls = () => {
if (!scan_id || !node_id || !node_type) {
throw new Error('Scan Type, Node Type and Node Id are required');
}
if (!updated_at) {
if (!created_at) {
return null;
}

Expand Down Expand Up @@ -644,7 +644,7 @@ const HistoryControls = () => {
id: item.scanId,
isCurrent: item.scanId === scan_id,
status: item.status,
timestamp: item.updatedAt,
timestamp: item.createdAt,
showScanCompareButton: true,
onScanTimeCompareButtonClick: onCompareScanClick,
onDeleteClick: (id) => {
Expand All @@ -668,7 +668,7 @@ const HistoryControls = () => {
);
},
}))}
currentTimeStamp={formatMilliseconds(updated_at)}
currentTimeStamp={formatMilliseconds(created_at)}
/>

{scanIdToDelete && (
Expand Down Expand Up @@ -751,7 +751,7 @@ const HistoryControls = () => {
onClick={() => {
setCompareInput({
...compareInput,
baseScanTime: updated_at ?? 0,
baseScanTime: created_at ?? 0,
showScanTimeModal: true,
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ const ScansTable = ({
size: 240,
maxSize: 250,
}),
columnHelper.accessor('updated_at', {
columnHelper.accessor('created_at', {
cell: (info) => <TruncatedText text={formatMilliseconds(info.getValue())} />,
header: () => <TruncatedText text="Timestamp" />,
minSize: 140,
Expand Down
2 changes: 1 addition & 1 deletion deepfence_frontend/apps/dashboard/src/queries/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const commonQueries = createQueryKeys('common', {
return {
data: (result.value.scans_info ?? []).slice(0, size)?.map((res) => {
return {
updatedAt: res.updated_at,
createdAt: res.created_at,
scanId: res.scan_id,
status: res.status,
nodeName: res.node_name,
Expand Down
Loading