Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/src/components/namespaces/CreateNamespaceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | null>(null)
Expand Down
10 changes: 8 additions & 2 deletions web/src/components/rbac/CanIChecker.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Comment on lines 187 to 189
Expand Down Expand Up @@ -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"
>
<option value="" disabled>{t('common.selectCluster', 'Select a cluster')}</option>
{clusters.map((c) => (
<option key={c} value={c}>{c}</option>
))}
Expand Down
Loading