Add configuration import

Created on 9 April 2025, about 1 month ago

Problem/Motivation

As a user of this module it would be nice if the configuration for the alert type was created by enabling this module.
As an existing user of the Sitewide Alert module, it would be nice if enabling this module did not blow out any existing types that we had previously defined.

Acceptance Criteria

  1. Types of USWDS Alert showed in the Sitewide Alert "Type" selector.
    1. Alert - Success
    2. Alert - Warning
    3. Alert - Error
    4. Alert - Informative
    5. Alert - Emergency
    6. Alert information paragraph width, and Slim should not be added because the narrow version would not be used in the blocks, they are more for use within content.
  2. Types of USWDS Site Alert showed in the Sitewide Alert "Type" selector.
    1. Site Alert - Informational
    2. Site Alert - Emergency
  3. Enabling this module should not overwrite any pre-existing "Types" if the Sitewide Alert module is already in use.

Proposed resolution

There are three options that occur to me at this time:

  1. Add config/install yml that is a copy of what you get when you create these by hand then to config export. Thre drawback to this method is that it will overwrite existing Types.
  2. Create a Recipe. - it is not clear if a recipe can add to existing config or if it always overwrites.
  3. Create a hook_install that adds them programatically.
✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States swirt Florida

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @swirt
  • πŸ‡ΊπŸ‡ΈUnited States donnahanlon
  • πŸ‡ΊπŸ‡ΈUnited States skyriter
  • Merge request !5Adds install file with config change β†’ (Merged) created by skyriter
  • πŸ‡ΊπŸ‡ΈUnited States skyriter

    I have added configuration and an install file to update the Alert Styles select list.

    Here's what it looks like now:

  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    I think I understand. Are you saying that config/install in uswds_alert will squash the settings (or the config/install in sitewide_alert)?

    I think there is a possibility. There is a chance of one thing clobbering the other. Uncharted territory for me. We probably have to do some testing with a site that has a mock existing setup of sitewide_alert and then see what happens when uswds alert is installed after that.

  • πŸ‡ΊπŸ‡ΈUnited States davidmpickett

    I've got a bunch of thoughts, but I don't think any of them should block merging. This functions as intended.

    • Alert Message field is not required. This seems weird, having an empty alert doesn't seem like a valid use case. But this is probably something we can't/shouldn't mess with because it comes from the Sitewide Alert module?
    • On Form Display and Display, is it possible for us to make the field_heading come before message on install? Or is that too complicated because we're adding fields to existing type? It's a simple enough configuration change to make after install, but more asking for my own education about best practices in module architecture.
    • i just noticed that Sitewide Alert has a Display Order setting in the configuration. Makes me once again question whether adding the weight field is correct for MVP if there's already a system for ordering alerts built into the base module
    • Another thing that's probably not our monkeys or our circus, but why are the Structure settings (Form Display/ Display etc.) for Sitewide Alerts under Configuration/User Interface rather than under Structure? Is this a limitation of modules, or just a choice the authors of Sitewide Alerts made?
  • πŸ‡ΊπŸ‡ΈUnited States davidmpickett

    Display Order field in configuration

  • πŸ‡ΊπŸ‡ΈUnited States davidmpickett

    Another question about field machine names. What's best practice for naming fields? I know on the VA we would title our fields very specifically to their context. So the Heading field might be field_alert_heading rather than field_heading.

    My understanding is that if two fields have the same name they share some settings and so being specific avoids potential collisions with other fields that someone may have. field_heading seems like it could be pretty common.

  • πŸ‡ΊπŸ‡ΈUnited States skyriter

    Requiring message

    I agree about Alert Message not being required seems odd. I wouldn't want to make it required, though, given that we're using that pre-existing field, so that we are backwards compatible.

    Order of Heading

    We should be able to add Heading before Alert Message without issue.

    Display order

    I think we can still use Weight and only when it's the same as the another weight do we use the Display Order setting. We can add that to the help text for weight Weight.

    Configuration

    Where the config page shows is set in the routing file. I'd leave it be.

    Field name

    Given that this is a field on a custom entity type rather than a node, we're only going a conflict if we add another heading field to it.

  • πŸ‡ΊπŸ‡ΈUnited States davidmpickett

    Discussion from meeting today:

    • What happens if someone is already using a Sitewide Alert and has added their own field_heading?
    • We will test to make sure nothing breaks
    • Christian will merge this ticket as is
  • πŸ‡ΊπŸ‡ΈUnited States skyriter
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024