From 868615fa89d6653fb6979fadc017a968965f74c9 Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Wed, 16 Oct 2024 07:08:22 +0200 Subject: [PATCH] chore: clean finding folder --- components/findings/FindingsCard.tsx | 93 ------------ components/findings/FindingsCardContent.tsx | 27 ---- components/findings/FindingsCardDetail.tsx | 59 -------- components/findings/FindingsCardScan.tsx | 25 ---- components/findings/FindingsCardType.tsx | 25 ---- components/findings/index.ts | 7 - components/findings/table/ColumnsFindings.tsx | 80 ----------- .../findings/table/DataTableFindings.tsx | 133 ------------------ 8 files changed, 449 deletions(-) delete mode 100644 components/findings/FindingsCard.tsx delete mode 100644 components/findings/FindingsCardContent.tsx delete mode 100644 components/findings/FindingsCardDetail.tsx delete mode 100644 components/findings/FindingsCardScan.tsx delete mode 100644 components/findings/FindingsCardType.tsx delete mode 100644 components/findings/table/ColumnsFindings.tsx delete mode 100644 components/findings/table/DataTableFindings.tsx diff --git a/components/findings/FindingsCard.tsx b/components/findings/FindingsCard.tsx deleted file mode 100644 index b4f9cab7a6..0000000000 --- a/components/findings/FindingsCard.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import { Divider } from "@nextui-org/react"; -import clsx from "clsx"; -import React from "react"; - -import { - FindingsCardContent, - FindingsCardDetail, - FindingsCardScan, - FindingsCardType, -} from "@/components/findings"; -import { FindingProps } from "@/types"; -interface FindingsCardProps { - selectedRow: FindingProps; -} - -export const FindingsCard: React.FC = ({ selectedRow }) => { - const { attributes, card } = selectedRow || {}; - const { CheckTitle } = attributes || {}; - const { - resourceLink, - resourceId, - resourceARN, - checkLink, - checkId, - type, - scanTime, - findingLink, - findingId, - details, - riskDetails, - riskLink, - recommendationDetails, - recommendationLink, - referenceInformation, - referenceLink, - } = card || {}; - - return ( - <> -
-

{CheckTitle}

- - - - - - - - - - - - - -
- - ); -}; diff --git a/components/findings/FindingsCardContent.tsx b/components/findings/FindingsCardContent.tsx deleted file mode 100644 index 09bba0150a..0000000000 --- a/components/findings/FindingsCardContent.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Link } from "@nextui-org/react"; -import React from "react"; - -interface FindingsCardContentProps { - title: string; - url?: string; - description: string; -} - -export const FindingsCardContent: React.FC = ({ - title, - url, - description, -}) => { - return ( - <> -

{title}

- {url ? ( - - {description} - - ) : ( -

{description}

- )} - - ); -}; diff --git a/components/findings/FindingsCardDetail.tsx b/components/findings/FindingsCardDetail.tsx deleted file mode 100644 index 957cc6809e..0000000000 --- a/components/findings/FindingsCardDetail.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { Button, Link } from "@nextui-org/react"; -import React from "react"; - -interface FindingsCardDetailProps { - title: string; - url?: string; - description: string; - type?: DetailType; -} - -type DetailType = "default" | "risk" | "recommendation" | "reference"; - -const getDetailColorClass = (type: DetailType): string => { - switch (type) { - case "risk": - return "border-red-200"; - case "recommendation": - return "border-green-200"; - case "reference": - return "border-gray-200"; - case "default": - default: - return "border-yellow-200"; - } -}; - -export const FindingsCardDetail: React.FC = ({ - title, - url, - description, - type = "default", -}) => { - return ( - <> - {description && ( -
-

- {title} - {url && ( - - )} -

-

{description}

-
- )} - - ); -}; diff --git a/components/findings/FindingsCardScan.tsx b/components/findings/FindingsCardScan.tsx deleted file mode 100644 index 1ccab7a0a8..0000000000 --- a/components/findings/FindingsCardScan.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { format, parseISO } from "date-fns"; -import React from "react"; - -interface FindingsCardScanProps { - title: string; - dateTime: string; -} - -export const FindingsCardScan: React.FC = ({ - title, - dateTime = "", -}) => { - const date = dateTime && parseISO(dateTime); - const formattedDate = date && format(date, "MMM dd, yyyy"); - const formattedTime = date && format(date, "p 'UTC'"); - - return ( - <> -

{title}

-

- {formattedDate} at {formattedTime} -

- - ); -}; diff --git a/components/findings/FindingsCardType.tsx b/components/findings/FindingsCardType.tsx deleted file mode 100644 index a525d0d1ab..0000000000 --- a/components/findings/FindingsCardType.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react"; - -interface FindingsCardTypeProps { - type: string[]; -} - -export const FindingsCardType: React.FC = ({ - type = [], -}) => { - const typeContent = () => { - if (type.length > 0) { - return type.join(", "); - } - return type[0]; - }; - - return ( - <> -

