Cleanup navigation related code #1037
Labels
category: refactor
The issue/PR is related to refactoring.
type: enhancement
The issue is a request for an enhancement.
type: technical debt - external devX
This issue/PR suffers from the ergonomics of external tools/dependencies
type: technical debt
This issue/PR represents/solves the technical debt of the project.
Describe the bug:
Currently, navigation-related code is scattered around our codebase in multiple places. It makes it hard to add new pages or change the navigation flow. Some of it is a result of Woo convention of adding pages - separate setup in PHP separate in JS. But I believe some of it could be cleaned up on our end.
Here is the list of places when we define the navigation:
/src/Menu/*.php
/js/src/index.js
/js/src/utils/urls.js
- List of internal URLs to be used in links, buttons, etc..~/utils/urls.js
#1024/js/src/components/navigation-classic/main-tab-nav.js
Thoughts, doubts:
I'm not entirely sure, what is the relation between 1. (
/src/Menu/*.php
) and 2. (/js/src/index.js
), and if the 2. will be needed in the new nav. Also, why it cannot be built from a single source.I have a gut feeling that 2. (
/js/src/index.js
) and 3. (/js/src/utils/urls.js
) could somewhat share the config.I think, the hack for legacy nav highlighting could be move from 4.
/js/src/components/navigation-classic/main-tab-nav.js
somewhere else, as it's easy to miss it. (Current, settings subpages & account-reconnection, do not use it). Also, we could use a somewhat more officialwindow.wpNavMenuClassChange
instead of manually hacking CSS selectors and classes.(Personally, I spend a week working with navigation. Then needed an entire day of debugging the WC-admin navigation to find it.)
The text was updated successfully, but these errors were encountered: