mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 01:48:12 +00:00
add permanent purge functionality for wagons and routes
- Implemented a method in to permanently delete wagons without history. - Added corresponding permissions for hard delete actions in . - Updated the UI components to include purge actions, ensuring they are only available to users with the appropriate permissions. - Created modals for confirming permanent deletions in and . - Enhanced API services to handle purge requests for locomotives, wagons, and routes. - Added tests for the purge functionality in both and services to ensure proper behavior and error handling.
This commit is contained in:
@@ -122,12 +122,16 @@ export const FREIGHT_PERMS = {
|
||||
create: "edr_freight_app:locomotives:create",
|
||||
update: "edr_freight_app:locomotives:update",
|
||||
delete: "edr_freight_app:locomotives:delete",
|
||||
/** Permanent purge — irreversible, granted separately from `delete`. */
|
||||
hardDelete: "edr_freight_app:locomotives:hard_delete",
|
||||
},
|
||||
wagons: {
|
||||
view: "edr_freight_app:wagons:view",
|
||||
create: "edr_freight_app:wagons:create",
|
||||
update: "edr_freight_app:wagons:update",
|
||||
delete: "edr_freight_app:wagons:delete",
|
||||
/** Permanent purge — irreversible, granted separately from `delete`. */
|
||||
hardDelete: "edr_freight_app:wagons:hard_delete",
|
||||
transferRequest: "edr_freight_app:wagons:transfer_request",
|
||||
transferFulfill: "edr_freight_app:wagons:transfer_fulfill",
|
||||
transferHistoryAll: "edr_freight_app:wagons:transfer_history_all",
|
||||
@@ -148,6 +152,8 @@ export const FREIGHT_PERMS = {
|
||||
create: "edr_freight_app:routes:create",
|
||||
update: "edr_freight_app:routes:update",
|
||||
delete: "edr_freight_app:routes:delete",
|
||||
/** Permanent purge — irreversible, granted separately from `delete`. */
|
||||
hardDelete: "edr_freight_app:routes:hard_delete",
|
||||
},
|
||||
containers: {
|
||||
view: "edr_freight_app:containers:view",
|
||||
@@ -598,6 +604,19 @@ export function canFleetAction(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanent-purge check for locomotives and wagons. Unlike
|
||||
* {@link canFleetAction} this does NOT fall back to the coarse fleet:manage
|
||||
* key — an irreversible delete needs its own grant, and the API guards these
|
||||
* endpoints the same way.
|
||||
*/
|
||||
export function canFleetHardDelete(
|
||||
user: AuthUser | null | undefined,
|
||||
resource: "locomotives" | "wagons" | "routes",
|
||||
): boolean {
|
||||
return hasPermission(user, FREIGHT_PERMS[resource].hardDelete);
|
||||
}
|
||||
|
||||
export function isFreightAdmin(user: AuthUser | null | undefined): boolean {
|
||||
return hasPermission(user, FREIGHT_PERMS.admin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user