google-listings-and-ads icon indicating copy to clipboard operation
google-listings-and-ads copied to clipboard

RFC: Remove `subpath` URLQueryParam from settings pages.

Open tomalec opened this issue 4 years ago • 6 comments

(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 use path param.
  • 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 subpath is empty?"

What's left/missing/to be done later:

  • [ ] Update track event README
  • [ ] Try to simplify wc_admin_register_page calls in src/Menu/Settings.php
  • [ ] :scroll: extrapolate for all other pages using subpath or similar param.
  • (edit) ~[ ] 📜(not sure if possible in WC-plaform) DRY/reduce duplication, of pages configs in src/Menu/*.phps, js/src/index.js and js/src/utils/url.js~ -> https://github.com/woocommerce/google-listings-and-ads/issues/1037

Screenshots:

path

Detailed test instructions:

  1. Go to Settings page /wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsettings
  2. Navigate into phone & address pages - "Edit" buttons
  3. 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 path for navigation.


//cc @eason9487 @ecgan

tomalec avatar Sep 30 '21 13:09 tomalec

@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.

ecgan avatar Sep 30 '21 17:09 ecgan

I managed to achieve that by using matchExpression property image

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.

tomalec avatar Oct 05 '21 15:10 tomalec

Highlighting the subpages in legacy menu is covered by https://github.com/woocommerce/google-listings-and-ads/pull/1038

tomalec avatar Oct 05 '21 18:10 tomalec

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)

findingsimple avatar Oct 14 '21 00:10 findingsimple

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

tomalec avatar Oct 14 '21 13:10 tomalec

@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.

tomalec avatar Oct 21 '21 19:10 tomalec

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.

eason9487 avatar Nov 11 '25 03:11 eason9487