From a20f4bb21f02035eb303ceed4b70b8048c55f664 Mon Sep 17 00:00:00 2001 From: alejandrobailo Date: Thu, 18 Dec 2025 12:01:58 +0100 Subject: [PATCH] feat: revert muted finding filter checkbox behavior --- .../_components/advanced-mutelist-form.tsx | 241 +++++++++--------- .../custom-checkbox-muted-findings.tsx | 65 +++-- .../saml/saml-integration-card.tsx | 48 +++- ui/lib/menu-list.ts | 2 +- ui/middleware.ts | 14 + 5 files changed, 221 insertions(+), 149 deletions(-) diff --git a/ui/app/(prowler)/mutelist/_components/advanced-mutelist-form.tsx b/ui/app/(prowler)/mutelist/_components/advanced-mutelist-form.tsx index 1251de6f85..6309d1f0af 100644 --- a/ui/app/(prowler)/mutelist/_components/advanced-mutelist-form.tsx +++ b/ui/app/(prowler)/mutelist/_components/advanced-mutelist-form.tsx @@ -1,6 +1,7 @@ "use client"; import { Textarea } from "@heroui/input"; +import { Trash2 } from "lucide-react"; import { useActionState, useEffect, useState } from "react"; import { @@ -9,9 +10,9 @@ import { getMutedFindingsConfig, updateMutedFindingsConfig, } from "@/actions/processors"; -import { DeleteIcon } from "@/components/icons"; import { Button, Card, Skeleton } from "@/components/shadcn"; import { useToast } from "@/components/ui"; +import { CustomAlertModal } from "@/components/ui/custom"; import { CustomLink } from "@/components/ui/custom/custom-link"; import { fontMono } from "@/config/fonts"; import { @@ -36,10 +37,22 @@ export function AdvancedMutelistForm() { }>({ isValid: true }); const [hasUserStartedTyping, setHasUserStartedTyping] = useState(false); + // Unified action that decides to create or update based on ID presence + const saveConfig = async ( + _prevState: MutedFindingsConfigActionState, + formData: FormData, + ): Promise => { + const id = formData.get("id"); + if (id) { + return updateMutedFindingsConfig(_prevState, formData); + } + return createMutedFindingsConfig(_prevState, formData); + }; + const [state, formAction, isPending] = useActionState< MutedFindingsConfigActionState, FormData - >(config ? updateMutedFindingsConfig : createMutedFindingsConfig, null); + >(saveConfig, null); const { toast } = useToast(); @@ -62,6 +75,10 @@ export function AdvancedMutelistForm() { title: "Configuration saved successfully", description: state.success, }); + // Reload config to get the created/updated data (shows Delete button) + getMutedFindingsConfig().then((result) => { + setConfig(result || null); + }); } else if (state?.errors?.general) { toast({ variant: "destructive", @@ -123,7 +140,7 @@ export function AdvancedMutelistForm() { -
+
@@ -132,23 +149,24 @@ export function AdvancedMutelistForm() { ); } - if (showDeleteConfirmation) { - return ( - + return ( + <> + {/* Delete Confirmation Modal */} +
-

- Delete Mutelist Configuration -

Are you sure you want to delete this configuration? This action cannot be undone.

-
+
- - ); - } + - return ( - -
- {config && } + + + {config && } -
-
-

- Advanced Mutelist Configuration -

-
    -
  • - - This Mutelist configuration will take effect on the next scan. - -
  • -
  • - Use this for pattern-based muting with wildcards, regions, and - tags. -
  • -
  • - Learn more about configuring the Mutelist{" "} - - here - - . -
  • -
  • - A default Mutelist is used to exclude certain predefined - resources if no Mutelist is provided. -
  • -
-
- -
- +
-