Problem/Motivation

Currently, the module requires the user to set the title, bg colors and fg colors through configuration in settings.local.php. This works, however, these values have already been set in the language switcher, so it often becomes a duplication of effort.

It would be preferable to be able to set the local environment colors through two other methods:

1. A machine name of one of the environments defined on the environment switchers page could be used instead, with the values for the environment title, background color, and foreground color pulled from the switcher values defined in config.

2. One of the environments defined on the switchers page should be selectable on the module settings page, and stored in the Drupal state (so the value is does not become part of configuration, and can be set uniquely per environment)

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

jigarius created an issue. See original summary.

jigarius’s picture

Status: Active » Needs review
StatusFileSize
new738 bytes

Here's what I tried and it works by adding just 2-3 lines. Please let me know if something needs to be improved.

jigarius’s picture

StatusFileSize
new708 bytes

Oops. Forgot to delete an unnecessary line. This patch works :D I'm using it on a production site at the moment.

jigarius’s picture

StatusFileSize
new830 bytes

Here's a revision to handle the case where an environment with a specified ID doesn't exist. I chose to go with an exception to let the user (developer) know that the environment indicator is not working correctly and something needs to be fixed.

jigarius’s picture

StatusFileSize
new830 bytes

Thinking about it a little more, the key "id" is a bit conflictive. Thus, I've renamed it to "switcher_id" to make it more clear.

mιχaliς’s picture

It works, but can you change your original description post to change

$config['environment_indicator.indicator']['id'] = 'local';

by

$config['environment_indicator.indicator']['switcher_id'] = 'local';

It works with 4.0.3 module version.

Thanks

jaypan’s picture

Re-rolling for 4.x branch. Included option to set the current environment on the module settings page.

jaypan’s picture

Title: Allow setting environment id in environment_indicator.indicator » Use switcher values for toolbar colors
jaypan’s picture

Title: Use switcher values for toolbar colors » Use switcher values for toolbar title, fg_color and bg_color
jaypan’s picture

Adding functionality where the toolbar link to the current environment is not shown when the current environment is set (as it has no use in this situation).

dshumaker’s picture

Thank you @Jaypan , your patch #10 works nicely.

dshumaker’s picture

Status: Needs review » Reviewed & tested by the community
devkinetic’s picture

Status: Reviewed & tested by the community » Needs work

This patch needs a reroll now that #2610208: Move procedural functions to a manager has landed.

ankitjhakal’s picture

Assigned: Unassigned » ankitjhakal
ankitjhakal’s picture

Priority: Normal » Major
StatusFileSize
new14.47 KB

Hi @devkinetic, Rerolled the patch, Attached patch working fine on my local machine. I have added the code for issue(https://www.drupal.org/project/environment_indicator/issues/3324429) in the same patch as i was not able to work without it. Moving this to need review status. Using this patch will need to add only single patch.

ankitjhakal’s picture

Assigned: ankitjhakal » Unassigned
Status: Needs work » Needs review
ankitjhakal’s picture

Assigned: Unassigned » ankitjhakal
StatusFileSize
new14.46 KB

Updated my patch little bit. Added extra check.

ankitjhakal’s picture

Assigned: ankitjhakal » Unassigned
jigarius’s picture

Status: Needs review » Needs work

The patch in comment 17 doesn't apply on version 4.0.14.

Suggestion: I was wondering, can't we try the new merge request work flow instead of the patches? It will make it clear whether the merge can still be performed.

dshumaker’s picture

@jigarius I added patch 17 to the Merge request: https://git.drupalcode.org/project/environment_indicator/-/merge_request...

dshumaker’s picture

Status: Needs work » Needs review
devkinetic’s picture

So this solution still requires editing settings.php to add the machine name of the config entity. I think it would be more useful if we did away with the settings.php stuff entirely and instead did regex/hostname matching on the active environment. I have an issue at #3380586: Implement the current environment as a service and utilize plugins where I use that approach vs the MR on this issue. If you agree with me, I'd welcome closing this issue out and moving the work over there. One thing I really liked about this issue is you created a service, rather than stuffing ToolbarHandler with the logic.

jaypan’s picture

I've actually just started setting up config splits, and working with the Environment Indicator UI module to set up the various environments, and stopped using this patch. I can see how this functionality could/would be beneficial for some people, but for me it because irrelevant with the Indicator UI module.