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)
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | issue-3210116-17.patch | 14.46 KB | ankitjhakal |
| #15 | issue-3210116-15.patch | 14.47 KB | ankitjhakal |
| #10 | environment_indicator-options_for_setting_current_environment.3210116.10.patch | 12.23 KB | jaypan |
Issue fork environment_indicator-3210116
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
Comment #2
jigariusHere's what I tried and it works by adding just 2-3 lines. Please let me know if something needs to be improved.
Comment #3
jigariusOops. Forgot to delete an unnecessary line. This patch works :D I'm using it on a production site at the moment.
Comment #4
jigariusHere'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.
Comment #5
jigariusThinking 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.
Comment #6
mιχaliς commentedIt works, but can you change your original description post to change
by
It works with 4.0.3 module version.
Thanks
Comment #7
jaypanRe-rolling for 4.x branch. Included option to set the current environment on the module settings page.
Comment #8
jaypanComment #9
jaypanComment #10
jaypanAdding 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).
Comment #11
dshumaker commentedThank you @Jaypan , your patch #10 works nicely.
Comment #12
dshumaker commentedComment #13
devkinetic commentedThis patch needs a reroll now that #2610208: Move procedural functions to a manager has landed.
Comment #14
ankitjhakal commentedComment #15
ankitjhakal commentedHi @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.
Comment #16
ankitjhakal commentedComment #17
ankitjhakal commentedUpdated my patch little bit. Added extra check.
Comment #18
ankitjhakal commentedComment #19
jigariusThe 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.
Comment #21
dshumaker commented@jigarius I added patch 17 to the Merge request: https://git.drupalcode.org/project/environment_indicator/-/merge_request...
Comment #22
dshumaker commentedComment #23
devkinetic commentedSo 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.
Comment #24
jaypanI'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.