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:
@@ -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('');
|
||||
|
||||
Reference in New Issue
Block a user