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,
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
import type { RoleDetail } from '../../api/queries/admin/rbac';
|
||||
import styles from './UserManagement.module.css';
|
||||
|
||||
export default function RolesTab() {
|
||||
export default function RolesTab({ highlightId, onHighlightConsumed }: { highlightId?: string | null; onHighlightConsumed?: () => void }) {
|
||||
const { toast } = useToast();
|
||||
const { data: roles, isLoading } = useRoles();
|
||||
|
||||
@@ -31,6 +31,17 @@ export default function RolesTab() {
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [deleteTarget, setDeleteTarget] = useState<RoleDetail | null>(null);
|
||||
|
||||
// Auto-select highlighted item from cmd-k navigation
|
||||
useEffect(() => {
|
||||
if (highlightId && roles) {
|
||||
const match = roles.find((r) => r.id === highlightId);
|
||||
if (match) {
|
||||
setSelectedId(match.id);
|
||||
onHighlightConsumed?.();
|
||||
}
|
||||
}
|
||||
}, [highlightId, roles]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Create form state
|
||||
const [newName, setNewName] = useState('');
|
||||
const [newDesc, setNewDesc] = useState('');
|
||||
|
||||
Reference in New Issue
Block a user