- {type.length > 1 ? "Types:" : "Type:"} -

-

{typeContent()}

- - ); -}; diff --git a/components/findings/index.ts b/components/findings/index.ts index e7c1764519..6f9176cda7 100644 --- a/components/findings/index.ts +++ b/components/findings/index.ts @@ -1,8 +1 @@ -export * from "./FindingsCard"; -export * from "./FindingsCardContent"; -export * from "./FindingsCardDetail"; -export * from "./FindingsCardScan"; -export * from "./FindingsCardType"; -export * from "./table/ColumnsFindings"; -export * from "./table/DataTableFindings"; export * from "./table/SkeletonTableFindings"; diff --git a/components/findings/table/ColumnsFindings.tsx b/components/findings/table/ColumnsFindings.tsx deleted file mode 100644 index b27f4a6dbb..0000000000 --- a/components/findings/table/ColumnsFindings.tsx +++ /dev/null @@ -1,80 +0,0 @@ -"use client"; - -import { - Button, - Dropdown, - DropdownItem, - DropdownMenu, - DropdownTrigger, -} from "@nextui-org/react"; -import { ColumnDef } from "@tanstack/react-table"; - -import { VerticalDotsIcon } from "@/components/icons"; -import { SeverityBadge } from "@/components/ui/table"; -import { FindingProps } from "@/types"; - -const getFindingsAttributes = (row: { original: FindingProps }) => { - return row.original.attributes; -}; - -export const ColumnsFindings: ColumnDef[] = [ - { - accessorKey: "checkTitle", - header: "Check", - cell: ({ row }) => { - const { CheckTitle } = getFindingsAttributes(row); - return

{CheckTitle}

; - }, - }, - { - accessorKey: "severity", - header: "Severity", - cell: ({ row }) => { - const { severity } = getFindingsAttributes(row); - return ; - }, - }, - - { - accessorKey: "region", - header: "Region", - cell: ({ row }) => { - const { region } = getFindingsAttributes(row); - return

{region}

; - }, - }, - { - accessorKey: "service", - header: "Service", - cell: ({ row }) => { - const { service } = getFindingsAttributes(row); - return

{service}

; - }, - }, - { - accessorKey: "account", - header: "Account", - cell: ({ row }) => { - const { account } = getFindingsAttributes(row); - return

{account}

; - }, - }, - { - accessorKey: "actions", - header: () => ( -
- - - - - - Mute Findings for Selected Filters - Configure Muted Findings - - -
- ), - }, -]; diff --git a/components/findings/table/DataTableFindings.tsx b/components/findings/table/DataTableFindings.tsx deleted file mode 100644 index 1bc3884492..0000000000 --- a/components/findings/table/DataTableFindings.tsx +++ /dev/null @@ -1,133 +0,0 @@ -"use client"; - -import { Button } from "@nextui-org/react"; -import { - ColumnDef, - flexRender, - getCoreRowModel, - getPaginationRowModel, - Row, - useReactTable, -} from "@tanstack/react-table"; -import clsx from "clsx"; - -import { FindingsCard } from "@/components/findings"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { FindingProps } from "@/types"; - -interface DataTableFindingsProps { - columns: ColumnDef[]; - data: TData[]; -} - -export function DataTableFindings({ - columns, - data, -}: DataTableFindingsProps) { - const table = useReactTable({ - data, - columns, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - }); - - const selectedRow = table.getSelectedRowModel().rows[0]?.original; - - const onClick = (row: Row) => { - table.resetRowSelection(true); - row.toggleSelected(); - return; - }; - - return ( - <> -
-
-
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? null - : flexRender( - header.column.columnDef.header, - header.getContext(), - )} - - ); - })} - - ))} - - - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row) => ( - onClick(row)} - className={"hover:cursor-pointer"} - > - {row.getVisibleCells().map((cell) => ( - - {flexRender( - cell.column.columnDef.cell, - cell.getContext(), - )} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
-
- - -
-
- -
- - ); -}