diff --git a/components/scans/launch-workflow/index.ts b/components/scans/launch-workflow/index.ts index 4ccdef368b..4f8a794d33 100644 --- a/components/scans/launch-workflow/index.ts +++ b/components/scans/launch-workflow/index.ts @@ -1,2 +1,2 @@ -export * from "./launch-scan-workflow"; +export * from "./launch-scan-workflow-form"; export * from "./select-scan-provider"; diff --git a/components/scans/launch-workflow/launch-scan-workflow.tsx b/components/scans/launch-workflow/launch-scan-workflow-form.tsx similarity index 91% rename from components/scans/launch-workflow/launch-scan-workflow.tsx rename to components/scans/launch-workflow/launch-scan-workflow-form.tsx index 99e27bb90c..b1149fceac 100644 --- a/components/scans/launch-workflow/launch-scan-workflow.tsx +++ b/components/scans/launch-workflow/launch-scan-workflow-form.tsx @@ -39,11 +39,22 @@ export const LaunchScanWorkflow = ({ const isLoading = form.formState.isSubmitting; const onSubmitClient = async (values: z.infer) => { + const formValues = { ...values }; + + if (!formValues.scanName?.trim()) { + const date = new Date(); + const month = (date.getMonth() + 1).toString().padStart(2, "0"); + const day = date.getDate().toString().padStart(2, "0"); + const year = date.getFullYear(); + const hours = date.getHours().toString().padStart(2, "0"); + const minutes = date.getMinutes().toString().padStart(2, "0"); + formValues.scanName = `scan:${month}/${day}/${year} ${hours}:${minutes}`; + } + const formData = new FormData(); - console.log(values); // Loop through form values and add to formData - Object.entries(values).forEach( + Object.entries(formValues).forEach( ([key, value]) => value !== undefined && formData.append( diff --git a/components/scans/table/scans/column-get-scans.tsx b/components/scans/table/scans/column-get-scans.tsx index 3e2d940e8e..604d67ef8b 100644 --- a/components/scans/table/scans/column-get-scans.tsx +++ b/components/scans/table/scans/column-get-scans.tsx @@ -29,18 +29,6 @@ export const ColumnGetScans: ColumnDef[] = [ return ; }, }, - { - accessorKey: "trigger", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const { - attributes: { trigger }, - } = getScanData(row); - return

{trigger}

; - }, - }, { accessorKey: "status", @@ -54,6 +42,27 @@ export const ColumnGetScans: ColumnDef[] = [ return ; }, }, + + { + accessorKey: "scanner_args", + header: "Scanner Args", + cell: ({ row }) => { + const { + attributes: { scanner_args }, + } = getScanData(row); + return

{scanner_args?.only_logs}

; + }, + }, + { + accessorKey: "resources", + header: "Resources", + cell: ({ row }) => { + const { + attributes: { unique_resource_count }, + } = getScanData(row); + return

{unique_resource_count}

; + }, + }, { accessorKey: "scheduled_at", header: ({ column }) => ( @@ -103,23 +112,15 @@ export const ColumnGetScans: ColumnDef[] = [ }, }, { - accessorKey: "scanner_args", - header: "Scanner Args", + accessorKey: "trigger", + header: ({ column }) => ( + + ), cell: ({ row }) => { const { - attributes: { scanner_args }, + attributes: { trigger }, } = getScanData(row); - return

{scanner_args?.only_logs}

; - }, - }, - { - accessorKey: "resources", - header: "Resources", - cell: ({ row }) => { - const { - attributes: { unique_resource_count }, - } = getScanData(row); - return

{unique_resource_count}

; + return

{trigger}

; }, }, {