Issue #3530958: Create an example code component for menus
For #3530958
- Adds an example component demonstrating a menu
- Adds a utility class for helping with json:api that sorts menus
- Extracts getPath from the Article List examples and adds it to the new utility class
- A little bit of naming tidy up to make things consistent
Testing Instructions
- Check out this branch
- Run
npm run build
and clear cache - Run the following:
drush site:install minimal
drush recipe modules/contrib/experience_builder/tests/fixtures/recipes/base
drush pm:install experience_builder
drush php-eval "Drupal\experience_builder\Entity\Page::create(['title' => 'Homepage', 'type' => 'xb_page', 'path' => ['alias' => '/homepage', 'langcode' => 'en']])->save();"
composer require drupal/jsonapi_menu_items
drush pm:enable jsonapi jsonapi_menu_items menu_ui
- Login, go to
/admin/config/services/linkset
and enable the menu linkset endpoint - Go to
/admin/structure/menu/manage/main
and create menu items, with nesting - Go to
/homepage
and then click "Edit" - Click + (Add) on the left hand menu, "+ Add new", give the component a name and click Add
- In the experience_builder module source code go to
tests/fixtures/code_components/menus
- Copy the example into the editor and verify you get a menu rendered, with working submenu items
- Verify the data fetched from the menu endpoint is shown in the Data Fetch pane
- Save the code component, and drag it from the Components list to the content area of a page and verify the menu is rendered as expected
Edited by Sally Young