Add a sort direction toggle to the wiki sidebar

What does this MR do and why?

Adds a sort direction toggle to the wiki sidebar and tidies up its header.

  • Sorting: a sort direction button in the sidebar header switches the page tree between ascending and descending order. Nested pages follow the same order, search keeps it, and the choice is saved in the browser so it survives page loads. The sidebar only receives the title, slug, and path of each page, so sorting is alphabetical. Sorting by date would need a backend change. On the "View all pages" page, the sidebar toggle and the list's own sort button stay independent: one orders the sidebar tree, the other the paginated list.
  • Header: the sidebar header shows "Wiki" next to the close button, so the "Wiki Pages" heading inside the sidebar goes away. With a custom sidebar, a "Pages" toggle stays at the top of the list because it is what expands the pages list.
  • View all pages: a small tertiary button below a divider, instead of a full-width button.
  • Icons: "Create a new page under ..." in the sidebar and "New page" in the More actions menu use the doc-new icon.

Two changes to the shared panel sidebar make this work:

  • panel_sidebar and Layouts::PanelSidebarComponent take an optional title:, rendered as a heading next to the close button.
  • PanelSidebarPortal mounts its actions into a target placed before the server-rendered actions. Before, it appended them after, so a Vue button shown to the left of "Add custom sidebar" received keyboard focus after it. The wiki is the only page that uses the portal's actions slot.

References

  • Related to #590402 (sorting part of the wiki sidebar enhancements)

Screenshots or screen recordings

State Before After
Wiki page 01_page 01_page
Sidebar, default order 02_sidebar 02_sidebar
Sidebar, descending (new, before has no sort) 03_descending 03_descending
Create subpage on hover 04_hover 04_hover
More actions menu 05_more_actions 05_more_actions
Custom sidebar, pages expanded 06_custom_sidebar 06_custom_sidebar

In ascending order, "guides archive" now sorts after the "guides" folder: the sidebar compares slugs one path segment at a time, so a hyphenated sibling no longer jumps ahead of a folder with the same prefix.

How to set up and validate locally

  1. Open a project wiki page with a few pages, including nested ones, for example https://gdk.test:3000/gitlab-org/gitlab-test/-/wikis/home.
  2. Check the sidebar header reads "Wiki" next to the close button, followed by the sort button and, if you can create pages, "Add custom sidebar".
  3. Select the sort button. The tree reverses, including pages inside folders, and the tooltip changes to "Sort direction: Descending".
  4. Type in "Search pages". The results keep the descending order.
  5. Reload the page. The order is still descending.
  6. Press Tab through the header. Focus moves from the close button to the sort button, then to "Add custom sidebar".
  7. Hover a page in the tree and check the create subpage button uses the doc-new icon. Open the More actions menu and check "New page" uses it too.
  8. Optional: add a custom sidebar. The "Pages" toggle expands and collapses the page list, and the sort button only shows while the list is expanded.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sascha Eggenberger

Merge request reports

Loading
Loading