refactor(badges): centralize status->BadgeVariant mapping per domain #264

Merged
vas2000-work merged 1 commit from refactor/MAPPS-268-centralize-status-badges into main 2026-06-18 00:39:16 +02:00
Owner

Every page hand-rolled its own status_variant() / *_status_badge() copy (contract, asset, project, invoice, KB article, ticket) and the copies drifted: the portal invoice mapper knew overdue and defaulted to Yellow while billing's defaulted to Gray and never handled overdue; the contract mapper was duplicated verbatim across contracts.rs and contacts.rs. New server statuses fell back to silent Gray inconsistently per page.

Introduce src/components/status_badge.rs as the single source per domain. Each helper returns (variant, humanized label) so both color and label live in one place; ticket_status_badge moves here unchanged (callers render the status verbatim). Pages now call the shared mappers and the duplicated humanize_*/status_variant/status_badge copies are deleted.

Add BadgeVariant::Orange so an overdue invoice reads distinctly from a written-off/void one (Red), satisfying the expand-coverage goal. Unknown statuses hit an explicit Gray fallback whose label is title-cased from the raw snake_case token rather than leaking partially_refunded. Derive Debug on BadgeVariant for the new unit tests.

#MAPPS-268

Every page hand-rolled its own status_variant() / *_status_badge() copy (contract, asset, project, invoice, KB article, ticket) and the copies drifted: the portal invoice mapper knew `overdue` and defaulted to Yellow while billing's defaulted to Gray and never handled `overdue`; the contract mapper was duplicated verbatim across contracts.rs and contacts.rs. New server statuses fell back to silent Gray inconsistently per page. Introduce src/components/status_badge.rs as the single source per domain. Each helper returns (variant, humanized label) so both color and label live in one place; ticket_status_badge moves here unchanged (callers render the status verbatim). Pages now call the shared mappers and the duplicated humanize_*/status_variant/status_badge copies are deleted. Add BadgeVariant::Orange so an overdue invoice reads distinctly from a written-off/void one (Red), satisfying the expand-coverage goal. Unknown statuses hit an explicit Gray fallback whose label is title-cased from the raw snake_case token rather than leaking `partially_refunded`. Derive Debug on BadgeVariant for the new unit tests. #MAPPS-268
refactor(badges): centralize status->BadgeVariant mapping per domain
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 2m29s
5baf6991f0
Every page hand-rolled its own status_variant() / *_status_badge() copy (contract, asset, project, invoice, KB article, ticket) and the copies drifted: the portal invoice mapper knew `overdue` and defaulted to Yellow while billing's defaulted to Gray and never handled `overdue`; the contract mapper was duplicated verbatim across contracts.rs and contacts.rs. New server statuses fell back to silent Gray inconsistently per page.

Introduce src/components/status_badge.rs as the single source per domain. Each helper returns (variant, humanized label) so both color and label live in one place; ticket_status_badge moves here unchanged (callers render the status verbatim). Pages now call the shared mappers and the duplicated humanize_*/status_variant/status_badge copies are deleted.

Add BadgeVariant::Orange so an overdue invoice reads distinctly from a written-off/void one (Red), satisfying the expand-coverage goal. Unknown statuses hit an explicit Gray fallback whose label is title-cased from the raw snake_case token rather than leaking `partially_refunded`. Derive Debug on BadgeVariant for the new unit tests.

#MAPPS-268
vas2000-work force-pushed refactor/MAPPS-268-centralize-status-badges from 5baf6991f0
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 2m29s
to a0b4a3a6ae
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m52s
Create release / Create release from merged PR (pull_request) Has been skipped
2026-06-17 23:58:48 +02:00
Compare
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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!264
No description provided.