Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(profile-ui): preserve active access navigation
Josué69954715a9bf
diff --git a/profile-ui/app/components/Sidebar/index.tsx b/profile-ui/app/components/Sidebar/index.tsxindex 7458ca4ca..4f14a4922 100644--- a/profile-ui/app/components/Sidebar/index.tsx+++ b/profile-ui/app/components/Sidebar/index.tsx@@ -43,7 +43,7 @@ export function Sidebar({ currentRoute, isOpen = false, onNavigate, onLogout }:{navigationItems.map(([routeKey, item]) => {const accessLoading =(routeKey === 'members' && manageableTeamsLoading && !canManageMembers) ||- (routeKey === 'approvalChannels' && approvalTargetsLoading)+ (routeKey === 'approvalChannels' && approvalTargetsLoading && !hasExternalChannelAccess)const accessDenied =(routeKey === 'members' && !canManageMembers) ||(routeKey === 'approvalChannels' && !hasExternalChannelAccess)diff --git a/profile-ui/app/components/__tests__/Sidebar.test.tsx b/profile-ui/app/components/__tests__/Sidebar.test.tsxnew file mode 100644index 000000000..f6f70798a--- /dev/null+++ b/profile-ui/app/components/__tests__/Sidebar.test.tsx@@ -0,0 +1,77 @@+import React from 'react'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import '@testing-library/jest-dom/vitest'+import { cleanup, render, screen } from '@testing-library/react'+import { Sidebar } from '@components/Sidebar'++const profileAccessState = vi.hoisted(() => ({+ approvalTargets: [] as Array<{ id: string }>,+ approvalTargetsError: false,+ approvalTargetsLoading: false,+ canManageMembers: false,+ manageableTeams: [],+ manageableTeamsError: false,+ manageableTeamsLoading: false,+ refreshApprovalTargets: vi.fn(),+ refreshManageableTeams: vi.fn(),+}))++vi.mock('next/image', () => ({+ default: ({ alt = '', ...props }: React.ImgHTMLAttributes<HTMLImageElement>) => (+ // eslint-disable-next-line @next/next/no-img-element+ <img alt={alt} {...props} />+ ),+}))++vi.mock('next/link', () => ({+ default: ({+ children,+ href,+ ...props+ }: React.AnchorHTMLAttributes<HTMLAnchorElement> & { href: string }) => (+ <a href={href} {...props}>+ {children}+ </a>+ ),+}))++vi.mock('@components/ProfileAccessContext', () => ({+ useProfileAccess: () => profileAccessState,+}))++beforeEach(() => {+ profileAccessState.approvalTargets = []+ profileAccessState.approvalTargetsError = false+ profileAccessState.approvalTargetsLoading = false+ profileAccessState.canManageMembers = false+ profileAccessState.manageableTeams = []+ profileAccessState.manageableTeamsError = false+ profileAccessState.manageableTeamsLoading = false+ profileAccessState.refreshApprovalTargets.mockClear()+ profileAccessState.refreshManageableTeams.mockClear()+})++afterEach(cleanup)++describe('Profile Sidebar access-controlled entries', () => {+ it('keeps the active approval-channel entry visible during a known-access refresh', () => {+ profileAccessState.approvalTargets = [{ id: 'slack-target' }]+ profileAccessState.approvalTargetsLoading = true++ const view = render(<Sidebar currentRoute="approvalChannels" onLogout={vi.fn()} />)++ const approvalLink = screen.getByRole('link', { name: /Approval Channels/i })+ expect(approvalLink).toHaveAttribute('aria-current', 'page')+ expect(approvalLink).toHaveAttribute('data-active', 'true')+ expect(view.container.querySelector('.cu-sidebar__item--loading')).not.toBeInTheDocument()+ })++ it('keeps initial approval-channel access unresolved behind a loading placeholder', () => {+ profileAccessState.approvalTargetsLoading = true++ const view = render(<Sidebar currentRoute="approvalChannels" onLogout={vi.fn()} />)++ expect(screen.queryByRole('link', { name: /Approval Channels/i })).not.toBeInTheDocument()+ expect(view.container.querySelector('.cu-sidebar__item--loading')).toBeInTheDocument()+ })+})diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.jsonindex ad789d543..03cfe1675 100644--- a/profile-ui/package-lock.json+++ b/profile-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-profile-ui",- "version": "0.1.112",+ "version": "0.1.113","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-profile-ui",- "version": "0.1.112",+ "version": "0.1.113","dependencies": {"next": "16.2.11","react": "^18.3.1",diff --git a/profile-ui/package.json b/profile-ui/package.jsonindex 268971420..eaac7331b 100644--- a/profile-ui/package.json+++ b/profile-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-profile-ui",- "version": "0.1.112",+ "version": "0.1.113","private": true,"scripts": {"dev": "next dev",