Skip to content

feat: sidebar menu tree with collection grouping, plugin subgroups, and public menu sync #1038

@ahliweb

Description

@ahliweb

What does this PR do?

Implements a comprehensive admin sidebar redesign that adds collection grouping, plugin subgroups, nested submenus, icon rendering, sidebar configuration, and bidirectional sync with public menus.

Discussion: #1027

Data Layer

  • Migration 039: Adds sort_order (INTEGER, default 0) and group (TEXT, nullable) columns to _emdash_collections
  • Collection types: sortOrder, group, and icon added to Collection, CreateCollectionInput, UpdateCollectionInput, ManifestCollection
  • Plugin types: group and sortOrder added to PluginAdminPage and ManifestPlugin.adminPages
  • Ordering: Collections now ordered by sort_order ASC, slug ASC instead of just slug ASC

Admin Sidebar Rendering

  • Collection grouping: Collections with a group field render in separate collapsible sidebar groups; ungrouped collections remain in the default "Content" group
  • Plugin grouping: Plugin pages with a group field render in separate collapsible sidebar groups; ungrouped pages remain in "Plugins"
  • Icon resolution: resolveIcon() helper maps 30+ icon names to Phosphor components with fallback to defaults
  • Nested submenus: NavItem.children support with NavSubMenu expandable component (max 1 level of nesting)
  • Sidebar config: hideCoreFeatures and hideCollections options in EmDashConfig.sidebar to hide items from the nav
  • RTL-safe: All layout uses logical Tailwind classes (ms-*, ps-*, start-*); chevrons flip in RTL

Menu Sync

  • addToMenu: New field on CreateCollectionInput — auto-adds a type: "collection" menu item to the specified public menu on collection creation
  • Auto-cleanup: Deleting a collection automatically removes its menu items
  • Manual sync endpoint: POST /_emdash/api/schema/collections/:slug/sync-menu to add a collection to a menu after creation
  • Full sync engine:
    • GET /_emdash/api/menus/:name/sync-diff — preview changes (toAdd, toRemove, toReorder)
    • POST /_emdash/api/menus/:name/sync — apply changes to align menu with sidebar structure

Reordering UI

  • CollectionReorderDialog: Drag-and-drop dialog using @dnd-kit/core + @dnd-kit/sortable for reordering collections
  • API endpoint: POST /_emdash/api/schema/collections/reorder — batch updates sort_order for multiple collections
  • Integration: "Reorder" button added to Content Types admin page

Related PR

Type of change

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions