From 2bfa37ca2e11b294a5ab113c31d4972d0614131e Mon Sep 17 00:00:00 2001 From: Sophia Dao Date: Thu, 1 Aug 2024 17:41:05 -0500 Subject: [PATCH] feat(findings): WIP - add in initial data table setup, add in some hardcoded value for display purposes, future skeleton loader --- app/(prowler)/findings/page.tsx | 54 ++++++++++-- components/index.ts | 2 + .../providers/table/ColumnsFindings.tsx | 86 +++++++++++++++++++ .../providers/table/SkeletonTableFindings.tsx | 65 ++++++++++++++ types/components.ts | 12 +++ 5 files changed, 214 insertions(+), 5 deletions(-) create mode 100644 components/providers/table/ColumnsFindings.tsx create mode 100644 components/providers/table/SkeletonTableFindings.tsx diff --git a/app/(prowler)/findings/page.tsx b/app/(prowler)/findings/page.tsx index 373833f41e..2595124a58 100644 --- a/app/(prowler)/findings/page.tsx +++ b/app/(prowler)/findings/page.tsx @@ -1,13 +1,57 @@ -import React from "react"; +import { Spacer } from "@nextui-org/react"; +import React, { Suspense } from "react"; -import { Header } from "@/components"; +import { + ColumnsFindings, + DataTable, + Header, + SkeletonTableFindings, +} from "@/components"; -export default function Findings() { +export default async function Findings() { return ( <>
- -

Hi hi from Findings page

+ +
+ + }> + + +
); } + +const SSRDataTable = async () => { + return ( + + ); +}; diff --git a/components/index.ts b/components/index.ts index 4cad0baacf..98f77ea0f2 100644 --- a/components/index.ts +++ b/components/index.ts @@ -1,8 +1,10 @@ export * from "./providers/DateWithTime"; export * from "./providers/ProviderInfo"; export * from "./providers/ScanStatus"; +export * from "./providers/table/ColumnsFindings"; export * from "./providers/table/ColumnsProviders"; export * from "./providers/table/DataTable"; +export * from "./providers/table/SkeletonTableFindings"; export * from "./providers/table/SkeletonTableProvider"; export * from "./ui/alert/Alert"; export * from "./ui/header/Header"; diff --git a/components/providers/table/ColumnsFindings.tsx b/components/providers/table/ColumnsFindings.tsx new file mode 100644 index 0000000000..90860b260e --- /dev/null +++ b/components/providers/table/ColumnsFindings.tsx @@ -0,0 +1,86 @@ +"use client"; + +import { + Button, + Dropdown, + DropdownItem, + DropdownMenu, + DropdownTrigger, +} from "@nextui-org/react"; +import { ColumnDef } from "@tanstack/react-table"; + +import { VerticalDotsIcon } from "@/components/icons"; +import { FindingsProps } from "@/types"; + +const getFindingsAttributes = (row: { original: FindingsProps }) => { + 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

{severity}

; + }, + }, + { + accessorKey: "status", + header: "Status", + cell: ({ row }) => { + const { status } = getFindingsAttributes(row); + return

{status}

; + }, + }, + { + 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/providers/table/SkeletonTableFindings.tsx b/components/providers/table/SkeletonTableFindings.tsx new file mode 100644 index 0000000000..074405d8a7 --- /dev/null +++ b/components/providers/table/SkeletonTableFindings.tsx @@ -0,0 +1,65 @@ +import { Card, Skeleton } from "@nextui-org/react"; +import React from "react"; + +export const SkeletonTableFindings = () => { + return ( + + {/* Table headers */} +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + {/* Table body */} +
+ {[...Array(3)].map((_, index) => ( +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ ))} +
+
+ ); +}; diff --git a/types/components.ts b/types/components.ts index 994adf02a2..b7b53724e5 100644 --- a/types/components.ts +++ b/types/components.ts @@ -35,3 +35,15 @@ export interface ProviderProps { }; }; } + +export interface FindingsProps { + id: string; + attributes: { + CheckTitle: string; + severity: string; + status: string; + region: string; + service: string; + account: string; + }; +}