Преглед на файлове

HUE-8758 [connectors] Move cluster config into webpack

Johan Ahlen преди 5 години
родител
ревизия
4bfda743c5

+ 6 - 4
desktop/core/src/desktop/js/apps/table_browser/app.js

@@ -22,6 +22,7 @@ import huePubSub from 'utils/huePubSub';
 import MetastoreViewModel from 'apps/table_browser/metastoreViewModel';
 import hueUtils from 'utils/hueUtils';
 import I18n from 'utils/i18n';
+import { GET_KNOWN_CONFIG_EVENT, CONFIG_REFRESHED_EVENT } from 'utils/hueConfig';
 
 const HUE_PUB_SUB_EDITOR_ID = 'metastore';
 
@@ -130,11 +131,12 @@ huePubSub.subscribe('app.dom.loaded', app => {
 
   ko.applyBindings(viewModel, $('#metastoreComponents')[0]);
 
-  huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
-    viewModel.appConfig(clusterConfig && clusterConfig['app_config']);
-  });
+  const configUpdated = config => {
+    viewModel.appConfig(config && config['app_config']);
+  };
 
-  huePubSub.publish('cluster.config.get.config');
+  huePubSub.publish(GET_KNOWN_CONFIG_EVENT, configUpdated);
+  huePubSub.subscribe(CONFIG_REFRESHED_EVENT, configUpdated);
 
   if (location.getParameter('refresh') === 'true') {
     dataCatalog

+ 3 - 1
desktop/core/src/desktop/js/apps/table_browser/metastoreViewModel.js

@@ -21,6 +21,7 @@ import apiHelper from 'api/apiHelper';
 import huePubSub from 'utils/huePubSub';
 import hueUtils from 'utils/hueUtils';
 import MetastoreSource from 'apps/table_browser/metastoreSource';
+import { GET_KNOWN_CONFIG_EVENT } from 'utils/hueConfig';
 
 class MetastoreViewModel {
   /**
@@ -66,7 +67,8 @@ class MetastoreViewModel {
 
     this.loading = ko.pureComputed(() => !this.source() || this.source().loading());
 
-    huePubSub.publish('cluster.config.get.config', clusterConfig => {
+    // TODO: Support dynamic config changes
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, clusterConfig => {
       const initialSourceType = options.sourceType || 'hive';
 
       if (clusterConfig && clusterConfig.app_config && clusterConfig.app_config.catalogs) {

+ 3 - 2
desktop/core/src/desktop/js/hue.js

@@ -72,6 +72,7 @@ import SqlAutocompleter from 'sql/sqlAutocompleter';
 import sqlStatementsParser from 'parse/sqlStatementsParser'; // In search.ko and notebook.ko
 import HueFileEntry from 'doc/hueFileEntry';
 import HueDocument from 'doc/hueDocument';
+import { REFRESH_CONFIG_EVENT } from 'utils/hueConfig';
 
 // TODO: Migrate away
 window._ = _;
@@ -116,6 +117,8 @@ window.sqlUtils = sqlUtils;
 window.sqlWorkerHandler = sqlWorkerHandler;
 
 $(document).ready(() => {
+  huePubSub.publish(REFRESH_CONFIG_EVENT); // Prefetch the config early
+
   const onePageViewModel = new OnePageViewModel();
   ko.applyBindings(onePageViewModel, $('.page-content')[0]);
 
@@ -136,8 +139,6 @@ $(document).ready(() => {
     ko.applyBindings(sidebarViewModel, $('.hue-sidebar-container')[0]);
   }
 
-  huePubSub.publish('cluster.config.get.config');
-
   $(document).on('hideHistoryModal', e => {
     $('#clearNotificationHistoryModal').modal('hide');
   });

+ 7 - 9
desktop/core/src/desktop/js/ko/components/assist/ko.assistFunctionsPanel.js

@@ -21,6 +21,7 @@ import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import { PigFunctions, SqlFunctions } from 'sql/sqlFunctions';
 import I18n from 'utils/i18n';
+import { GET_KNOWN_CONFIG_EVENT, CONFIG_REFRESHED_EVENT } from 'utils/hueConfig';
 
 // prettier-ignore
 const TEMPLATE = `
@@ -171,16 +172,12 @@ class AssistFunctionsPanel {
       updateType(details.type);
     });
 
-    const configSub = huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
+    const configUpdated = config => {
       const lastActiveType =
         this.activeType() || apiHelper.getFromTotalStorage('assist', 'function.panel.active.type');
-      if (
-        clusterConfig.app_config &&
-        clusterConfig.app_config.editor &&
-        clusterConfig.app_config.editor.interpreters
-      ) {
+      if (config.app_config && config.app_config.editor && config.app_config.editor.interpreters) {
         const typesIndex = {};
-        clusterConfig.app_config.editor.interpreters.forEach(interpreter => {
+        config.app_config.editor.interpreters.forEach(interpreter => {
           if (
             interpreter.type === 'hive' ||
             interpreter.type === 'impala' ||
@@ -203,9 +200,10 @@ class AssistFunctionsPanel {
       } else {
         this.availableTypes([]);
       }
-    });
+    };
 
-    huePubSub.publish('cluster.config.get.config');
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, configUpdated);
+    const configSub = huePubSub.subscribe(CONFIG_REFRESHED_EVENT, configUpdated);
 
     this.disposals.push(() => {
       activeSnippetTypeSub.remove();

+ 20 - 13
desktop/core/src/desktop/js/ko/components/assist/ko.assistFunctionsPanel.test.js

@@ -16,26 +16,34 @@
 
 import huePubSub from 'utils/huePubSub';
 import AssistFunctionsPanel from './ko.assistFunctionsPanel';
+import { CONFIG_REFRESHED_EVENT, GET_KNOWN_CONFIG_EVENT } from 'utils/hueConfig';
 
 describe('ko.assistFunctionsPanel.js', () => {
   it('should handle cluster config updates', () => {
-    let clusterConfigGetCalled = false;
-    const configSub = huePubSub.subscribe('cluster.config.get.config', () => {
-      clusterConfigGetCalled = true;
-      huePubSub.publish('cluster.config.set.config', {
-        app_config: {
-          editor: {
-            interpreters: [{ type: 'pig' }, { type: 'pig' }, { type: 'impala' }, { type: 'banana' }]
+    const spy = jest.spyOn(huePubSub, 'publish').mockImplementation((topic, cb) => {
+      if (topic === GET_KNOWN_CONFIG_EVENT && cb) {
+        cb({
+          app_config: {
+            editor: {
+              interpreters: [
+                { type: 'pig' },
+                { type: 'pig' },
+                { type: 'impala' },
+                { type: 'banana' }
+              ]
+            }
           }
-        }
-      });
+        });
+      }
     });
     const subject = new AssistFunctionsPanel();
 
-    expect(clusterConfigGetCalled).toBeTruthy();
+    expect(spy).toHaveBeenCalled();
     expect(subject.availableTypes()).toEqual(['impala', 'pig']);
 
-    huePubSub.publish('cluster.config.set.config', {
+    spy.mockRestore();
+
+    huePubSub.publish(CONFIG_REFRESHED_EVENT, {
       app_config: {
         editor: {
           interpreters: [{ type: 'pig' }]
@@ -46,7 +54,7 @@ describe('ko.assistFunctionsPanel.js', () => {
     expect(subject.availableTypes()).toEqual(['pig']);
     expect(subject.activeType()).toEqual('pig');
 
-    huePubSub.publish('cluster.config.set.config', {
+    huePubSub.publish(CONFIG_REFRESHED_EVENT, {
       app_config: {
         editor: {
           interpreters: [{ type: 'banana' }]
@@ -57,7 +65,6 @@ describe('ko.assistFunctionsPanel.js', () => {
     expect(subject.availableTypes()).toEqual([]);
     expect(subject.activeType()).toBeFalsy();
 
-    configSub.remove();
     subject.dispose();
   });
 });

+ 7 - 9
desktop/core/src/desktop/js/ko/components/assist/ko.assistLangRefPanel.js

@@ -21,6 +21,7 @@ import apiHelper from 'api/apiHelper';
 import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
+import { GET_KNOWN_CONFIG_EVENT, CONFIG_REFRESHED_EVENT } from 'utils/hueConfig';
 
 // prettier-ignore
 const TEMPLATE = `
@@ -149,15 +150,11 @@ class AssistLangRefPanel {
       updateType(details.type);
     });
 
-    const configSub = huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
+    const configUpdated = config => {
       const lastActiveType = this.sourceType();
-      if (
-        clusterConfig.app_config &&
-        clusterConfig.app_config.editor &&
-        clusterConfig.app_config.editor.interpreters
-      ) {
+      if (config.app_config && config.app_config.editor && config.app_config.editor.interpreters) {
         const typesIndex = {};
-        clusterConfig.app_config.editor.interpreters.forEach(interpreter => {
+        config.app_config.editor.interpreters.forEach(interpreter => {
           if (interpreter.type === 'hive' || interpreter.type === 'impala') {
             typesIndex[interpreter.type] = true;
           }
@@ -172,9 +169,10 @@ class AssistLangRefPanel {
       } else {
         this.availableTypes([]);
       }
-    });
+    };
 
-    huePubSub.publish('cluster.config.get.config');
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, configUpdated);
+    const configSub = huePubSub.subscribe(CONFIG_REFRESHED_EVENT, configUpdated);
 
     this.disposals.push(() => {
       configSub.remove();

+ 16 - 13
desktop/core/src/desktop/js/ko/components/assist/ko.assistLangRefPanel.test.js

@@ -16,6 +16,7 @@
 
 import huePubSub from 'utils/huePubSub';
 import AssistLangRefPanel from './ko.assistLangRefPanel';
+import { CONFIG_REFRESHED_EVENT, GET_KNOWN_CONFIG_EVENT } from 'utils/hueConfig';
 
 describe('ko.assistLangRefPanel.js', () => {
   beforeAll(() => {
@@ -24,23 +25,26 @@ describe('ko.assistLangRefPanel.js', () => {
   });
 
   it('should handle cluster config updates', () => {
-    let clusterConfigGetCalled = false;
-    const configSub = huePubSub.subscribe('cluster.config.get.config', () => {
-      clusterConfigGetCalled = true;
-      huePubSub.publish('cluster.config.set.config', {
-        app_config: {
-          editor: {
-            interpreters: [{ type: 'hive' }, { type: 'impala' }, { type: 'banana' }]
+    const spy = jest.spyOn(huePubSub, 'publish').mockImplementation((topic, cb) => {
+      if (topic === GET_KNOWN_CONFIG_EVENT && cb) {
+        cb({
+          app_config: {
+            editor: {
+              interpreters: [{ type: 'hive' }, { type: 'impala' }, { type: 'banana' }]
+            }
           }
-        }
-      });
+        });
+      }
     });
+
     const subject = new AssistLangRefPanel();
 
-    expect(clusterConfigGetCalled).toBeTruthy();
+    expect(spy).toHaveBeenCalled();
     expect(subject.availableTypes()).toEqual(['hive', 'impala']);
 
-    huePubSub.publish('cluster.config.set.config', {
+    spy.mockRestore();
+
+    huePubSub.publish(CONFIG_REFRESHED_EVENT, {
       app_config: {
         editor: {
           interpreters: [{ type: 'impala' }]
@@ -51,7 +55,7 @@ describe('ko.assistLangRefPanel.js', () => {
     expect(subject.availableTypes()).toEqual(['impala']);
     expect(subject.sourceType()).toEqual('impala');
 
-    huePubSub.publish('cluster.config.set.config', {
+    huePubSub.publish(CONFIG_REFRESHED_EVENT, {
       app_config: {
         editor: {
           interpreters: [{ type: 'banana' }]
@@ -62,7 +66,6 @@ describe('ko.assistLangRefPanel.js', () => {
     expect(subject.availableTypes()).toEqual([]);
     expect(subject.sourceType()).toBeFalsy();
 
-    configSub.remove();
     subject.dispose();
   });
 });

+ 3 - 8
desktop/core/src/desktop/js/ko/components/assist/ko.assistPanel.js

@@ -22,6 +22,7 @@ import AssistInnerPanel from 'ko/components/assist/assistInnerPanel';
 import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
+import { GET_KNOWN_CONFIG_EVENT, CONFIG_REFRESHED_EVENT } from 'utils/hueConfig';
 
 const TEMPLATE = `
   <script type="text/html" id="assist-panel-inner-header">
@@ -91,7 +92,8 @@ class AssistPanel {
     self.lastOpenPanelType = ko.observable();
     apiHelper.withTotalStorage('assist', 'last.open.panel', self.lastOpenPanelType);
 
-    huePubSub.subscribeOnce('cluster.config.set.config', clusterConfig => {
+    // TODO: Support dynamic config changes
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, clusterConfig => {
       if (clusterConfig && clusterConfig['app_config']) {
         const panels = [];
         const appConfig = clusterConfig['app_config'];
@@ -290,13 +292,6 @@ class AssistPanel {
         lastFoundPanel.length === 1 ? lastFoundPanel[0] : self.availablePanels()[0]
       );
     });
-
-    window.setTimeout(() => {
-      // Main initialization trigger in hue.mako, this is for Hue 3
-      if (self.availablePanels().length === 0) {
-        huePubSub.publish('cluster.config.get.config');
-      }
-    }, 0);
   }
 }
 

+ 2 - 1
desktop/core/src/desktop/js/ko/components/contextPopover/ko.contextPopover.js

@@ -32,6 +32,7 @@ import PartitionContext from './partitionContext';
 import ResizeHelper from './resizeHelper';
 import StorageContext from './storageContext';
 import componentUtils from '../componentUtils';
+import { GET_KNOWN_CONFIG_EVENT } from 'utils/hueConfig';
 
 const SUPPORT_TEMPLATES = `
   <script type="text/html" id="context-popover-footer">
@@ -976,7 +977,7 @@ class SqlContextContentsGlobalSearch {
     let sourceType = params.data.sourceType && params.data.sourceType.toLowerCase();
 
     if (!sourceType || sourceType === 'hive') {
-      huePubSub.publish('cluster.config.get.config', clusterConfig => {
+      huePubSub.publish(GET_KNOWN_CONFIG_EVENT, clusterConfig => {
         if (clusterConfig) {
           const defaultEditor = clusterConfig['default_sql_interpreter'];
           if (!sourceType || (sourceType === 'hive' && defaultEditor === 'impala')) {

+ 6 - 2
desktop/core/src/desktop/js/ko/components/ko.sidebar.js

@@ -21,6 +21,7 @@ import apiHelper from 'api/apiHelper';
 import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
+import { GET_KNOWN_CONFIG_EVENT, CONFIG_REFRESHED_EVENT } from 'utils/hueConfig';
 
 export const NAME = 'hue-sidebar';
 
@@ -239,7 +240,7 @@ class Sidebar {
       });
     };
 
-    huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
+    const configUpdated = clusterConfig => {
       const items = [];
       if (clusterConfig && clusterConfig['app_config']) {
         const appsItems = [];
@@ -369,7 +370,10 @@ class Sidebar {
 
       this.items(items);
       updateActive();
-    });
+    };
+
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, configUpdated);
+    huePubSub.subscribe(CONFIG_REFRESHED_EVENT, configUpdated);
 
     let throttle = -1;
     huePubSub.subscribe('set.current.app.name', appName => {

+ 6 - 2
desktop/core/src/desktop/js/onePageViewModel.js

@@ -22,6 +22,7 @@ import page from 'page';
 import hueUtils from 'utils/hueUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
+import { CONFIG_REFRESHED_EVENT, GET_KNOWN_CONFIG_EVENT } from 'utils/hueConfig';
 
 class OnePageViewModel {
   constructor() {
@@ -810,7 +811,7 @@ class OnePageViewModel {
       );
     });
 
-    huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
+    const configUpdated = clusterConfig => {
       page('/', () => {
         page(clusterConfig['main_button_action'].page);
       });
@@ -819,7 +820,10 @@ class OnePageViewModel {
         self.loadApp('404');
       });
       page();
-    });
+    };
+
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, configUpdated);
+    huePubSub.subscribe(CONFIG_REFRESHED_EVENT, configUpdated);
 
     huePubSub.subscribe('open.link', href => {
       if (href) {

+ 6 - 2
desktop/core/src/desktop/js/sideBarViewModel.js

@@ -18,6 +18,7 @@ import * as ko from 'knockout';
 
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
+import { CONFIG_REFRESHED_EVENT, GET_KNOWN_CONFIG_EVENT } from 'utils/hueConfig';
 
 class SideBarViewModel {
   constructor(onePageViewModel, topNavViewModel) {
@@ -27,7 +28,7 @@ class SideBarViewModel {
 
     self.pocClusterMode = topNavViewModel.pocClusterMode;
 
-    huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
+    const configUpdated = clusterConfig => {
       const items = [];
 
       if (clusterConfig && clusterConfig['app_config']) {
@@ -131,7 +132,10 @@ class SideBarViewModel {
       }
 
       self.items(items);
-    });
+    };
+
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, configUpdated);
+    huePubSub.subscribe(CONFIG_REFRESHED_EVENT, configUpdated);
 
     self.leftNavVisible = topNavViewModel.leftNavVisible;
     self.onePageViewModel = onePageViewModel;

+ 23 - 15
desktop/core/src/desktop/js/topNavViewModel.js

@@ -21,6 +21,11 @@ import apiHelper from 'api/apiHelper';
 import hueAnalytics from 'utils/hueAnalytics';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
+import {
+  CONFIG_REFRESHED_EVENT,
+  GET_KNOWN_CONFIG_EVENT,
+  REFRESH_CONFIG_EVENT
+} from 'utils/hueConfig';
 
 class TopNavViewModel {
   constructor(onePageViewModel) {
@@ -59,9 +64,9 @@ class TopNavViewModel {
     self.hasJobBrowser = ko.observable(window.HAS_JOB_BROWSER);
     self.clusters = ko.observableArray();
 
-    huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
-      if (clusterConfig && clusterConfig['main_button_action']) {
-        const topApp = clusterConfig['main_button_action'];
+    const configUpdated = config => {
+      if (config && config['main_button_action']) {
+        const topApp = config['main_button_action'];
         self.mainQuickCreateAction({
           displayName: topApp.buttonName,
           icon: topApp.type,
@@ -72,9 +77,9 @@ class TopNavViewModel {
         self.mainQuickCreateAction(undefined);
       }
 
-      if (clusterConfig && clusterConfig['button_actions']) {
+      if (config && config['button_actions']) {
         const apps = [];
-        const buttonActions = clusterConfig['button_actions'];
+        const buttonActions = config['button_actions'];
         buttonActions.forEach(app => {
           const interpreters = [];
           let toAddDivider = false;
@@ -122,23 +127,26 @@ class TopNavViewModel {
         self.quickCreateActions([]);
       }
 
-      if (clusterConfig && clusterConfig['clusters']) {
-        self.clusters(clusterConfig['clusters']);
+      if (config && config['clusters']) {
+        self.clusters(config['clusters']);
       }
 
       self.hasJobBrowser(
         window.HAS_JOB_BROWSER &&
-          clusterConfig &&
-          clusterConfig['app_config'] &&
-          clusterConfig['app_config']['browser'] &&
-          (clusterConfig['app_config']['browser']['interpreter_names'].indexOf('yarn') != -1 ||
-            clusterConfig['app_config']['editor']['interpreter_names'].indexOf('impala') != -1 ||
-            clusterConfig['app_config']['browser']['interpreter_names'].indexOf('dataeng') != -1)
+          config &&
+          config['app_config'] &&
+          config['app_config']['browser'] &&
+          (config['app_config']['browser']['interpreter_names'].indexOf('yarn') !== -1 ||
+            config['app_config']['editor']['interpreter_names'].indexOf('impala') !== -1 ||
+            config['app_config']['browser']['interpreter_names'].indexOf('dataeng') !== -1)
       );
-    });
+    };
+
+    huePubSub.publish(GET_KNOWN_CONFIG_EVENT, configUpdated);
+    huePubSub.subscribe(CONFIG_REFRESHED_EVENT, configUpdated);
 
     huePubSub.subscribe('hue.new.default.app', () => {
-      huePubSub.publish('cluster.config.refresh.config');
+      huePubSub.publish(REFRESH_CONFIG_EVENT);
     });
   }
 }

+ 57 - 0
desktop/core/src/desktop/js/utils/hueConfig.js

@@ -0,0 +1,57 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+import $ from 'jquery';
+
+import apiHelper from 'api/apiHelper';
+import huePubSub from 'utils/huePubSub';
+
+export const REFRESH_CONFIG_EVENT = 'cluster.config.refresh.config';
+export const CONFIG_REFRESHED_EVENT = 'cluster.config.set.config';
+export const GET_KNOWN_CONFIG_EVENT = 'cluster.config.get.config';
+
+let lastConfigPromise = undefined;
+
+const refreshConfig = () => {
+  lastConfigPromise = new Promise((resolve, reject) => {
+    apiHelper
+      .getClusterConfig()
+      .done(data => {
+        if (data.status === 0) {
+          resolve(data);
+        } else {
+          $(document).trigger('error', data.message);
+          reject();
+        }
+      })
+      .fail(reject);
+  });
+
+  lastConfigPromise
+    .then(config => {
+      huePubSub.publish(CONFIG_REFRESHED_EVENT, config);
+    })
+    .catch(() => {
+      huePubSub.publish(CONFIG_REFRESHED_EVENT);
+    });
+};
+
+huePubSub.subscribe(REFRESH_CONFIG_EVENT, refreshConfig);
+
+huePubSub.subscribe(GET_KNOWN_CONFIG_EVENT, callback => {
+  if (lastConfigPromise && callback) {
+    lastConfigPromise.then(callback).catch(callback);
+  }
+});

+ 0 - 62
desktop/core/src/desktop/static/desktop/js/clusterConfig.js

@@ -1,62 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-function ClusterConfig(params) {
-  var self = this;
-
-  self.clusterConfig = undefined;
-  self.loading = true;
-
-  var refreshConfig = function () {
-    window.apiHelper.getClusterConfig(params).done(function (data) {
-      if (data.status === 0) {
-        self.loading = false;
-        self.clusterConfig = data;
-        huePubSub.publish('cluster.config.set.config', self.clusterConfig);
-      } else {
-        $(document).trigger("error", data.message);
-        huePubSub.publish('cluster.config.set.config');
-      }
-    }).fail(function () {
-      huePubSub.publish('clustser.config.set.config');
-    }).always(function () {
-      self.loading = false;
-    });
-  };
-
-  huePubSub.subscribe('cluster.config.refresh.config', refreshConfig);
-
-  if (window.location.pathname.indexOf('/accounts/login') === -1) {
-    refreshConfig();
-  }
-
-  huePubSub.subscribe('cluster.config.get.config', function (callback) {
-    if (!self.loading) {
-      if (callback) {
-        callback(self.clusterConfig)
-      } else {
-        huePubSub.publish('cluster.config.set.config', self.clusterConfig);
-      }
-    } else if (callback) {
-      huePubSub.subscribeOnce('cluster.config.set.config', function () {
-        callback(self.clusterConfig)
-      })
-    }
-  });
-}
-
-new ClusterConfig();

+ 0 - 1
desktop/core/src/desktop/templates/common_header.mako

@@ -186,7 +186,6 @@ if USE_NEW_EDITOR.get():
 
 % if user.is_authenticated():
   <script src="${ static('desktop/ext/js/localforage.min.js') }"></script>
-  <script src="${ static('desktop/js/clusterConfig.js') }"></script>
 
   <script type="text/javascript">
     $(document).ready(function () {

+ 0 - 3
desktop/core/src/desktop/templates/hue.mako

@@ -367,9 +367,6 @@ ${ hueAceAutocompleter.hueAceAutocompleter() }
 
 ${ commonHeaderFooterComponents.header_pollers(user, is_s3_enabled, apps) }
 
-## clusterConfig makes an Ajax call so it needs to be after commonHeaderFooterComponents
-<script src="${ static('desktop/js/clusterConfig.js') }"></script>
-
 % if request is not None:
 ${ smart_unicode(login_modal(request).content) | n,unicode }
 % endif