/** * Version Warning Component * * Displays warnings about API version compatibility and issues. */ import { Alert, Box, Button, Link } from '@mui/material'; import React from 'react'; import { SealedSecret } from '../lib/SealedSecretCRD'; export interface VersionWarningProps { /** Whether to auto-detect version on mount */ autoDetect?: boolean; /** Whether to show detailed version information */ showDetails?: boolean; } /** * Component that detects and displays API version information * * Shows warnings if: * - CRD is not installed * - Version detection fails * - Using non-default version (informational) */ export function VersionWarning({ autoDetect = true, showDetails = false }: VersionWarningProps) { const [loading, setLoading] = React.useState(true); const [detectedVersion, setDetectedVersion] = React.useState(null); const [error, setError] = React.useState(null); const detectVersion = React.useCallback(async () => { setLoading(true); setError(null); try { const result = await SealedSecret.detectApiVersion(); if (result.ok) { setDetectedVersion(result.value); setError(null); } else if (result.ok === false) { setDetectedVersion(null); // Ensure error is always a string const errorMessage = typeof result.error === 'string' ? result.error : String(result.error); setError(errorMessage); } } catch (e) { // Catch any unexpected errors setDetectedVersion(null); setError(e instanceof Error ? e.message : String(e)); } setLoading(false); }, []); React.useEffect(() => { if (autoDetect) { detectVersion(); } }, [autoDetect, detectVersion]); // Don't show anything while loading if (loading) { return null; } // Show error if detection failed if (error) { return ( Retry } > API Version Detection Failed
{String(error)} {String(error).includes('not found') && ( <>

Install Sealed Secrets with:{' '} kubectl apply -f https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.24.0/controller.yaml
Or visit:{' '} github.com/bitnami-labs/sealed-secrets )}
); } // Show informational message if using non-default version if (detectedVersion && detectedVersion !== SealedSecret.DEFAULT_VERSION) { return ( API Version Detected
Using API version: {detectedVersion} {showDetails && ( <>
Default version: {SealedSecret.DEFAULT_VERSION} )}
); } // Show success if explicitly showing details if (showDetails && detectedVersion) { return ( API Version Detected
Using API version: {detectedVersion}
); } // Default: show nothing (version detected successfully) return null; }