From a88c489a6018e01ac16983b73a4e740b80278ce4 Mon Sep 17 00:00:00 2001
From: Ahmad Bamieh <ahmadbamieh@gmail.com>
Date: Thu, 15 Aug 2019 02:08:19 +0300
Subject: [PATCH] [telemetry] add spacesEnabled config back to xpack_main
 (#43312)

* add spacesEnabled config back to xpack

* move some variables back to xpack_main

* fix import path
---
 x-pack/legacy/plugins/telemetry/index.ts  |  3 ---
 x-pack/legacy/plugins/xpack_main/index.js | 10 ++++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/x-pack/legacy/plugins/telemetry/index.ts b/x-pack/legacy/plugins/telemetry/index.ts
index 4125dae82f9fa..b1f5a953ab1d3 100644
--- a/x-pack/legacy/plugins/telemetry/index.ts
+++ b/x-pack/legacy/plugins/telemetry/index.ts
@@ -64,12 +64,9 @@ export const telemetry = (kibana: any) => {
       injectDefaultVars(server: Server) {
         const config = server.config();
         return {
-          telemetryEnabled: getXpackConfigWithDeprecated(config, 'telemetry.enabled'),
           telemetryUrl: getXpackConfigWithDeprecated(config, 'telemetry.url'),
-          spacesEnabled: config.get('xpack.spaces.enabled'),
           telemetryBanner: config.get('xpack.telemetry.banner'),
           telemetryOptedIn: null,
-          activeSpace: null,
         };
       },
       hacks: [
diff --git a/x-pack/legacy/plugins/xpack_main/index.js b/x-pack/legacy/plugins/xpack_main/index.js
index 14be51bc871e6..4feb69f62cd19 100644
--- a/x-pack/legacy/plugins/xpack_main/index.js
+++ b/x-pack/legacy/plugins/xpack_main/index.js
@@ -10,6 +10,7 @@ import {
   XPACK_DEFAULT_ADMIN_EMAIL_UI_SETTING,
   XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS
 } from '../../server/lib/constants';
+import { getXpackConfigWithDeprecated } from '../telemetry/common/get_xpack_config_with_deprecated';
 import { mirrorPluginStatus } from '../../server/lib/mirror_plugin_status';
 import { replaceInjectedVars } from './server/lib/replace_injected_vars';
 import { setupXPackMain } from './server/lib/setup_xpack_main';
@@ -75,6 +76,15 @@ export const xpackMain = (kibana) => {
         'plugins/xpack_main/hacks/check_xpack_info_change',
       ],
       replaceInjectedVars,
+      injectDefaultVars(server) {
+        const config = server.config();
+
+        return {
+          telemetryEnabled: getXpackConfigWithDeprecated(config, 'telemetry.enabled'),
+          activeSpace: null,
+          spacesEnabled: config.get('xpack.spaces.enabled'),
+        };
+      },
       __webpackPluginProvider__(webpack) {
         return new webpack.BannerPlugin({
           banner: dedent`