Problem/Motivation

As part of #3441100: Integrate Umami message, the new messages component was introduced in Navigation to give support to Umami. That component could be used by other modules or profiles to provide their own messages as well.

Would be great to convert it to SDC to be more consistent with the rest of Navigation buttons.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3502993

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

nod_’s picture

Status: Postponed » Active
nod_’s picture

Title: [PP-1] Convert Navigation messages component to SDC » Convert Navigation messages component to SDC

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

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

finnsky’s picture

Status: Active » Needs review

Everything looks much cleaner and simpler now!
Please take a look

pdureau’s picture

Assigned: Unassigned » pdureau

i will have a look

pdureau’s picture

It is a very nice SDC component! I love the facts you are not using Twig blocks fro your slot, iri-reference for URL prop, and both the definition and the template are very clean 👍

A few feedbacks however...

Little cleanups

Slots are not typed, so you need to remove "type" property:

slots:
  content:
    type: string
    description: Message content.

It seems you are using BEM methodology for the class naming, so this:

{%
  set classes = [
    'toolbar-message',
    'toolbar-message--type--' ~ type,
  ]
%}

Would be better written like:

{%
  set classes = [
    'toolbar-message',
    'toolbar-message--' ~ type,
  ]
%}

data-drupal-tooltip

Don't use a slot as an attribute value. A slot can have anything, including markup, and may break the browser DOM.

setAttribute('data-drupal-tooltip', content).

So, what can we do? The obvious options would be:

  • Make content a string prop instead of a slot, especially if only plain text is expected here
  • Create a new string prop for this attribute value

However, the best would be to remove those attributes from the template:

setAttribute('data-drupal-tooltip', content).setAttribute('data-drupal-tooltip-class', 'admin-toolbar__tooltip')

Because they tell us about the context how/where the component is used instead of being proper parts of the component.

I would inject them from outside (non tested proposal):

          '#type' => 'component',
          '#component' => 'navigation:message',
          '#props' => [
            'type' => 'warning',
            'url' => $url,
           'attributes' => new Attribute({
              'data-drupal-tooltip': content, # raw? processed? or something else?
              'data-drupal-tooltip-class': 'admin-toolbar__tooltip'
          })
          ],

Side note

I am recommending executing drush sdcv umami from https://www.drupal.org/project/sdc_devel/ to automatically get useful warning and errors.

There are still some rough edges (unclear messages, false positives...) but this tools is already usable.

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Needs work
finnsky’s picture

Status: Needs work » Needs review
finnsky’s picture

Moved content to typed props.

Please review!

pdureau’s picture

Status: Needs review » Needs work

It looks good! Thanks a lot.

Some little proposals.

Definitions

Props:

  • type title is missing
  • content description is the same as the title, you can remove it

Templating

I am afraid {% if url is not empty %} is not catching when url value is missing. I would recommend the simpler {% if url %}

finnsky’s picture

Status: Needs work » Needs review

Thank you for quick response!
Fixed!

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative
StatusFileSize
new104.62 KB
new94.59 KB

Tested this on an Umami install

Hate uploading duplicate files almost but here's before and after

before

After

after

Looking at the MR my only question was going to be if content should be a slot but see @pdureau already addressed that and I'll 100% defer to him on all things SDC.

Rest looked good to me.

finnsky’s picture

@nod_ That dependency not needed anymore because CSS now provided in SDC

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

Fixed conflict in core/modules/navigation/src/Hook/NavigationHooks.php now that theme hooks moved to it's own.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I think we need to deprecate the theme hook if we can. Hopefully we can...

finnsky’s picture

@alexpott

It's not entirely clear what we should deprecate!

The SDC component and theme hook can work without Umami.
Even if Umami is disabled, many modules may want to add messages to the Navigation.

https://www.drupal.org/project/drupal/issues/3441100#comment-15770404

That's why we implemented the styles and functionality in the Navigation module and not in Umami.

Or did you mean something else? Please clarify!

alexpott’s picture

@finnsky when I made that comment this issue was removing stuff from \Drupal\navigation\Hook\NavigationThemeHooks::theme() - now it is not. The reason for this change is not explained in any of the recent comments... anyhow removing something from \Drupal\navigation\Hook\NavigationThemeHooks::theme() means that contrib and custom can have dead code that we need to tell people to remove.

finnsky’s picture

Status: Needs work » Needs review
finnsky’s picture

I think this misunderstanding arose because the hooks were previously reworked, causing a merge conflict.

So I'm sending it back to review because the hooks aren't currently being changed in the MR.

finnsky’s picture

As discussed in Slack
https://drupal.slack.com/archives/C7AB68LJV/p1763900832081709

removed navigation__message theme hook and added CR
https://www.drupal.org/node/3559492

smustgrave’s picture

Think the CR could use some love as that doesn't really seem to describe the impact.

I peaked the slack conversation @alexpott you mentioned "it is beta though" not sure if you meant core or the navigation module but navigation is marked stable so would this be a BC.

finnsky’s picture

I'm not so sure.
Should we update the CR or add the theme_hook handler we removed and issue a deprecation message?

smustgrave’s picture

Not entirely sure especially with 11.3 actually releasing today.

finnsky’s picture

I rebased and updated the CR.

Please check.

finnsky’s picture

Rebased

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

This one has taken a lot of twist and turns but I believe the feedback has been addressed. Know navigation is still not marked stable so should be safe to do? Going out on a limb.

alexpott’s picture

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

Committed and pushed 3b4e8c1c66c to main and e39714281b7 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed e3971428 on 11.x
    task: #3502993 Convert Navigation messages component to SDC
    
    By: plopesc...

  • alexpott committed 3b4e8c1c on main
    task: #3502993 Convert Navigation messages component to SDC
    
    By: plopesc...

  • catch committed 7b5d5ac9 on main
    fix: follow-up #3502993 to adjust AssetAggregationAcrossPagesTest.
    

  • catch committed 6923cfca on 11.x
    fix: follow-up #3502993 to adjust AssetAggregationAcrossPagesTest.
    
quietone’s picture

Correct version and branch on the change record.

Status: Fixed » Closed (fixed)

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