Add option to show environment indicator all the time instead of giving permission to each role

Created on 21 December 2024, 8 months ago

Problem/Motivation

I know I can give permission to all roles to achieve this, but I don't want environment indicator to be on my stage and/or production environment, and for that I use config exclude modules β†’ , but than all roles get deleted due to #3230825 issue ✨ Change config as if the modules defined in config_exclude_modules had been uninstalled Needs work .

Proposed resolution

Maybe we should add configuration option or override this via settings.php.

✨ Feature request
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡·πŸ‡ΈSerbia holo96

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

Merge Requests

Comments & Activities

  • Issue created by @holo96
  • Status changed to Needs review 3 months ago
  • πŸ‡·πŸ‡ΈSerbia holo96

    I guess I am only one needing this :)
    I've updated fork

    I am willing to improve it based on maintainers feedback.

  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

    Thank you for your inquiry, I've updated the issue summary. I welcome a merge request

  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ
  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ
  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ
  • Merge request !115Resolve #3495410 "Unrestriced access" β†’ (Open) created by holo96
  • Pipeline finished with Failed
    about 2 months ago
    Total: 214s
    #527445
  • πŸ‡·πŸ‡ΈSerbia holo96

    Updated merge request to match newest additions
    Updated README

  • Pipeline finished with Failed
    about 2 months ago
    Total: 1120s
    #527449
  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

    Hi @holo96,

    In light of ✨ Performance Improvements Active , I think we should take a slightly different approach.

    Rather than putting hasAccess() on the service, I’d propose a new helper in environment_indicator.module that calls less heavy functions like this:

    
    /**
     * Check if user has access to environment indicator.
     *
     * This function checks both the traditional permission and the new
     * unrestricted access setting.
     *
     * @return \Drupal\Core\Session\AccountProxyInterface|false
     *   The current user account if access is granted, FALSE otherwise.
     */
    function _environment_indicator_has_access() {
      $account = \Drupal::currentUser();
    
      // Check if unrestricted access is enabled in settings.php.
      if (Settings::get('environment_indicator_unrestricted_access', FALSE)) {
        return $account;
      }
    
      // Fall back to traditional permission check.
      if ($account->hasPermission('access environment indicator')) {
        return $account;
      }
    
      return FALSE;
    }
    

    See https://git.drupalcode.org/project/environment_indicator/-/merge_request...

    Additionally, I think we should find a way to let users know that they have this setting set in settings.php.

    From my perspective, site admins will likely not remember they have this setting set in settings.php and will begin pulling their hair out.

    I think we should add a notice on the `/admin/config/development/environment-indicator` page if the setting is enabled.

    Additionally, I think we should add some PHPUnit tests so we can feel confident about the feature functioning as expected in future updates.

  • πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ
Production build 0.71.5 2024