mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 21:11:53 +00:00
feat(ui): filter scans by provider group
- Add the provider group selector to the Scan Jobs filter bar Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { Suspense } from "react";
|
||||
|
||||
import { getAllProviderGroups } from "@/actions/manage-groups/manage-groups";
|
||||
import { getAllProviders } from "@/actions/providers";
|
||||
import { getScans } from "@/actions/scans";
|
||||
import { getSchedules } from "@/actions/schedules";
|
||||
@@ -168,8 +169,12 @@ export default async function Scans({
|
||||
const session = await auth();
|
||||
const resolvedSearchParams = await searchParams;
|
||||
|
||||
const providersData = await getAllProviders();
|
||||
const [providersData, providerGroupsData] = await Promise.all([
|
||||
getAllProviders(),
|
||||
getAllProviderGroups(),
|
||||
]);
|
||||
const providers = providersData?.data ?? [];
|
||||
const providerGroups = providerGroupsData?.data ?? [];
|
||||
|
||||
const connectedProviders = providers.filter(
|
||||
(provider: ProviderProps) =>
|
||||
@@ -220,6 +225,7 @@ export default async function Scans({
|
||||
) : (
|
||||
<ScansPageShell
|
||||
providers={providers}
|
||||
providerGroups={providerGroups}
|
||||
hasManageScansPermission={hasManageScansPermission}
|
||||
activeScanCount={activeScanCount}
|
||||
>
|
||||
|
||||
@@ -9,6 +9,13 @@ vi.mock("@/components/filters/provider-account-selectors", () => ({
|
||||
ProviderAccountSelectors: () => <div>Provider account selectors</div>,
|
||||
}));
|
||||
|
||||
vi.mock(
|
||||
"@/app/(prowler)/_overview/_components/provider-group-selector",
|
||||
() => ({
|
||||
ProviderGroupSelector: () => <div>Provider group selector</div>,
|
||||
}),
|
||||
);
|
||||
|
||||
vi.mock("@/components/shadcn", () => ({
|
||||
Select: ({ children }: { children: React.ReactNode }) => (
|
||||
<div>{children}</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { ProviderGroupSelector } from "@/app/(prowler)/_overview/_components/provider-group-selector";
|
||||
import { ProviderAccountSelectors } from "@/components/filters/provider-account-selectors";
|
||||
import {
|
||||
Select,
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
SelectValue,
|
||||
} from "@/components/shadcn";
|
||||
import { SCAN_JOBS_TAB, type ScanJobsTab } from "@/types";
|
||||
import type { ProviderGroup } from "@/types/components";
|
||||
import type { ProviderProps } from "@/types/providers";
|
||||
|
||||
import {
|
||||
@@ -18,6 +20,7 @@ import {
|
||||
|
||||
interface ScansFilterBarProps {
|
||||
providers: ProviderProps[];
|
||||
providerGroups?: ProviderGroup[];
|
||||
activeTab: ScanJobsTab;
|
||||
scheduleType: string;
|
||||
scanStatus: string;
|
||||
@@ -30,6 +33,7 @@ const filterItemClass = "w-full md:w-[calc(50%-0.375rem)] xl:w-60";
|
||||
|
||||
export function ScansFilterBar({
|
||||
providers,
|
||||
providerGroups = [],
|
||||
activeTab,
|
||||
scheduleType,
|
||||
scanStatus,
|
||||
@@ -53,6 +57,13 @@ export function ScansFilterBar({
|
||||
accountSelectorClassName={filterItemClass}
|
||||
/>
|
||||
|
||||
<div className={filterItemClass}>
|
||||
<ProviderGroupSelector
|
||||
groups={providerGroups}
|
||||
paramsToDeleteOnChange={["page", "scanId"]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{showScheduleTypeFilter && (
|
||||
<Select value={scheduleType} onValueChange={onScheduleTypeChange}>
|
||||
<SelectTrigger aria-label="All Types" className={filterItemClass}>
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
import { buildViewFirstScanTour } from "@/lib/tours/view-first-scan.tour";
|
||||
import { useScansStore } from "@/store";
|
||||
import { SCAN_JOBS_TAB, SCAN_TAB_LABELS, type ScanJobsTab } from "@/types";
|
||||
import type { ProviderGroup } from "@/types/components";
|
||||
import type { ProviderProps } from "@/types/providers";
|
||||
import type { ScanScheduleCapability } from "@/types/schedules";
|
||||
|
||||
@@ -32,6 +33,7 @@ import { useScansFilters } from "./use-scans-filters";
|
||||
|
||||
interface ScansPageShellProps {
|
||||
providers: ProviderProps[];
|
||||
providerGroups?: ProviderGroup[];
|
||||
hasManageScansPermission: boolean;
|
||||
activeScanCount?: number;
|
||||
children: ReactNode;
|
||||
@@ -42,6 +44,7 @@ interface ScansPageShellProps {
|
||||
|
||||
export function ScansPageShell({
|
||||
providers,
|
||||
providerGroups = [],
|
||||
hasManageScansPermission,
|
||||
activeScanCount = 0,
|
||||
children,
|
||||
@@ -116,6 +119,7 @@ export function ScansPageShell({
|
||||
>
|
||||
<ScansFilterBar
|
||||
providers={providers}
|
||||
providerGroups={providerGroups}
|
||||
activeTab={filters.activeTab}
|
||||
scheduleType={filters.scheduleType}
|
||||
scanStatus={filters.scanStatus}
|
||||
|
||||
Reference in New Issue
Block a user