From cbbfaba6acbc0e04ee5ef589375659da645d6336 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 17 Apr 2019 09:25:08 +0100 Subject: [PATCH] ui: Adds easily accessible `env` for user settable 'debug' settings (#5668) This is a synchronous only 'debug' setting accessor, uses localStorage first and falls back to ember config. --- ui-v2/app/env.js | 5 +++++ ui-v2/app/instance-initializers/event-source.js | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 ui-v2/app/env.js diff --git a/ui-v2/app/env.js b/ui-v2/app/env.js new file mode 100644 index 0000000000..5b4ab0e371 --- /dev/null +++ b/ui-v2/app/env.js @@ -0,0 +1,5 @@ +import config from './config/environment'; +export default function(str) { + const user = window.localStorage.getItem(str); + return user !== null ? user : config[str]; +} diff --git a/ui-v2/app/instance-initializers/event-source.js b/ui-v2/app/instance-initializers/event-source.js index d2a707ee10..3ad5c102d0 100644 --- a/ui-v2/app/instance-initializers/event-source.js +++ b/ui-v2/app/instance-initializers/event-source.js @@ -1,8 +1,7 @@ -import config from '../config/environment'; +import env from 'consul-ui/env'; -const enabled = 'CONSUL_UI_DISABLE_REALTIME'; export function initialize(container) { - if (config[enabled] || window.localStorage.getItem(enabled) !== null) { + if (env('CONSUL_UI_DISABLE_REALTIME')) { return; } ['node', 'coordinate', 'session', 'service', 'proxy']