fix(assets): distinguish loading / empty / failed in Change History panel (MAPPS-304) #297

Merged
YousifShkara merged 1 commit from fix/MAPPS-304-asset-change-history-states into main 2026-06-21 09:14:49 +02:00
Owner

Before, the asset Change History panel collapsed every fetch outcome through unwrap_or_default(), so a 403 from the RequireAdmin gate on /assets/{id}/audit-log (which a non-admin role hits) rendered the same "No history yet" string as a genuinely empty audit log. That misled the QA report into thinking change-tracking was broken when the panel was actually permission-denied. The audit Resource now carries Result<Vec<AuditEntry>, String> and the render picks one of three states (Loading / Ready / Failed), with the failure branch showing the underlying error so a real fetch failure is visible and actionable instead of disguised as empty. The "Edited by X" header label reads through the same projection and only renders when the latest entry actually loaded. PMS-447 (single-tenancy admin floor) stops most users from hitting the 403 in the first place; this change handles the remaining failure cases (network drop, future role downgrade) honestly.

The companion "spurious error toast on every successful update" half of the ticket still needs a fresh reproduction with the MAPPS-299 panic-hook PR deployed: the asset PUT path is put_authed::<serde_json::Value, _> against PUT /assets/{id} which returns Json<AssetResponse> on 200 (not 204), and Value deserialises any JSON shape, so the failure case is not visible from static analysis. Tracking that follow-up on the ticket.

#MAPPS-304

Before, the asset Change History panel collapsed every fetch outcome through `unwrap_or_default()`, so a 403 from the `RequireAdmin` gate on `/assets/{id}/audit-log` (which a non-admin role hits) rendered the same "No history yet" string as a genuinely empty audit log. That misled the QA report into thinking change-tracking was broken when the panel was actually permission-denied. The audit `Resource` now carries `Result<Vec<AuditEntry>, String>` and the render picks one of three states (Loading / Ready / Failed), with the failure branch showing the underlying error so a real fetch failure is visible and actionable instead of disguised as empty. The "Edited by X" header label reads through the same projection and only renders when the latest entry actually loaded. PMS-447 (single-tenancy admin floor) stops most users from hitting the 403 in the first place; this change handles the remaining failure cases (network drop, future role downgrade) honestly. The companion "spurious error toast on every successful update" half of the ticket still needs a fresh reproduction with the MAPPS-299 panic-hook PR deployed: the asset PUT path is `put_authed::<serde_json::Value, _>` against `PUT /assets/{id}` which returns `Json<AssetResponse>` on 200 (not 204), and `Value` deserialises any JSON shape, so the failure case is not visible from static analysis. Tracking that follow-up on the ticket. #MAPPS-304
fix(assets): distinguish loading / empty / failed in Change History panel (MAPPS-304)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m6s
Create release / Create release from merged PR (pull_request) Has been skipped
e460ff8987
Before, the asset Change History panel collapsed every fetch outcome through `unwrap_or_default()`, so a 403 from the `RequireAdmin` gate on `/assets/{id}/audit-log` (which a non-admin role hits) rendered the same "No history yet" string as a genuinely empty audit log. That misled the QA report into thinking change-tracking was broken when the panel was actually permission-denied. The audit `Resource` now carries `Result<Vec<AuditEntry>, String>` and the render picks one of three states (Loading / Ready / Failed), with the failure branch showing the underlying error so a real fetch failure is visible and actionable instead of disguised as empty. The "Edited by X" header label reads through the same projection and only renders when the latest entry actually loaded. PMS-447 (single-tenancy admin floor) stops most users from hitting the 403 in the first place; this change handles the remaining failure cases (network drop, future role downgrade) honestly.

The companion "spurious error toast on every successful update" half of the ticket still needs a fresh reproduction with the MAPPS-299 panic-hook PR deployed: the asset PUT path is `put_authed::<serde_json::Value, _>` against `PUT /assets/{id}` which returns `Json<AssetResponse>` on 200 (not 204), and `Value` deserialises any JSON shape, so the failure case is not visible from static analysis. Tracking that follow-up on the ticket.

#MAPPS-304
YousifShkara deleted branch fix/MAPPS-304-asset-change-history-states 2026-06-21 09:14:49 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!297
No description provided.