core icon indicating copy to clipboard operation
core copied to clipboard

[TASK] Refactor Breadcrumb Logic for Scalability

Open adrianjm-dotCMS opened this issue 1 year ago • 0 comments

Description

The current logic for generating breadcrumbs for "special cases" (routes that don't map 1:1 with a menu item, like /templates/edit/:id or /content?filter=) is handled with a growing if/else block.

This approach is difficult to maintain and is not scalable. As we add more special routes, this conditional logic will become complex and error-prone.

Objective: Refactor this implementation to use a more scalable "Strategy Map" pattern (e.g., a Map or an object literal). The goal is to map a URL pattern (or a function that tests the URL) to a specific handler function responsible for building the breadcrumbs for that case.

This will allow us to register new special cases cleanly without modifying the core logic, simply by adding a new entry to the map.

Acceptance Criteria

  • AC1: The existing if/else block for handling special breadcrumb cases must be removed.

  • AC2: A map-like structure (e.g., Map, Object) must be implemented to register handler functions for special cases.

  • AC3: The existing cases (/templates/edit/:id and /content?filter=) must be migrated to use this new pattern.

  • AC4: The breadcrumb functionality must remain identical to the user. This is a refactor and should not introduce any behavioral changes.

  • AC5: The new structure must make it easy to add future special cases simply by registering a new handler, without touching the main processing logic.

Priority

None

Additional Context

No response

adrianjm-dotCMS avatar Nov 10 '25 21:11 adrianjm-dotCMS