Problem/Motivation

Navigation needs to provide a simple way to add new blocks programmatically.

This issue aims to provide these config actions that would allow to integrate Navigation with recipes.

Steps to reproduce

N/A

Proposed resolution

Provide Config Action to add new blocks to navigation from recipes

Remaining tasks

Review

User interface changes

N/A

Introduced terminology

N/A

API changes

New config action

Data model changes

N/A

Release notes snippet

TBD

Issue fork drupal-3478224

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

plopesc created an issue. See original summary.

plopesc’s picture

First shot for this one.

It allows to provide a recipe like this:

name: Navigation Block Test Recipe
type: Examples
description: 'Adds a block to Navigation.'
install:
  - navigation
config:
  actions:
    navigation.block_layout:
      addNavigationBlock:
        position: 1
        configuration:
          id: 'navigation_menu:content'
          label: Content From Recipe
          label_display: 1
          provider: navigation
          level: 1
          depth: 2

After applying the recipe, a new block with the settings described above is added to the Navigation.

This one needs tests and some extra work, but let's open the discussion about it.

penyaskito’s picture

I hoped we could do this generically or at least provide a trait in layout builder so we don't repeat ourselves. See #3475115: Provide a Config Action to add a component in a layout. I have some WIP for that one that I will upload before next week.

plopesc’s picture

Thank you for bringing up that issue, I was unaware of it. Definitely avoid reinventing the wheel should be a priority.

Navigation use case might differ a bit, given that sections and regions are more limited than in other scenarios. I'm pretty sure we could take advantage of that trait, though.

This initial approach is a proof of concept to validate the approach. More than happy to readjust it to be based on the code in the mentioned issue once it is ready.

Thanks!

plopesc’s picture

plopesc’s picture

Issue tags: +Starshot blocker

This will be probably necessary for Starshot.

plopesc’s picture

Status: Active » Needs review

Initial approach including base test coverage.

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs change record

Appears to have some open threads

Also tagging for a change record.

m4olivei’s picture

MR looks pretty good. The other core issue, #3475115: Provide a Config Action to add a component in a layout is moving along since last mentioned here. When I looked over it, it seems like it would cover our use case. It's also been marked as a Starshot blocker, so the timeline should fit our needs here.

@plopsec, what do you think? If it covers everything we need, this issue would no longer be relevant correct?

plopesc’s picture

@m4olivei The way LB is implemented in Navigation, nested in a different config entity makes impossible to use the trait approach described in #3475115: Provide a Config Action to add a component in a layout.

We discovered it when I tried to apply it to this one. See comments #6 & #7 in #3475115: Provide a Config Action to add a component in a layout.

If we want to provide config actions for Navigation, with the tools we have today, it should be based on a custom plugin.

m4olivei’s picture

Assigned: Unassigned » m4olivei

@m4olivei The way LB is implemented in Navigation, nested in a different config entity makes impossible to use the trait approach described in #3475115: Provide a Config Action to add a component in a layout.

Ahh, now I understand. Thanks for explaining that. Our LB configuration is in simple config, whereas the config action in #3475115: Provide a Config Action to add a component in a layout needs to work on config entities.

I'll work on the remaining feedback here.

m4olivei’s picture

Assigned: m4olivei » Unassigned
Status: Needs work » Needs review

All threads are addressed. Looking good to me. Setting to Needs review.

pameeela’s picture

phenaproxima’s picture

Status: Needs review » Needs work

This seems straightforward enough to me. I have a few minor points but otherwise I'd say RTBC.

plopesc’s picture

Status: Needs work » Needs review

Thank you for your review. Feedback addressed.

plopesc’s picture

Issue tags: -Needs change record

Draft CR created.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed the code, checked all the feedback and verified it was resolved.
This unblocks some usecases for the dashboard contrib module too.
So RTBC.

catch made their first commit to this issue’s fork.

  • catch committed 9a90e5e0 on 11.1.x
    Issue #3478224 by plopesc, m4olivei, penyaskito, dmitry.korhov,...

  • catch committed f91792e4 on 11.x
    Issue #3478224 by plopesc, m4olivei, penyaskito, dmitry.korhov,...
catch’s picture

Version: 11.x-dev » 11.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 11.1.x, thanks!

plopesc changed the visibility of the branch 3478224-proof-of-concept to hidden.

thejimbirch’s picture

Issue tags: +Recipes initiative
thejimbirch’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.