Separate dashboard functions from grouped administration operations
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -33,6 +33,7 @@ export function AppSidebar() {
|
||||
profileAccess,
|
||||
scopedAdministration,
|
||||
dashboardNavigation,
|
||||
administrationNavigation,
|
||||
} = usePage<{
|
||||
auth: Auth;
|
||||
existingBusinessEnabled?: boolean;
|
||||
@@ -43,6 +44,7 @@ export function AppSidebar() {
|
||||
contentManagementHref?: string | null;
|
||||
scopedAdministration?: { label: string; href: string }[];
|
||||
dashboardNavigation?: { label: string; href: string }[];
|
||||
administrationNavigation?: { label: string; href: string }[];
|
||||
contentManagementAccess?: {
|
||||
opportunities?: { index: string; create?: string | null };
|
||||
};
|
||||
@@ -59,6 +61,7 @@ export function AppSidebar() {
|
||||
contentManagementAccess,
|
||||
scopedAdministration,
|
||||
dashboardNavigation,
|
||||
administrationNavigation,
|
||||
legacyContent: currentPage.props.legacyContentEnabled as
|
||||
| boolean
|
||||
| undefined,
|
||||
|
||||
@@ -54,6 +54,7 @@ export function PortalGroupedMenu() {
|
||||
opportunityManagement?: OpportunityManagementAccess | null;
|
||||
scopedAdministration?: { label: string; href: string }[];
|
||||
dashboardNavigation?: { label: string; href: string }[];
|
||||
administrationNavigation?: { label: string; href: string }[];
|
||||
contentManagementHref?: string | null;
|
||||
contentManagementAccess?: {
|
||||
opportunities?: { index: string; create?: string | null };
|
||||
@@ -81,6 +82,7 @@ export function PortalGroupedMenu() {
|
||||
contentManagementAccess: props.contentManagementAccess,
|
||||
scopedAdministration: props.scopedAdministration,
|
||||
dashboardNavigation: props.dashboardNavigation,
|
||||
administrationNavigation: props.administrationNavigation,
|
||||
});
|
||||
const current = currentNavigationGroup(groups, url);
|
||||
const currentItem = currentNavigationItem(groups, url);
|
||||
|
||||
@@ -22,8 +22,11 @@ export function PortalSidebarNavigation({
|
||||
}) {
|
||||
const active = currentNavigationItem(groups, url);
|
||||
const ordered = [
|
||||
...groups.filter((group) => group.id === 'administration'),
|
||||
...groups.filter((group) => group.id === 'work'),
|
||||
...groups.filter((group) => group.id !== 'work'),
|
||||
...groups.filter(
|
||||
(group) => group.id !== 'work' && group.id !== 'administration',
|
||||
),
|
||||
];
|
||||
const links = (items: PortalNavItem[], depth = 0): ReactNode =>
|
||||
items.map((item) =>
|
||||
|
||||
@@ -14,6 +14,7 @@ export type PortalNavAccess = {
|
||||
};
|
||||
scopedAdministration?: { label: string; href: string }[];
|
||||
dashboardNavigation?: { label: string; href: string }[];
|
||||
administrationNavigation?: { label: string; href: string }[];
|
||||
procurement?: boolean;
|
||||
funding?: boolean;
|
||||
authenticated: boolean;
|
||||
@@ -422,7 +423,9 @@ export function currentNavigationGroup(
|
||||
for (const [key, value] of target.searchParams)
|
||||
if (current.searchParams.get(key) !== value) return;
|
||||
const score =
|
||||
target.pathname.length + target.searchParams.size * 100;
|
||||
target.pathname.length +
|
||||
target.searchParams.size * 100 +
|
||||
(target.hash ? 10000 : 0);
|
||||
if (!match || score > match.score) match = { group, score };
|
||||
});
|
||||
for (const group of groups) visit(group.children ?? [], group.id);
|
||||
@@ -449,7 +452,7 @@ export function currentNavigationItem(
|
||||
)
|
||||
)
|
||||
continue;
|
||||
const score = target.searchParams.size;
|
||||
const score = target.searchParams.size + (target.hash ? 10000 : 0);
|
||||
if (score > best.score) {
|
||||
best.id = item.id;
|
||||
best.score = score;
|
||||
@@ -479,43 +482,125 @@ export function portalNavigation(access: PortalNavAccess): PortalNavItem[] {
|
||||
: null)
|
||||
: null;
|
||||
const dashboardActivities = access.authenticated
|
||||
? [
|
||||
...(access.dashboardNavigation ?? []),
|
||||
...previous
|
||||
? access.dashboardNavigation?.length
|
||||
? access.dashboardNavigation
|
||||
: previous
|
||||
.filter((group) => group.id === 'account')
|
||||
.flatMap((group) => group.children ?? [])
|
||||
.filter((item) => item.href === '/dashboard')
|
||||
.map((item) => ({
|
||||
label: 'Painel operacional',
|
||||
href: item.href!,
|
||||
})),
|
||||
]
|
||||
.map((item) => ({ label: 'Visão geral', href: item.href! }))
|
||||
: [];
|
||||
const administration = access.authenticated
|
||||
const flatten = (items: PortalNavItem[]): PortalNavItem[] =>
|
||||
items.flatMap((item) =>
|
||||
item.children ? flatten(item.children) : [item],
|
||||
);
|
||||
const profileAdministration = new Set([
|
||||
'profile-administration',
|
||||
'profile-installation',
|
||||
'profile-audit',
|
||||
]);
|
||||
const candidates = access.authenticated
|
||||
? [
|
||||
...(dashboardActivities.length
|
||||
...(workHub
|
||||
? [link('work-entry', 'Gestão de conteúdos', workHub)]
|
||||
: []),
|
||||
...(workCreate
|
||||
? [
|
||||
{
|
||||
id: 'collaborative-dashboard',
|
||||
label: 'Dashboard',
|
||||
children: dashboardActivities.map((item, index) =>
|
||||
link(
|
||||
'dashboard-activity-' + index,
|
||||
item.label,
|
||||
item.href,
|
||||
),
|
||||
),
|
||||
},
|
||||
link(
|
||||
'prepare-analysis',
|
||||
'Preparar análise e ideia',
|
||||
workCreate + '?analysis=proactive',
|
||||
),
|
||||
]
|
||||
: []),
|
||||
...previous
|
||||
.filter((group) => group.id === 'management')
|
||||
.flatMap((group) => group.children ?? []),
|
||||
...(workOpportunities
|
||||
? [
|
||||
link(
|
||||
'work-opportunities',
|
||||
'Oportunidades em preparação',
|
||||
workOpportunities.index,
|
||||
),
|
||||
]
|
||||
: []),
|
||||
...(access.administrationNavigation ?? []).map((item, index) =>
|
||||
link(
|
||||
'administrative-activity-' + index,
|
||||
item.label,
|
||||
item.href,
|
||||
),
|
||||
),
|
||||
...flatten(
|
||||
previous
|
||||
.filter((group) => group.id === 'management')
|
||||
.flatMap((group) => group.children ?? []),
|
||||
),
|
||||
...(access.scopedAdministration ?? []).map((item, index) =>
|
||||
link('scoped-' + index, item.label, item.href),
|
||||
),
|
||||
...previous
|
||||
.filter((group) => group.id === 'profile-opportunities')
|
||||
.flatMap((group) => group.children ?? [])
|
||||
.filter((item) => profileAdministration.has(item.id)),
|
||||
]
|
||||
: [];
|
||||
const categories = [
|
||||
{
|
||||
id: 'administration-content',
|
||||
label: 'Conteúdos e oportunidades',
|
||||
children: [] as PortalNavItem[],
|
||||
},
|
||||
{
|
||||
id: 'administration-records',
|
||||
label: 'Cadastros e investimento',
|
||||
children: [] as PortalNavItem[],
|
||||
},
|
||||
{
|
||||
id: 'administration-followup',
|
||||
label: 'Pedidos e acompanhamento',
|
||||
children: [] as PortalNavItem[],
|
||||
},
|
||||
{
|
||||
id: 'administration-access',
|
||||
label: 'Acessos e configuração',
|
||||
children: [] as PortalNavItem[],
|
||||
},
|
||||
];
|
||||
for (const item of candidates) {
|
||||
const path = new URL(item.href!, 'https://portal.invalid').pathname;
|
||||
const category =
|
||||
/^\/(gestao-conteudos|management\/(portal-services|opportunities|concursos)|minhas-oportunidades)(\/|$)/.test(
|
||||
path,
|
||||
)
|
||||
? 0
|
||||
: /^\/management\/(interests|crm|balcao\/atribuicoes)(\/|$)/.test(
|
||||
path,
|
||||
)
|
||||
? 2
|
||||
: profileAdministration.has(item.id) ||
|
||||
/-install$/.test(path) ||
|
||||
path === '/management/ai'
|
||||
? 3
|
||||
: 1;
|
||||
categories[category].children.push(item);
|
||||
}
|
||||
const administration = [
|
||||
...(dashboardActivities.length
|
||||
? [
|
||||
{
|
||||
id: 'collaborative-dashboard',
|
||||
label: 'Dashboard',
|
||||
children: dashboardActivities.map((item, index) =>
|
||||
link(
|
||||
'dashboard-activity-' + index,
|
||||
item.label,
|
||||
item.href,
|
||||
),
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...categories.filter((group) => group.children.length > 0),
|
||||
];
|
||||
return uniqueNavigationDestinations([
|
||||
{
|
||||
id: 'discovery',
|
||||
@@ -655,34 +740,13 @@ export function portalNavigation(access: PortalNavAccess): PortalNavItem[] {
|
||||
id: 'work',
|
||||
label: 'Área de trabalho',
|
||||
children: [
|
||||
link(
|
||||
'work-entry',
|
||||
workHub
|
||||
? 'Gestão de conteúdos e oportunidades'
|
||||
: 'Acesso à gestão',
|
||||
workHub || '/acesso-gestao',
|
||||
),
|
||||
...(workCreate
|
||||
? [
|
||||
link(
|
||||
'prepare-analysis',
|
||||
'Preparar análise e ideia',
|
||||
workCreate + '?analysis=proactive',
|
||||
),
|
||||
]
|
||||
: []),
|
||||
...(workOpportunities
|
||||
? [
|
||||
link(
|
||||
'work-opportunities',
|
||||
'Oportunidades em preparação',
|
||||
workOpportunities.index,
|
||||
),
|
||||
]
|
||||
...(!workHub
|
||||
? [link('work-entry', 'Acesso à gestão', '/acesso-gestao')]
|
||||
: []),
|
||||
...previous
|
||||
.filter((group) => group.id === 'profile-opportunities')
|
||||
.flatMap((group) => group.children ?? []),
|
||||
.flatMap((group) => group.children ?? [])
|
||||
.filter((item) => !profileAdministration.has(item.id)),
|
||||
],
|
||||
},
|
||||
...previous.filter((group) => group.id === 'account'),
|
||||
|
||||
@@ -60,7 +60,20 @@ export default function Dashboard({
|
||||
<h1 className="text-2xl font-semibold">Painel do portal</h1>
|
||||
<ProfileNavigation />
|
||||
<ContentManagementEntry />
|
||||
<DashboardWorkQueue queue={workQueue} />
|
||||
<section id="meu-trabalho" className="scroll-mt-24">
|
||||
{workQueue ? (
|
||||
<DashboardWorkQueue queue={workQueue} />
|
||||
) : (
|
||||
<>
|
||||
<h2 className="text-lg font-semibold">
|
||||
O meu trabalho
|
||||
</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Sem fila de trabalho disponível neste âmbito.
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
{editorialQueue && (
|
||||
<section
|
||||
className="rounded-lg border p-4"
|
||||
@@ -128,7 +141,10 @@ export default function Dashboard({
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
<section className="space-y-4">
|
||||
<section
|
||||
id="manifestacoes"
|
||||
className="scroll-mt-24 space-y-4"
|
||||
>
|
||||
<h2 className="text-lg font-semibold">
|
||||
Manifestações de interesse
|
||||
</h2>
|
||||
@@ -149,7 +165,10 @@ export default function Dashboard({
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
<section className="space-y-4">
|
||||
<section
|
||||
id="indicadores-oportunidades"
|
||||
className="scroll-mt-24 space-y-4"
|
||||
>
|
||||
<h2 className="text-lg font-semibold">
|
||||
<Link href="/management/opportunities">
|
||||
{opportunityManagement
|
||||
@@ -190,7 +209,10 @@ export default function Dashboard({
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
<section className="space-y-4">
|
||||
<section
|
||||
id="pedidos-recentes"
|
||||
className="scroll-mt-24 space-y-4"
|
||||
>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<h2 className="text-lg font-semibold">
|
||||
Pedidos mais recentes
|
||||
@@ -243,6 +265,7 @@ export default function Dashboard({
|
||||
)}
|
||||
</section>
|
||||
<nav
|
||||
id="accoes-rapidas"
|
||||
aria-label="Acções rápidas"
|
||||
className="flex flex-wrap gap-4"
|
||||
>
|
||||
@@ -264,7 +287,10 @@ export default function Dashboard({
|
||||
</nav>
|
||||
</>
|
||||
) : investorPath ? (
|
||||
<section className="space-y-4 rounded-xl border p-6">
|
||||
<section
|
||||
id="meus-investimentos"
|
||||
className="scroll-mt-24 space-y-4 rounded-xl border p-6"
|
||||
>
|
||||
<h2 className="text-lg font-semibold">
|
||||
Os meus investimentos
|
||||
</h2>
|
||||
|
||||
@@ -152,7 +152,7 @@ export default function EditorialWorkflow({
|
||||
},
|
||||
].filter((area) => area.entries.some((item) => item.href));
|
||||
return (
|
||||
<Management title="Dashboard">
|
||||
<Management title="Circuito editorial">
|
||||
<p className="max-w-3xl text-sm text-slate-600">
|
||||
Acompanhe a preparação, revisão e publicação numa única área de
|
||||
trabalho. Seleccione uma actividade para continuar nas tarefas
|
||||
|
||||
Reference in New Issue
Block a user