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
13 changes: 10 additions & 3 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, useMemo } 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 @@ -167,7 +167,7 @@ function formReducer(state: FormState, action: FormAction): FormState {
function CanICheckerContent() {
const { t } = useTranslation('common')
const { deduplicatedClusters: rawClusters } = useClusters()
const clusters = rawClusters.map(c => c.name)
const clusters = useMemo(() => rawClusters.map(c => c.name), [rawClusters])
const { checkPermission, checking, result, error, reset } = useCanI()

const [form, dispatch] = useReducer(formReducer, INITIAL_FORM_STATE)
Expand All @@ -177,7 +177,14 @@ function CanICheckerContent() {
selectedUserGroups, customUserGroup, showAdvanced, checkedSnapshot,
} = form

// Get selected cluster for namespace fetching — only after the user makes an explicit choice
// Auto-select the 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] })
}
}, [cluster, clusters])
Comment on lines +181 to +185

// Get selected cluster for namespace fetching
const selectedCluster = cluster
const { namespaces } = useNamespaces(selectedCluster)

Expand Down
Loading