fix(ui): use shared scan launch action errors (#11664)

This commit is contained in:
Alejandro Bailo
2026-06-23 09:52:20 +02:00
committed by GitHub
parent 0610866b73
commit c6c07957a6
12 changed files with 278 additions and 21 deletions
@@ -24,6 +24,11 @@ import {
} from "@/components/shared/cloud-feature-badge";
import { ToastAction, useToast } from "@/components/ui";
import { EntityInfo } from "@/components/ui/entities";
import {
type ActionErrorResult,
getActionErrorMessage,
hasActionError,
} from "@/lib/action-errors";
import {
getScanScheduleCapability,
getScheduleFormDefaults,
@@ -129,7 +134,7 @@ export function LaunchStep({
}
}, [isAdvanced, mode]);
const launchOnDemandScan = async (): Promise<{ error?: unknown } | null> => {
const launchOnDemandScan = async (): Promise<ActionErrorResult | null> => {
if (!providerId || isBlocked) return null;
const formData = new FormData();
formData.set("providerId", providerId);
@@ -144,12 +149,12 @@ export function LaunchStep({
setIsLaunching(true);
const scanResult = await launchOnDemandScan();
if (scanResult?.error) {
if (hasActionError(scanResult)) {
setIsLaunching(false);
toast({
variant: "destructive",
title: "Unable to launch scan",
description: String(scanResult.error),
description: getActionErrorMessage(scanResult),
});
return;
}