google-listings-and-ads
google-listings-and-ads copied to clipboard
RFC: Remove `subpath` URLQueryParam from settings pages.
(This is a follow-up from https://github.com/woocommerce/google-listings-and-ads/pull/1025#discussion_r717420234)
Changes proposed in this Pull Request:
Remove subpath URLQueryParam from settings pages.
Use WC navigation features instead.
This way we have
- routing unified with the WC stack
- less noise in URLs & track events
- more intuitive URL & track event props, as the entire path is in a single param, not divided into a number of chunks
- could get closer to simplify
.~/utils/url.js, as we no longer need to construct a query object, but just usepathparam. - remove the source of problems like the one discussed at https://github.com/woocommerce/google-listings-and-ads/pull/1025#discussion_r717420234, TL;DR: "what if
subpathis empty?"
What's left/missing/to be done later:
- [ ] Update track event README
- [ ] Try to simplify
wc_admin_register_pagecalls insrc/Menu/Settings.php - [ ] :scroll: extrapolate for all other pages using
subpathor similar param. - (edit) ~[ ] 📜(not sure if possible in WC-plaform) DRY/reduce duplication, of pages configs in
src/Menu/*.phps,js/src/index.jsandjs/src/utils/url.js~ -> https://github.com/woocommerce/google-listings-and-ads/issues/1037
Screenshots:

Detailed test instructions:
- Go to Settings page
/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsettings - Navigate into phone & address pages - "Edit" buttons
- Navigate away and around observing how URL changes, and what track events are fired. (full page reloads instead of SPA-morph, is an unrelated issue https://github.com/woocommerce/google-listings-and-ads/issues/1027)
Changelog entry
Make all settings pages use only
pathfor navigation.
//cc @eason9487 @ecgan
@tomalec , the reason why we use subpath is to make the pages work with the new WC Navigation beta feature. Refer to the following links:
- https://github.com/woocommerce/google-listings-and-ads/pull/605#issuecomment-847288673
- https://github.com/woocommerce/google-listings-and-ads/issues/665
- https://github.com/woocommerce/google-listings-and-ads/pull/743 (This has video demo.)
You can enable the WC Navigation feature in WC Settings > Advanced > Features.
I managed to achieve that by using matchExpression property

It was quite hidden in the docs, so I found it by debugging it live :man_facepalming: But I hope it's stable enough and desired usage.
Highlighting the subpages in legacy menu is covered by https://github.com/woocommerce/google-listings-and-ads/pull/1038
Mental note - before we go merging will this impact any funnels we have set up or direct links we may have (in the codebase or docs)
will this impact any funnels we have set up or direct links we may have (in the codebase or docs)
Yes, it will. All path=/google/settings&subpath={subpath} will become path=/google/settings/{subpath}.
So the url, path and subpath event props will change respectively.
That's why I still have on my todo list:
Update track event README
@jconroy does the above make it a no-go? or maybe it's ok, but we should change everything at once, to update the docs and funnels only once, to minimize the inconvenience, for users of those.
Thanks for proposing the RFC, @tomalec! After several years of iteration, the new WooCommerce Navigation has been deprecated (see #2406). The stale PRs related to it will likely require reassessment for appropriate solutions, so I am closing this PR.