import { useActionQuery } from "@agent-native/core/client/hooks"; import { ActionQueryError } from "./action-query-error"; import { Badge } from "./ui/badge"; import { Skeleton } from "./ui/skeleton"; import { formatResourceTimestamp } from "./workspace-resource-effective-stack"; function isApprovalRequest(result: any): boolean { return ( result?.status === "pending" && typeof result?.changeType === "string" && result.changeType.startsWith("workspace-resource.") ); } export function workspaceResourceMutationMessage( result: any, fallback: string, ): string { return isApprovalRequest(result) ? "Approval requested" : fallback; } export function ImpactPreview({ operation, resourceId, path, scope, enabled = true, }: { operation: "create" | "update" | "delete"; resourceId?: string; path?: string; scope?: "all" | "selected"; enabled?: boolean; }) { const query = useActionQuery( "preview-workspace-resource-change", { operation, resourceId, path, scope, }, { enabled: enabled && Boolean(resourceId || path) }, ); const { data: impact, isLoading } = query; if (!enabled || (!resourceId && !path)) return null; if (isLoading) { return (
{affectsAllApps ? `This change applies to every workspace app${typeof appCount === "number" ? ` (${appCount} discovered)` : ""}.` : "This change only applies to explicitly granted apps."}{" "} {willRequestApproval ? "It will be queued for approval before it takes effect." : "It will take effect immediately when saved."}
{overrides.count > 0 ? (