Make version indicator source and version indicator source fallback configurable.

Created on 30 November 2022, almost 2 years ago
Updated 22 July 2024, 4 months ago

Problem/Motivation

Since version 4.0.11, the toolbar item includes a random string of characters in parentheses to the left of the environment name. This appears to be where the release state information would appear. We don't set this state in our site and the random string of characters never appeared before version 4.0.11.

Steps to reproduce

1. Update to 4.0.11.
2. Do not set or unset a environment_indicator.current_release version state.

Proposed resolution

A merge request has been submitted to address this issue: MR #44.

The proposed solution in the merge request makes several changes:
1. Introduces new configuration settings for `version_identifier` and `version_identifier_fallback` in `environment_indicator.settings.yml`.
2. Adds these settings to the schema and a new update hook to initialize them.
3. Updates the `ToolbarHandler` class to use these new settings and display the appropriate version identifier.
4. Updates the settings form to allow selecting the source of the version identifier and a fallback option.

For existing sites, the update hook `environment_indicator_update_8101` ensures backward compatibility by initializing the new settings with default values if they are not already set:

  function environment_indicator_update_8101() {
    $config_factory = \Drupal::configFactory();
    $settings = $config_factory->getEditable('environment_indicator.settings');
    if ($settings->get('version_identifier') === NULL) {
      $settings->set('version_identifier', 'environment_indicator_current_release');
    }
    if ($settings->get('version_identifier_fallback') === NULL) {
      $settings->set('version_identifier_fallback', 'deployment_identifier');
    }
    $settings->save();
  }

When I set a release state with the recommended Drush command on the environment indicator settings screen, the random characters go away and the release version I set appears. (drush sset environment_indicator.current_release v1.2.44)

This confirms that the random string issue is due to the missing release state. The merge request will resolve this by ensuring the release state is only displayed when it is explicitly set.

How to test

1. Ensure the Environment Indicator UI module is enabled.
2. Update your site to the latest version including the merge request changes.
3. Navigate to the environment indicator settings page at `/admin/config/development/environment-indicator`.
4. Verify that the new settings for `version_identifier` and `version_identifier_fallback` are present.
5. Ensure the default values are set correctly for both settings.
6. Test by not setting the `environment_indicator.current_release` state and observe that no random string appears.
7. Set a release state using the command: drush sset environment_indicator.current_release v1.2.44 and verify that the release version appears correctly.
8. Change the `version_identifier` setting to different options (e.g., `deployment_identifier`, `drupal_version`, `none`) and verify the output in the toolbar.
9. Ensure the fallback option works by setting `version_identifier` to a non-existing source and checking if the fallback value is used.

For convenience, a Landofile is provided in the merge request body for those who want to use it.

Screenshots of the New UI

✨ Feature request
Status

RTBC

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States timwood Rockville, Maryland

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024