Skip to content

Make menu items in new navigation sidebar pinnable

Thomas Hutterer requested to merge new_nav_pin_menu_items into master

What does this MR do and why?

Implementation of #378547 (closed):

  • Menu items can be pinned and unpinned.
  • Pins can be reorderd.
  • Pinned items are stored in a new JSONB database column (in the user_preferences table).

Screenshots or screen recordings

recording_1679576983

How to set up and validate locally

First enable the feature flag for the new navigation:

Feature.enable(:super_sidebar_nav, User.first)

Then toggle on the New navigation in the top-right user dropdown.

Then perform these (or similar) steps to test the new feature:

  • Go to any project or group.
  • See the new empty Pinned section in the sidebar.
  • Open any section, like Plan, and hover any of its menu items.
  • Click the little 📌 button to pin the item.
  • Find it now in the Pinned section.
  • Use it to navigate to that page. See it shown as active. Its original section stays collapsed, so that we don't double-show it.
  • Pin a couple more menu items.
  • In the Pinned section, hover one of them and drag&drop the little handle-icon on the left to reorder your pins.
  • Delete some pins from the Pinned section and see their 📌 icon change also in their original section.
  • Delete a pin by clicking the 📌 of the orignal item in its section.
  • Reload the page in between any of these steps to see everything persisted on the backend.

Database

Output of db:migrate

main: == 20230321125300 AddPinnedNavItemsToUserPreference: migrating ================
main: -- add_column(:user_preferences, :pinned_nav_items, :jsonb, {:null=>false, :default=>{}})
main:    -> 0.0027s
main: == 20230321125300 AddPinnedNavItemsToUserPreference: migrated (0.0069s) =======

Output of db:rollback

main: == 20230321125300 AddPinnedNavItemsToUserPreference: reverting ================
main: -- remove_column(:user_preferences, :pinned_nav_items, :jsonb, {:null=>false, :default=>{}})
main:    -> 0.0012s
main: == 20230321125300 AddPinnedNavItemsToUserPreference: reverted (0.0067s) =======

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Review status

Category Reviewer Maintainer
backend @joseph 🏓 @ck3g
database @jarka @a_akgun
frontend @pgascouvaillancourt 🏓 @ohoral
test @acunskis -
Edited by Thomas Hutterer

Merge request reports