feat: handle admin cmd-k selection with tab navigation state

This commit is contained in:
hsiegeln
2026-04-02 23:38:06 +02:00
parent 111bcc302d
commit 69ca52b25e

View File

@@ -503,30 +503,47 @@ function LayoutContent() {
navigate('/login'); navigate('/login');
}, [logout, navigate]); }, [logout, navigate]);
const ADMIN_CATEGORIES = new Set(['user', 'group', 'role']);
const ADMIN_TAB_MAP: Record<string, string> = { user: 'users', group: 'groups', role: 'roles' };
const handlePaletteSelect = useCallback((result: any) => { const handlePaletteSelect = useCallback((result: any) => {
if (result.path) { if (result.path) {
const state: Record<string, unknown> = { sidebarReveal: result.path }; if (ADMIN_CATEGORIES.has(result.category)) {
if (result.category === 'exchange' || result.category === 'attribute') { const itemId = result.id.split(':').slice(1).join(':');
const parts = result.path.split('/').filter(Boolean); navigate(result.path, {
if (parts.length === 4 && parts[0] === 'exchanges') { state: { tab: ADMIN_TAB_MAP[result.category], highlight: itemId },
state.selectedExchange = { });
executionId: parts[3], } else {
applicationId: parts[1], const state: Record<string, unknown> = { sidebarReveal: result.path };
routeId: parts[2], if (result.category === 'exchange' || result.category === 'attribute') {
}; const parts = result.path.split('/').filter(Boolean);
if (parts.length === 4 && parts[0] === 'exchanges') {
state.selectedExchange = {
executionId: parts[3],
applicationId: parts[1],
routeId: parts[2],
};
}
} }
navigate(result.path, { state });
} }
navigate(result.path, { state });
} }
setPaletteOpen(false); setPaletteOpen(false);
}, [navigate, setPaletteOpen]); }, [navigate, setPaletteOpen]);
const handlePaletteSubmit = useCallback((query: string) => { const handlePaletteSubmit = useCallback((query: string) => {
const baseParts = ['/exchanges']; if (isAdminPage) {
if (scope.appId) baseParts.push(scope.appId); // Navigate to top result — CommandPalette calls onSelect for the top result
if (scope.routeId) baseParts.push(scope.routeId); // when Enter is pressed, so this is only reached if there are no results.
navigate(`${baseParts.join('/')}?text=${encodeURIComponent(query)}`); // Navigate to RBAC page as fallback.
}, [navigate, scope.appId, scope.routeId]); navigate('/admin/rbac');
} else {
const baseParts = ['/exchanges'];
if (scope.appId) baseParts.push(scope.appId);
if (scope.routeId) baseParts.push(scope.routeId);
navigate(`${baseParts.join('/')}?text=${encodeURIComponent(query)}`);
}
}, [isAdminPage, navigate, scope.appId, scope.routeId]);
const handleSidebarNavigate = useCallback((path: string) => { const handleSidebarNavigate = useCallback((path: string) => {
const state = { sidebarReveal: path }; const state = { sidebarReveal: path };