localgov icon indicating copy to clipboard operation
localgov copied to clipboard

Change the order of tabs in the Content view

Open willguv opened this issue 1 year ago • 9 comments

This is the current order

Image

Media and Alert banners are used often but are too far over to the right

I think the order should be:

  • Content
  • Blocks (if user has permissions)
  • Media
  • Files (if user has permissions)
  • Alert banners
  • Directory facets
  • Locations
  • Page components
  • Scheduling
  • Service contacts

The reasoning for this is as follows:

  • Content, blocks, media and files are used most so they're first
  • The rest are used less so they're in alphabetical order

willguv avatar May 23 '24 10:05 willguv

This needed a combination of changes in the following PRs:

  • https://github.com/localgovdrupal/localgov_core/pull/226 (increases the weight of "Files" and "Page components" local task items).
  • https://github.com/localgovdrupal/localgov_alert_banner/pull/330 (Alters the weight of "Alert banners" local task).
  • https://github.com/localgovdrupal/localgov_directories/pull/379 (Alters the weight of "Directory facets" local task).
  • https://github.com/localgovdrupal/localgov_geo/pull/120 (Alters the weight of "Locations" local task).
  • https://github.com/localgovdrupal/localgov_workflows/pull/100 (Alters the weights of "Scheduling" and "Service contacts" local task items).

The resulting order of the Content page tabs after the above PRs make it into the main branch are:

  • Content (weight -10, unchanged)
  • Blocks (weight 0, unchanged)
  • Media (weight 10, unchanged)
  • Files (weight updated to 20)
  • Alert banners (weight updated to 30)
  • Directory facets (weight updated to 40)
  • Locations (weight updated to 50)
  • Page components (weight updated to 60)
  • Scheduling (weight updated to 70)
  • Service contacts (weight updated to 80)

MariosORION avatar Jun 04 '24 16:06 MariosORION

Thanks @MariosORION !

willguv avatar Jun 04 '24 16:06 willguv

Thanks for this @MariosORION ! Here's how I tested:

  1. Fresh install (on Gitpod @willguv :smile: )
  2. Enabling localgov_demo module.
  3. Composer required all the branches. (@willguv like this https://docs.localgovdrupal.org/devs/how-to/how-to-test-modules-with-gitpod.html#_5-testing-branches-from-github )
  4. Clear the cache. (drush cr)
  5. See the following order of the local tasks:

image

Crikey, quite a few pull requests to get through to re-arrange the tabs! I guess that makes sense.
Although, thinking about it now, could all this code be in one module? localgov_core for example? Oh no... I see now, lots of them are the default weight from config: https://github.com/localgovdrupal/localgov_directories/pull/379/files

Sorry! Totally makes sense!

Thanks @MariosORION and @willguv :smiley_cat:

finnlewis avatar Jun 04 '24 23:06 finnlewis

This is brilliant, thanks Finn for testing and writing up these docs. I'll be able to take modules and branches for a spin, freeing up dev time. Will encourage others to get involved too.

Also thanks very much @MariosORION for picking this up at short notice.

Great work all round!

willguv avatar Jun 04 '24 23:06 willguv

This is great, thanks both! Indeed @finnlewis , I wanted to keep the changes as "local" as possible hence the separate PRs. I was thinking about a testing workflow for this kind of change (e.g. referencing the actual branches in composer.json for local testing) - it looks like the Gitpod approach works really well - nice one! 👍👍

MariosORION avatar Jun 05 '24 08:06 MariosORION

@MariosORION - quick question ( came up while reviewing and merging) - do the local tasks weights get exported as config, and so is it something that a specific site can override with config import?

finnlewis avatar Jun 13 '24 14:06 finnlewis

@finnlewis short answer is yes. Long answer: Local tasks are made to primarily be static. Defaults are defined in example.links.task.yml files and hook_menu_local_tasks_alter can be used to alter these. The PRs here use a combination of the two, depending on the relative weight required for each item and how each item's weight is already defined (or altered) in the corresponding module. A specific site could override all of these using the same hook (also assuming that the weight of the module of the specific site where the hook implementation is added is greater than the weights of the modules utilising the same hook in these PRs).

MariosORION avatar Jun 13 '24 19:06 MariosORION

Just installed this - looks great, thanks @MariosORION!

willguv avatar Jun 18 '24 14:06 willguv

Great to hear, @willguv !

MariosORION avatar Jun 18 '24 14:06 MariosORION