Skip to content

Commit

Permalink
Merge pull request #2 from spalger/pr/7454
Browse files Browse the repository at this point in the history
[ui/settings] go red when settings are not found, otherwise mimic es …
  • Loading branch information
ycombinator authored Jun 15, 2016
2 parents 273c349 + ced2a21 commit 5fe4a6b
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 5fe4a6b

Please sign in to comment.