From 839e79d16eb4a11b3006cfb59c9eaddc7b2c68d6 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 000000000..5b4ab0e37 --- /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 d2a707ee1..3ad5c102d 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']