mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 11:18:17 +00:00
Add allocation management features and update permissions for container allocation
This commit is contained in:
@@ -109,10 +109,19 @@ export const RULE_ENGINE_PERMISSIONS: FreightPermissionSeed[] = RULE_ENGINE_RESO
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Container-allocation permission for the previously-unguarded
|
||||
* booking allocate-containers endpoint.
|
||||
*/
|
||||
export const GAP_CONTROLLER_PERMISSIONS: FreightPermissionSeed[] = [
|
||||
perm('c1000001-0001-4000-8000-000000000001', 'edr_freight_app:allocation:manage', 'Allocate containers to vehicles'),
|
||||
];
|
||||
|
||||
export const BOOKING_RULE_ENGINE_PERMISSIONS = [
|
||||
...BOOKING_PERMISSIONS,
|
||||
...CONTRACT_PERMISSIONS,
|
||||
...RULE_ENGINE_PERMISSIONS,
|
||||
...GAP_CONTROLLER_PERMISSIONS,
|
||||
];
|
||||
|
||||
export const BOOKING_RULE_ENGINE_PERMISSION_KEYS = BOOKING_RULE_ENGINE_PERMISSIONS.map(
|
||||
@@ -171,6 +180,9 @@ export const FREIGHT_PERMS = {
|
||||
manage: (slug: RuleEngineResourceSlug) =>
|
||||
`edr_freight_app:rule_engine:${slugToResourceKey(slug)}:manage`,
|
||||
},
|
||||
allocation: {
|
||||
manage: 'edr_freight_app:allocation:manage',
|
||||
},
|
||||
} as const;
|
||||
|
||||
const allRuleEngineViewKeys = () =>
|
||||
@@ -286,6 +298,34 @@ export const ROLE_PERMISSION_PRESETS = {
|
||||
orgManager: [...BOOKING_RULE_ENGINE_PERMISSION_KEYS],
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Position permission presets (positions-as-roles). Grants flow to users via
|
||||
* Position → PositionPermission (NOT Role/RolePermission). Each reuses the
|
||||
* matching ROLE_PERMISSION_PRESETS key-array as a building block and adds the
|
||||
* gap-controller keys the position needs. Deduped via Set.
|
||||
*/
|
||||
const dedupe = (keys: string[]): string[] => [...new Set(keys)];
|
||||
|
||||
export const POSITION_PERMISSION_PRESETS = {
|
||||
// Chief: senior operational role — intake/line-staff approval + director
|
||||
// approval + scheduling/ops, plus container allocation.
|
||||
chief: dedupe([
|
||||
...ROLE_PERMISSION_PRESETS.lineStaff,
|
||||
...ROLE_PERMISSION_PRESETS.director,
|
||||
...ROLE_PERMISSION_PRESETS.operationsOfficer,
|
||||
FREIGHT_PERMS.allocation.manage,
|
||||
]),
|
||||
director: dedupe([...ROLE_PERMISSION_PRESETS.director]),
|
||||
ceo: dedupe([...ROLE_PERMISSION_PRESETS.ceo]),
|
||||
ethiopianGl: dedupe([...ROLE_PERMISSION_PRESETS.glEthiopia]),
|
||||
djiboutiGl: dedupe([...ROLE_PERMISSION_PRESETS.glDjibouti]),
|
||||
marketer: dedupe([...ROLE_PERMISSION_PRESETS.marketing]),
|
||||
operation: dedupe([
|
||||
...ROLE_PERMISSION_PRESETS.operationsOfficer,
|
||||
FREIGHT_PERMS.allocation.manage,
|
||||
]),
|
||||
} as const;
|
||||
|
||||
export const PERMISSIONS_CATALOG = BOOKING_RULE_ENGINE_PERMISSIONS.map((p) => ({
|
||||
key: p.key,
|
||||
label: p.name.en,
|
||||
|
||||
Reference in New Issue
Block a user