statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Environments - Option 2: Environment files and (not)editing in CP #2447

Open miloslavkostir opened 4 years ago

miloslavkostir commented 4 years ago

Option 2: Environment files doesn't show Managed externally by your environment. in CP (as the doc says here) Option 1: Interpolation works well.

.env:

APP_ENV=dev

site/settings/debug.yaml:

debug: false
debug_bar: false
loggers:
  file:
    daily: true

site/settings/environments/dev.yaml:

settings:
  debug:
    debug: true
    debug_bar: true

Settings works. Debug is enabled as long as APP_ENV equal dev in .env file. But in CP I expect Managed externally by your environment. But there are regular editable inputs.

If APP_ENV == dev and site/settings/environments/dev.yaml exists (as above): I can change the settings and submit the form. Statamic says Settings saved. but no change is saved in fact. After page refresh there are an original values (values from site/settings/environments/dev.yaml).

If APP_ENV != dev and current-env .yaml file doesn't exists: I can change the settings, submit the form and changes are saved successfully into default settings file site/settings/debug.yaml

Expected behavior

Environment details:

peschee commented 4 years ago

I can confirm this. Using Option 2 does not make the values in CP non-editable.

Using values from an environment file .env disables a settings field entirely. Instead the message "Managed externally by your environment." is displayed.

@miloslavkostir In your example, this would mean using:

site/settings/environments/dev.yaml

settings:
  debug: "{env:APP_DEBUG}"
    debug: true
    debug_bar: true

.env

APP_DEBUG=true

From what the docs state, both options should disable the editing of the values in CP.

This seems like a bug @jackmcdade @jasonvarga?

jasonvarga commented 4 years ago

Agreed its a bug. But in my opinion it's better to use the .env option anyway. The other way is removed in v3, it's confusing.