diff --git a/web/src/components/namespaces/CreateNamespaceModal.tsx b/web/src/components/namespaces/CreateNamespaceModal.tsx index 879772bd75..f758ca05c5 100644 --- a/web/src/components/namespaces/CreateNamespaceModal.tsx +++ b/web/src/components/namespaces/CreateNamespaceModal.tsx @@ -15,7 +15,7 @@ interface CreateNamespaceModalProps { export function CreateNamespaceModal({ clusters, onClose, onCreated }: CreateNamespaceModalProps) { const { t } = useTranslation() const [name, setName] = useState('') - const [cluster, setCluster] = useState('') + const [cluster, setCluster] = useState(clusters[0] ?? '') const [teamLabel, setTeamLabel] = useState('') const [creating, setCreating] = useState(false) const [error, setError] = useState(null) diff --git a/web/src/components/rbac/CanIChecker.tsx b/web/src/components/rbac/CanIChecker.tsx index be66c72fe7..5a018a65e9 100644 --- a/web/src/components/rbac/CanIChecker.tsx +++ b/web/src/components/rbac/CanIChecker.tsx @@ -1,4 +1,4 @@ -import { useReducer } from 'react' +import { useReducer, useEffect } from 'react' import { Shield, Check, X, Loader2, AlertCircle, ChevronDown } from 'lucide-react' import { useCanI } from '../../hooks/usePermissions' import { useClusters, useNamespaces } from '../../hooks/useMCP' @@ -177,6 +177,13 @@ function CanICheckerContent() { selectedUserGroups, customUserGroup, showAdvanced, checkedSnapshot, } = form + // Auto-select first cluster when clusters load and none is selected yet + useEffect(() => { + if (cluster === '' && clusters.length > 0) { + dispatch({ type: 'SET_FIELD', field: 'cluster', value: clusters[0] }) + } + }, [clusters, cluster]) + // Get selected cluster for namespace fetching — only after the user makes an explicit choice const selectedCluster = cluster const { namespaces } = useNamespaces(selectedCluster) @@ -265,7 +272,6 @@ function CanICheckerContent() { className="w-full p-2 rounded-lg bg-secondary border border-border text-foreground focus:outline-hidden focus:ring-2 focus:ring-blue-500 appearance-none pr-8" data-testid="can-i-cluster" > - {clusters.map((c) => ( ))}