fix(navigation): expose work area and preserve authorised menu destinations in QA
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-28 20:08:54 +02:00
parent 77d133ef0e
commit 6e8de43ae7
13 changed files with 1416 additions and 66 deletions
+17 -35
View File
@@ -1,10 +1,8 @@
import { profileLinks } from '@/components/profile-navigation';
import {PortalSidebarNavigation} from '@/components/portal-sidebar-navigation';
import type { ProfileAccess } from '@/types/profile-access';
import { Link, usePage } from '@inertiajs/react';
import { LayoutGrid } from 'lucide-react';
import { portalNavigation } from '@/lib/portal-navigation';
import { portalNavigation,canShowLegacyManagement } from '@/lib/portal-navigation';
import AppLogo from '@/components/app-logo';
import { NavMain } from '@/components/nav-main';
import { NavUser } from '@/components/nav-user';
import {
Sidebar,
@@ -20,6 +18,7 @@ import type { Auth } from '@/types';
import type { OpportunityManagementAccess } from '@/types/opportunity-management';
export function AppSidebar() {
const currentPage=usePage();
const {
auth,
existingBusinessEnabled,
@@ -27,7 +26,9 @@ export function AppSidebar() {
aiEnabled,
opportunityManagement,
contentManagementHref,
contentManagementAccess,
profileAccess,
scopedAdministration,
} = usePage<{
auth: Auth;
existingBusinessEnabled?: boolean;
@@ -36,45 +37,26 @@ export function AppSidebar() {
profileAccess?: ProfileAccess | null;
opportunityManagement?: OpportunityManagementAccess | null;
contentManagementHref?: string | null;
scopedAdministration?: {label:string;href:string}[];
contentManagementAccess?: {opportunities?:{index:string;create?:string|null}};
}>().props;
const groups = portalNavigation({
authenticated: !!auth.user,
manager: auth.canManagePortal,
manager: canShowLegacyManagement(auth),
businesses: existingBusinessEnabled,
education: educationEnabled,
ai: aiEnabled,
opportunityManagement,
profileAccess,
contentManagementHref,
contentManagementAccess,
scopedAdministration,
legacyContent: currentPage.props.legacyContentEnabled as boolean|undefined,
procurement: currentPage.props.procurementEnabled as boolean|undefined,
businessReviewUrl: currentPage.props.businessReviewUrl as string|null|undefined,
});
const items = groups.map((group) => ({
title: group.label,
href: group.children?.find((item) => item.href)?.href ?? '/',
icon: LayoutGrid,
}));
if (contentManagementHref) {
items.unshift({ title: 'Gestão de conteúdos e oportunidades', href: contentManagementHref, icon: LayoutGrid });
}
if (auth.canManagePortal && opportunityManagement) {
items.push({
title: opportunityManagement.manage.label,
href: opportunityManagement.manage.href,
icon: LayoutGrid,
});
if (opportunityManagement.installed) {
items.push({
title: opportunityManagement.create.label,
href: opportunityManagement.create.href,
icon: LayoutGrid,
});
}
}
items.push(
...profileLinks(profileAccess).map((link) => ({
...link,
icon: LayoutGrid,
})),
);
return (
<Sidebar collapsible="icon" variant="inset">
<Sidebar collapsible="offcanvas" variant="inset">
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem>
@@ -88,7 +70,7 @@ export function AppSidebar() {
</SidebarHeader>
<SidebarContent>
<NavMain items={items} />
<PortalSidebarNavigation groups={groups} url={currentPage.url}/>
</SidebarContent>
<SidebarFooter>
+10 -12
View File
@@ -31,6 +31,7 @@ import {
} from '@/components/ui/dropdown-menu';
import {
portalNavigation,
canShowLegacyManagement,
currentNavigationGroup,
currentNavigationItem,
} from '@/lib/portal-navigation';
@@ -44,6 +45,7 @@ export function PortalGroupedMenu() {
auth: {
user: { name?: string; email?: string } | null;
canManagePortal: boolean;
legacyManagementAccess?:boolean;
};
existingBusinessEnabled?: boolean;
businessReviewUrl?: string | null;
@@ -54,6 +56,8 @@ export function PortalGroupedMenu() {
profileAccess?: ProfileAccess | null;
opportunityManagement?: OpportunityManagementAccess | null;
scopedAdministration?: { label: string; href: string }[];
contentManagementHref?: string | null;
contentManagementAccess?: {opportunities?:{index:string;create?:string|null}};
}>();
const { t, language, requestCount } = useTempoUi();
const mobile = useIsMobile();
@@ -63,7 +67,7 @@ export function PortalGroupedMenu() {
? { id: navigation.active, ...navigation.view.tools }
: undefined,
authenticated: !!props.auth?.user,
manager: !!props.auth?.canManagePortal,
manager: canShowLegacyManagement(props.auth),
businesses: props.existingBusinessEnabled,
businessReviewUrl: props.businessReviewUrl,
education: props.educationEnabled,
@@ -72,17 +76,10 @@ export function PortalGroupedMenu() {
legacyContent: props.legacyContentEnabled,
opportunityManagement: props.opportunityManagement,
profileAccess: props.profileAccess,
contentManagementHref: props.contentManagementHref,
contentManagementAccess: props.contentManagementAccess,
scopedAdministration: props.scopedAdministration,
});
if (props.scopedAdministration?.length)
groups.push({
id: 'scoped-administration',
label: 'Administração',
children: props.scopedAdministration.map((item, index) => ({
id: `scoped-${index}`,
label: item.label,
href: item.href,
})),
});
const current = currentNavigationGroup(groups, url);
const currentItem = currentNavigationItem(groups, url);
const [loggingOut, setLoggingOut] = useState(false);
@@ -134,7 +131,7 @@ export function PortalGroupedMenu() {
);
const accountGroups = groups.filter(
(group) =>
!['home', 'discovery', 'realization', 'support'].includes(group.id),
!['home', 'discovery', 'realization', 'support','work'].includes(group.id),
);
const panelLabel = `${t('O meu painel')} — ${requestCount} ${t(requestCount === 1 ? 'pedido recebido' : 'pedidos recebidos')}`;
const institutionalCurrent = url.split('?')[0] === '/contacto';
@@ -200,6 +197,7 @@ export function PortalGroupedMenu() {
'discovery',
'realization',
'support',
'work',
].includes(group.id),
)
.map((group) => (
@@ -0,0 +1,17 @@
import {Link} from '@inertiajs/react';
import {LayoutGrid} from 'lucide-react';
import type {ReactNode} from 'react';
import type {PortalNavItem} from '@/lib/portal-navigation';
import {currentNavigationItem} from '@/lib/portal-navigation';
import {searchTerritoryHref} from '@/lib/search-territory';
import {SidebarGroup,SidebarGroupLabel,SidebarMenu,SidebarMenuButton,SidebarMenuItem} from '@/components/ui/sidebar';
/** Render every authorised destination; a group is never reduced to its first link. */
export function PortalSidebarNavigation({groups,url}:{groups:PortalNavItem[];url:string}){
const active=currentNavigationItem(groups,url);
const ordered=[...groups.filter(group=>group.id==='work'),...groups.filter(group=>group.id!=='work')];
const links=(items:PortalNavItem[],depth=0):ReactNode=>items.map(item=>item.children?
<li key={item.id} className="list-none"><p className="px-2 pt-3 pb-1 text-xs font-medium text-muted-foreground">{item.label}</p><ul className="ml-2 border-l pl-2">{links(item.children,depth+1)}</ul></li>:
item.href?<SidebarMenuItem key={item.id}><SidebarMenuButton asChild isActive={item.id===active} className="h-auto min-h-8 whitespace-normal py-2"><Link href={searchTerritoryHref(item.href,url)} aria-current={item.id===active?'page':undefined}>{depth===0&&<LayoutGrid aria-hidden="true"/>}<span className="min-w-0 flex-1" style={{whiteSpace:'normal',overflow:'visible',textOverflow:'clip',overflowWrap:'anywhere'}}>{item.label}</span></Link></SidebarMenuButton></SidebarMenuItem>:null);
return <nav aria-label="Navegação completa do portal">{ordered.map(group=><SidebarGroup key={group.id}><SidebarGroupLabel>{group.label}</SidebarGroupLabel><SidebarMenu>{links(group.children??[])}</SidebarMenu></SidebarGroup>)}</nav>;
}