Task 004: add demo auth and role checks

This commit is contained in:
2026-05-21 18:31:40 +03:00
parent 7a11d50aa7
commit 7972e9a95f
26 changed files with 2207 additions and 23 deletions
@@ -0,0 +1,47 @@
import type { Role } from "@pipeline/shared";
export type NavigationItem = {
id: string;
label: string;
href: string;
roles: readonly Role[];
};
export const ROLE_NAVIGATION_ITEMS = [
{
id: "dashboard",
label: "Dashboard",
href: "/",
roles: ["ADMIN", "EDITOR"],
},
{
id: "new-article",
label: "New article",
href: "/articles/new",
roles: ["ADMIN", "EDITOR"],
},
{
id: "review",
label: "Review",
href: "/review",
roles: ["ADMIN", "EDITOR"],
},
{
id: "site-config",
label: "Site configuration",
href: "/admin/sites",
roles: ["ADMIN"],
},
{
id: "script-versions",
label: "Script versions",
href: "/admin/scripts",
roles: ["ADMIN"],
},
] as const satisfies readonly NavigationItem[];
export function getRoleNavigationItems(role: Role): NavigationItem[] {
return ROLE_NAVIGATION_ITEMS.filter((item) =>
item.roles.some((allowedRole) => allowedRole === role),
);
}