feat: handle admin cmd-k selection with tab navigation state
This commit is contained in:
@@ -503,30 +503,47 @@ function LayoutContent() {
|
||||
navigate('/login');
|
||||
}, [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) => {
|
||||
if (result.path) {
|
||||
const state: Record<string, unknown> = { sidebarReveal: result.path };
|
||||
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],
|
||||
};
|
||||
if (ADMIN_CATEGORIES.has(result.category)) {
|
||||
const itemId = result.id.split(':').slice(1).join(':');
|
||||
navigate(result.path, {
|
||||
state: { tab: ADMIN_TAB_MAP[result.category], highlight: itemId },
|
||||
});
|
||||
} else {
|
||||
const state: Record<string, unknown> = { sidebarReveal: result.path };
|
||||
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);
|
||||
}, [navigate, setPaletteOpen]);
|
||||
|
||||
const handlePaletteSubmit = useCallback((query: string) => {
|
||||
const baseParts = ['/exchanges'];
|
||||
if (scope.appId) baseParts.push(scope.appId);
|
||||
if (scope.routeId) baseParts.push(scope.routeId);
|
||||
navigate(`${baseParts.join('/')}?text=${encodeURIComponent(query)}`);
|
||||
}, [navigate, scope.appId, scope.routeId]);
|
||||
if (isAdminPage) {
|
||||
// Navigate to top result — CommandPalette calls onSelect for the top result
|
||||
// when Enter is pressed, so this is only reached if there are no results.
|
||||
// Navigate to RBAC page as fallback.
|
||||
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 state = { sidebarReveal: path };
|
||||
|
||||
Reference in New Issue
Block a user