Problem/Motivation

As a site builder, I want to have a visual representation of the libraries that are attached within the template so that I can have a clear picture of things affecting this page.

Proposed resolution

Add a libraries widget to the component_override entity form. The imported twig file should be scanned for library attachments and the widget should visualize those libraries and allow manipulating/extending the libraries attached to the component_override. When the component_override is rendered, the libraries should be attached. The libraries should not be displayed inside the template editor on the component_override form.

User interface changes

  • These attachments should be visualized within the component_override entity form as a new field on the Component Override entity.
  • This field should be populated with the discovered libraries from the template
  • Existing libraries from the core libraries api should be able to be selected and added to this form element(s)
  • Element should be multi-value
  • Element should support removing libraries from the override

Data model changes

Add a libraries property (array) to the component_override config entity.

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

s_leu created an issue. See original summary.

s_leu’s picture

s_leu’s picture

Status: Active » Needs review

I couldn't change the MR target branch on the MR created automatically on the issue fork, so I filed a custom MR that can be used to review the changes relevant for this issue against the changes of the parent issue here: https://git.drupalcode.org/issue/component_library-3259011/-/merge_reque...

tim bozeman’s picture

The changes from #3259011: Add Component Overrides have been merged to the 1.0.x branch. Maybe just rebasing would make it easier to review ¯\_(ツ)_/¯

fabianx’s picture

     $libraries = $override->get('libraries');
      foreach ($libraries as $library) {
        $template .= "{{ attach_library('$library') }}\n";
      }

I would probably attach the libraries in front of the template - just because that's usually the convention where to do that.

heddn’s picture

Status: Needs review » Needs work

Let's rebase the MR so it is easier to review.

s_leu’s picture

Status: Needs work » Needs review

The branch is rebased now and the MR ready for merging. Unfortunately I was unable to get tests running locally, thus I didn't add the code extending the tests in the main branch of the MR, but pushed it here: https://git.drupalcode.org/issue/component_library-3262430/-/tree/326243...

tim bozeman’s picture

The Override Mode UI is about ready so, I rebased this branch against #3264776: Add an Override Mode UI. It seems to be working, but do you want to double check I didn't break anything @s_leu?

tim bozeman’s picture

Rebased again against 1.0.x.

s_leu’s picture

Thanks for the rebases @Tim Bozeman . I checked it and made some changes, mainly dropping obsolete code that got obsolete after the rebase and the changes it introduced. Everything is still working as expected, so this is ready for another review by someone else. Or should we RTBC it already?

  • s_leu authored 63381a1 on 1.0.x
    Issue #3262430 by s_leu: Component Overrides: Show attached Libraries
    
tim bozeman’s picture

Status: Needs review » Fixed

Very nice. Thanks!

tim bozeman’s picture

Status: Fixed » Closed (fixed)