From 9639082e2067d88a12bf1422edfdb382b47f7aa6 Mon Sep 17 00:00:00 2001 From: sumit_chaturvedi Date: Mon, 28 Apr 2025 10:25:04 +0530 Subject: [PATCH] srn Fix lint --- ui/app/(prowler)/resources/page.tsx | 48 ++++++++----------- .../skeleton/skeleton-finding-summary.tsx | 22 +++++---- ui/components/resources/table/index.ts | 2 +- .../resources/table/resource-detail.tsx | 1 + 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/ui/app/(prowler)/resources/page.tsx b/ui/app/(prowler)/resources/page.tsx index 87f3ad9c2c..bfc0e86e18 100644 --- a/ui/app/(prowler)/resources/page.tsx +++ b/ui/app/(prowler)/resources/page.tsx @@ -1,12 +1,12 @@ import { Spacer } from "@nextui-org/react"; -import { format, parseISO, subDays } from "date-fns"; +import { format, parseISO } from "date-fns"; import { Suspense } from "react"; import { getResourceFields, getResources } from "@/actions/resources"; import { getScansByFields } from "@/actions/scans"; import { FilterControls } from "@/components/filters"; -import { ColumnResources } from "@/components/resources/table/column-resources"; import { SkeletonTableResources } from "@/components/resources/skeleton/skeleton-table-resources"; +import { ColumnResources } from "@/components/resources/table/column-resources"; import { ContentLayout } from "@/components/ui"; import { DataTable, DataTableFilterCustom } from "@/components/ui/table"; import { createDict } from "@/lib"; @@ -18,7 +18,6 @@ export default async function Resources({ searchParams: SearchParamsProps; }) { const searchParamsKey = JSON.stringify(searchParams || {}); - const twoDaysAgo = format(subDays(new Date(), 2), "yyyy-MM-dd"); // Check if the searchParams contain any date or filter const hasDateOrScanFilter = Object.keys(searchParams).some((key) => @@ -28,7 +27,7 @@ export default async function Resources({ // Default filters for getFindings const defaultFilters: Record = hasDateOrScanFilter ? {} // Do not apply default filters if there are date or filters - : { "filter[inserted_at]": twoDaysAgo, "page[size]": "100" }; // TODO: Remove page[size] 100 when metadata endpoint implemented + : { "page[size]": "100" }; // TODO: Remove page[size] 100 when metadata endpoint implemented const filters: Record = { ...defaultFilters, @@ -55,6 +54,7 @@ export default async function Resources({ } } + // Resource call for filters const resourcesData = await getResourceFields( "name,type,region,service", filters, @@ -69,14 +69,14 @@ export default async function Resources({ resourceNameList = Array.from( new Set( resourcesData.data.map((item: ResourceProps) => item.attributes.name) || - [], + [], ), ); typeList = Array.from( new Set( resourcesData.data.map((item: ResourceProps) => item.attributes.type) || - [], + [], ), ); @@ -144,20 +144,12 @@ const SSRDataTable = async ({ const defaultSort = "name"; const sort = searchParams.sort?.toString() || defaultSort; - const twoDaysAgo = format(subDays(new Date(), 2), "yyyy-MM-dd"); - // Check if the searchParams contain any date or filter const hasDateOrScanFilter = Object.keys(searchParams).some((key) => key.includes("inserted_at"), ); - // Default filters for getFindings - const defaultFilters: Record = hasDateOrScanFilter - ? {} // Do not apply default filters if there are date or filters - : { "filter[inserted_at]": twoDaysAgo }; - const filters: Record = { - ...defaultFilters, ...Object.fromEntries( Object.entries(searchParams) .filter(([key]) => key.startsWith("filter[")) @@ -196,22 +188,22 @@ const SSRDataTable = async ({ // Expand each resources with its corresponding findings and provider const expandedResources = resourcesData?.data ? resourcesData.data.map((resource: ResourceProps) => { - const findings = { - meta: resource.relationships.findings.meta, - data: resource.relationships.findings.data?.map( - (finding) => findingsDict[finding.id], - ), - }; + const findings = { + meta: resource.relationships.findings.meta, + data: resource.relationships.findings.data?.map( + (finding) => findingsDict[finding.id], + ), + }; - const provider = { - data: providerDict[resource.relationships.provider.data.id], - }; + const provider = { + data: providerDict[resource.relationships.provider.data.id], + }; - return { - ...resource, - relationships: { findings, provider }, - }; - }) + return { + ...resource, + relationships: { findings, provider }, + }; + }) : []; const expandedResponse = { diff --git a/ui/components/resources/skeleton/skeleton-finding-summary.tsx b/ui/components/resources/skeleton/skeleton-finding-summary.tsx index 8d4c02d675..f3bc958c79 100644 --- a/ui/components/resources/skeleton/skeleton-finding-summary.tsx +++ b/ui/components/resources/skeleton/skeleton-finding-summary.tsx @@ -1,14 +1,16 @@ import React from "react"; export const SkeletonFindingSummary = () => { - return (
-
-
-
-
-
-
-
+ return ( +
+
+
+
+
+
+
-
); -} \ No newline at end of file +
+
+ ); +}; diff --git a/ui/components/resources/table/index.ts b/ui/components/resources/table/index.ts index c4b3f27f55..c8c06fca14 100644 --- a/ui/components/resources/table/index.ts +++ b/ui/components/resources/table/index.ts @@ -1,4 +1,4 @@ +export * from "../skeleton/skeleton-table-resources"; export * from "./column-resources"; export * from "./data-table-row-details"; export * from "./resource-detail"; -export * from "../skeleton/skeleton-table-resources"; diff --git a/ui/components/resources/table/resource-detail.tsx b/ui/components/resources/table/resource-detail.tsx index f3a421b13c..624c780b0f 100644 --- a/ui/components/resources/table/resource-detail.tsx +++ b/ui/components/resources/table/resource-detail.tsx @@ -11,6 +11,7 @@ import { } from "@/components/ui/entities"; import { SeverityBadge, StatusFindingBadge } from "@/components/ui/table"; import { ResourceApiResponse, ResourceProps } from "@/types"; + import { SkeletonFindingSummary } from "../skeleton/skeleton-finding-summary"; const renderValue = (value: string | null | undefined) => {