Skip to content

Commit

Permalink
[ui/settings] go red when settings are not found, otherwise mimic es …
Browse files Browse the repository at this point in the history
…status
  • Loading branch information
spalger committed Jun 15, 2016
1 parent 273c349 commit ced2a21
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/ui/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defaultsDeep, partial } from 'lodash';
import defaultsProvider from './defaults';

export default function setupSettings(kbnServer, server, config) {
const status = kbnServer.status.create('ui settings');
const uiSettings = {
getAll,
getDefaults,
Expand All @@ -12,6 +13,7 @@ export default function setupSettings(kbnServer, server, config) {
};

server.decorate('server', 'uiSettings', () => uiSettings);
kbnServer.ready().then(mirrorEsStatus);

function getAll() {
return Promise
Expand All @@ -24,7 +26,7 @@ export default function setupSettings(kbnServer, server, config) {
}

function userSettingsNotFound(kibanaVersion) {
server.plugins.elasticsearch.status.yellow(`Could not find user-provided settings for this version of Kibana (${kibanaVersion})`);
status.red(`Could not find user-provided settings for Kibana ${kibanaVersion}`);
return {};
}

Expand Down Expand Up @@ -56,6 +58,18 @@ export default function setupSettings(kbnServer, server, config) {
function remove(key) {
return set(key, null);
}

function mirrorEsStatus() {
const esStatus = kbnServer.status.getForPluginId('elasticsearch');

copyStatus();
esStatus.on('change', copyStatus);

function copyStatus() {
const { state } = esStatus;
status[state](state === 'green' ? 'Ready' : `Elasticsearch plugin is ${state}`);
}
}
}

function hydrateUserSettings(user) {
Expand Down

0 comments on commit ced2a21

Please sign in to comment.