diff --git a/ui/components/providers/organizations/org-launch-scan.tsx b/ui/components/providers/organizations/org-launch-scan.tsx index 6ffaac0468..42528e23a8 100644 --- a/ui/components/providers/organizations/org-launch-scan.tsx +++ b/ui/components/providers/organizations/org-launch-scan.tsx @@ -1,17 +1,26 @@ "use client"; -import { CheckCircle2, Loader2 } from "lucide-react"; import { useRouter } from "next/navigation"; import { useEffect, useRef, useState } from "react"; -import { scheduleDaily } from "@/actions/scans/scans"; +import { scanOnDemand, scheduleDaily } from "@/actions/scans/scans"; +import { AWSProviderBadge } from "@/components/icons/providers-badge"; import { WIZARD_FOOTER_ACTION_TYPE, WizardFooterConfig, } from "@/components/providers/wizard/steps/footer-controls"; -import { Badge } from "@/components/shadcn"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/shadcn/select/select"; +import { TreeSpinner } from "@/components/shadcn/tree-view/tree-spinner"; +import { TreeStatusIcon } from "@/components/shadcn/tree-view/tree-status-icon"; import { useToast } from "@/components/ui"; import { useOrgSetupStore } from "@/store/organizations/store"; +import { TREE_ITEM_STATUS } from "@/types/tree"; interface OrgLaunchScanProps { onClose: () => void; @@ -19,6 +28,13 @@ interface OrgLaunchScanProps { onFooterChange: (config: WizardFooterConfig) => void; } +const SCAN_SCHEDULE = { + DAILY: "daily", + SINGLE: "single", +} as const; + +type ScanScheduleOption = (typeof SCAN_SCHEDULE)[keyof typeof SCAN_SCHEDULE]; + export function OrgLaunchScan({ onClose, onBack, @@ -26,14 +42,13 @@ export function OrgLaunchScan({ }: OrgLaunchScanProps) { const router = useRouter(); const { toast } = useToast(); - const { - organizationName, - organizationExternalId, - createdProviderIds, - reset, - } = useOrgSetupStore(); + const { organizationExternalId, createdProviderIds, reset } = + useOrgSetupStore(); const [isLaunching, setIsLaunching] = useState(false); + const [scheduleOption, setScheduleOption] = useState( + SCAN_SCHEDULE.DAILY, + ); const launchActionRef = useRef<() => void>(() => {}); const handleLaunchScan = async () => { @@ -45,7 +60,10 @@ export function OrgLaunchScan({ const formData = new FormData(); formData.set("providerId", providerId); - const result = await scheduleDaily(formData); + const result = + scheduleOption === SCAN_SCHEDULE.DAILY + ? await scheduleDaily(formData) + : await scanOnDemand(formData); if (!result?.error) { successCount++; } @@ -58,7 +76,10 @@ export function OrgLaunchScan({ toast({ title: "Scan Launched", - description: `Daily scan scheduled for ${successCount} account${successCount !== 1 ? "s" : ""}.`, + description: + scheduleOption === SCAN_SCHEDULE.DAILY + ? `Daily scan scheduled for ${successCount} account${successCount !== 1 ? "s" : ""}.` + : `Single scan launched for ${successCount} account${successCount !== 1 ? "s" : ""}.`, }); }; @@ -73,7 +94,7 @@ export function OrgLaunchScan({ backDisabled: isLaunching, onBack, showAction: true, - actionLabel: isLaunching ? "Launching..." : "Launch scan", + actionLabel: "Launch scan", actionDisabled: isLaunching, actionType: WIZARD_FOOTER_ACTION_TYPE.BUTTON, onAction: () => { @@ -83,39 +104,68 @@ export function OrgLaunchScan({ }, [isLaunching, onBack, onFooterChange]); return ( -
- {/* Org info */} -
- AWS - {organizationName} - {organizationExternalId && ( - {organizationExternalId} - )} -
+
+
+
+ +

My Organization

+
- {/* Success message */} -
- -

Accounts Connected!

-

- Your accounts are connected to Prowler and ready to scan! -

-
- - {/* Scan schedule info */} -
-

- Select a Prowler scan schedule for these accounts. -

-
- Scan Daily (every 24 hours) +
+ UID: +
+ + {organizationExternalId || "N/A"} + +
- {isLaunching && ( -
- - Launching scans... + {isLaunching ? ( +
+
+ +

Launching scans...

+
+
+ ) : ( +
+
+ +

Accounts Connected!

+
+ +

+ Your accounts are connected to Prowler and ready to Scan! +

+ +
+

+ Select a Prowler scan schedule for these accounts. +

+ +
)}