Skip to content

Resolve #3324621 Make version indicator source and version indicator source fallback configurable.

image

Overview

This merge request introduces several enhancements and fixes to the Environment Indicator module, focusing on the configurability of the version identifier displayed in the environment indicator and improving the overall code structure and documentation.

Changes Made

  1. Configuration Schema Updates:

    • Added the version_identifier field to the environment_indicator.settings configuration schema.
    • Added the version_identifier_fallback field to the environment_indicator.settings configuration schema.
  2. Form Updates:

    • Updated EnvironmentIndicatorSettingsForm to include a select field for version_identifier with options and descriptions.
    • Updated EnvironmentIndicatorSettingsForm to include a select field for version_identifier_fallback with options and descriptions.
  3. Help Text Enhancements:

    • Revised the environment_indicator_help function to provide detailed information about the version identifier options.
    • Consolidated help information about the Deployment Identifier and its usage.
    • Created a new section in the help text to explain how to set each version identifier option.
  4. ToolbarHandler Modifications:

    • Updated the getCurrentRelease method to handle the new version_identifier and version_identifier_fallback configuration.
    • Implemented logic to return the appropriate version identifier based on the selected options.
  5. Update Hook:

    • Added environment_indicator_update_8101 to initialize the version_identifier setting for existing installations, ensuring it defaults to environment_indicator_current_release .
    • Added environment_indicator_update_8101 to initialize the version_identifier_fallback setting for existing installations, ensuring it defaults to deployment_identifier .
  6. Documentation and Code Clean-Up:

    • Improved code comments and documentation throughout the module.
    • Refactored and optimized various parts of the code for better readability and maintainability.
  7. Update Install Configuration

  • Added version_identifier config to the default install configuration. Set default to match existing functionality
  • Added version_identifier_fallback config to the default install configuration. Set default to match existing functionality

How to Test

  1. Configuration:

    • Navigate to the Environment Indicator settings page.
    • Verify that the Source of version identifier to display select field is present with the correct options.
    • Verify that the Fallback source of version identifier to display select field is present with the correct options.
    • Verify that you can not choose the same option for both the source and fallback.
    • Select different options and save the configuration.
  2. Functionality:

    • Set the environment_indicator.current_release state and verify it displays correctly.
    • Set the deployment identifier in settings.php and verify it displays correctly.
    • Verify the correct Drupal version displays when selected.
    • Ensure no version identifier is displayed when none is selected.
  3. Help Text:

    • Verify the help text on the settings page provides detailed and accurate information about the version identifier options.

Additional Notes

  • Ensure to clear the cache after applying the update to reflect the new configuration and help text changes.
  • Review the deployment identifier mechanism documentation to understand its integration with various hosting providers.

This merge request significantly enhances the configurability of the Environment Indicator module, providing users with more flexibility in displaying version identifiers and improving the overall user experience.

This .lando.yml file worked for me when testing.

name: environment_indicator
recipe: drupal10
config:
  php: '8.2'
  via: apache:2.4
  webroot: web
  database: mariadb:10.4
  xdebug: false
services:
  database:
    type: compose
    services:
      image: mariadb:10.4
      command: docker-entrypoint.sh mariadbd
      restart: always
      ports:
        - '3306'
      environment:
        MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'true'
        MARIADB_DATABASE: drupal10
        MYSQL_DATABASE: drupal10
        MARIADB_USER: drupal10
        MARIADB_PASSWORD: drupal10
  appserver:
    overrides:
      environment:
        SIMPLETEST_DB: 'mysql://drupal10:drupal10@database/drupal10'
        SIMPLETEST_BASE_URL: 'http://appserver'
      volumes:
        # Don't share our host working directory as /app. We want /app empty for composer.
        - /app
        # Instead share our host working directory as a standalone package.
        - .:/usr/local/environment_indicator
    build:
      # Create a new Drupal project and use the module as a non-packagist repository.
      - composer create-project --dev drupal/recommended-project:10.2.x /app
      - composer config extra.enable-patching true
      - composer config extra.composer-exit-on-patch-failure true
      - composer config allow-plugins.cweagans/composer-patches true
      - composer require cweagans/composer-patches
      - composer config minimum-stability dev
      - composer config allow-plugins.phpstan/extension-installer true
      - composer require --dev drupal/core-dev:^10.2 drush/drush phpspec/prophecy-phpunit:* phpstan/extension-installer mglaman/phpstan-drupal phpstan/phpstan-deprecation-rules drupal/config_inspector
      - composer config repositories.localdev path /usr/local/environment_indicator && composer require drupal/environment_indicator:\*@dev
tooling:
  # Provide a command to install Drupal.
  install:
    service: appserver
    cmd:
      - /app/vendor/bin/drush --root=/app/web site:install --account-mail=noreply@example.com --account-name=admin --account-pass=admin --db-url=mysql://drupal10:drupal10@database:3306/drupal10 -y --verbose
      - /app/vendor/bin/drush en -y environment_indicator config_inspector
  # Provide Drush tooling to automatically know the Drupal root.
  drush:
    service: appserver
    cmd: /app/vendor/bin/drush --root=/app/web
  phpcs:
    service: appserver
    cmd: /app/vendor/bin/phpcs -s --colors --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/environment_indicator
  # Provide PHPCBF tooling to fix coding standards.
  phpcbf:
    service: appserver
    cmd: /app/vendor/bin/phpcbf -s --colors --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/environment_indicator
  # Provide phpstan tooling to check for code quality and deprecated code.
  phpstan:
    service: appserver
    cmd: /app/vendor/bin/phpstan analyse --configuration web/modules/contrib/environment_indicator/phpstan.neon web/modules/contrib/environment_indicator
  # Provide phpunit tooling to run unit tests.
  phpunit:
    service: appserver
    cmd: /app/vendor/bin/phpunit --configuration /app/web/core/phpunit.xml.dist --bootstrap /app/web/core/tests/bootstrap.php /app/web/modules/contrib/environment_indicator
Edited by Chris Green

Merge request reports