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