Task 004: add demo auth and role checks
This commit is contained in:
@@ -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),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user