mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 20:05:41 +00:00
Add fleet management and admin permissions, and update controllers to enforce new permissions
This commit is contained in:
@@ -20,6 +20,11 @@ export const FREIGHT_PERMS = {
|
||||
view: "edr_freight_app:train_scheduling:view",
|
||||
manage: "edr_freight_app:train_scheduling:manage",
|
||||
},
|
||||
fleet: {
|
||||
view: "edr_freight_app:fleet:view",
|
||||
manage: "edr_freight_app:fleet:manage",
|
||||
},
|
||||
admin: "edr_freight_app:admin",
|
||||
} as const;
|
||||
|
||||
const slugToResourceKey = (slug: RuleEngineResourceSlug): string =>
|
||||
@@ -82,6 +87,14 @@ export function canManageScheduling(user: AuthUser | null | undefined): boolean
|
||||
return hasPermission(user, FREIGHT_PERMS.trainScheduling.manage);
|
||||
}
|
||||
|
||||
export function canViewFleet(user: AuthUser | null | undefined): boolean {
|
||||
return hasPermission(user, FREIGHT_PERMS.fleet.view);
|
||||
}
|
||||
|
||||
export function isFreightAdmin(user: AuthUser | null | undefined): boolean {
|
||||
return hasPermission(user, FREIGHT_PERMS.admin);
|
||||
}
|
||||
|
||||
export function ruleEngineViewKey(slug: RuleEngineResourceSlug): string {
|
||||
return `edr_freight_app:rule_engine:${slugToResourceKey(slug)}:view`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user