feat: RBAC page reads cmd-k navigation state for tab switch and highlight

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-02 23:40:03 +02:00
parent 69ca52b25e
commit 146398b183
4 changed files with 66 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
import { useState, useMemo } from 'react';
import { useState, useMemo, useEffect } from 'react';
import {
Avatar,
Badge,
@@ -36,7 +36,7 @@ import type { UserDetail } from '../../api/queries/admin/rbac';
import { useAuthStore } from '../../auth/auth-store';
import styles from './UserManagement.module.css';
export default function UsersTab() {
export default function UsersTab({ highlightId, onHighlightConsumed }: { highlightId?: string | null; onHighlightConsumed?: () => void }) {
const { toast } = useToast();
const { data: users, isLoading } = useUsers();
const { data: allGroups } = useGroups();
@@ -49,6 +49,17 @@ export default function UsersTab() {
const [deleteTarget, setDeleteTarget] = useState<UserDetail | null>(null);
const [removeGroupTarget, setRemoveGroupTarget] = useState<string | null>(null);
// Auto-select highlighted item from cmd-k navigation
useEffect(() => {
if (highlightId && users) {
const match = users.find((u) => u.userId === highlightId);
if (match) {
setSelectedId(match.userId);
onHighlightConsumed?.();
}
}
}, [highlightId, users]); // eslint-disable-line react-hooks/exhaustive-deps
// Create form state
const [newUsername, setNewUsername] = useState('');
const [newDisplay, setNewDisplay] = useState('');