From a2459bb61ab162f1f6dba3ff9d1327553ef62ecb Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 12:07:51 -0700 Subject: [PATCH 1/8] If Elasticsearch plugin is not yet green, log a warning --- src/ui/settings/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ui/settings/index.js b/src/ui/settings/index.js index bb6ced2edfe78..09c56c85dd313 100644 --- a/src/ui/settings/index.js +++ b/src/ui/settings/index.js @@ -24,8 +24,12 @@ export default function setupSettings(kbnServer, server, config) { } function userSettingsNotFound(kibanaVersion) { - const message = 'Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'; - server.plugins.kibana.status.red(message); + let message; + if (server.plugins.elasticsearch.status.state === 'green') { + server.plugins.kibana.status.red('Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'); + } else { + server.log(['warning', 'settings'], 'User-provided settings were requested before the Kibana index was ready'); + } return {}; } From ab66d5ea679409d3f9340566df4010cb45d3c108 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 12:09:39 -0700 Subject: [PATCH 2/8] Reload window if user has been sent to status page but status is green Of course, if the user has *explicitly* requested the status page, then don't reload the window and cause an infinite loop! --- src/plugins/status_page/public/status_page.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/status_page/public/status_page.js b/src/plugins/status_page/public/status_page.js index 2fc65f299b803..07fd6999c11cc 100644 --- a/src/plugins/status_page/public/status_page.js +++ b/src/plugins/status_page/public/status_page.js @@ -9,7 +9,7 @@ import uiModules from 'ui/modules'; const chrome = require('ui/chrome') .setRootTemplate(require('plugins/status_page/status_page.html')) -.setRootController('ui', function ($http, $scope) { +.setRootController('ui', function ($http, $window, $scope) { const ui = this; ui.loading = false; @@ -36,6 +36,14 @@ const chrome = require('ui/chrome') ui.serverState = overall.state; ui.serverStateMessage = overall.title; } + + // Unless the status page was explicitly requested, there is no + // reason to stay on the status page if the status is green; reload + // the window so the user is shown the page they were requesting. + const statusPageUrl = chrome.addBasePath('/status'); + if ((overall.state === 'green') && ($window.location.pathname !== statusPageUrl)) { + return $window.location.reload(); + } }) .catch(function () { if (ui.fetchError) return; From e860fc384c2e60a394c976a055712b8086b635d6 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 12:15:06 -0700 Subject: [PATCH 3/8] Adding comments --- src/ui/settings/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ui/settings/index.js b/src/ui/settings/index.js index 09c56c85dd313..53d14678834d4 100644 --- a/src/ui/settings/index.js +++ b/src/ui/settings/index.js @@ -26,8 +26,12 @@ export default function setupSettings(kbnServer, server, config) { function userSettingsNotFound(kibanaVersion) { let message; if (server.plugins.elasticsearch.status.state === 'green') { + // If Kibana index is ready but we still couldn't find user-provided settings in it, + // turn Kibana plugin to red server.plugins.kibana.status.red('Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'); } else { + // Otherwise, simply log a warning because a page refresh (once the Kibana index is ready) will + // solve the problem server.log(['warning', 'settings'], 'User-provided settings were requested before the Kibana index was ready'); } return {}; From 3ebf365e411232689fd2e2affc3e10127f74f99d Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 12:46:19 -0700 Subject: [PATCH 4/8] Removing extra parenthesis because operator precedence is a thing --- src/plugins/status_page/public/status_page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/status_page/public/status_page.js b/src/plugins/status_page/public/status_page.js index 07fd6999c11cc..c33cb72789482 100644 --- a/src/plugins/status_page/public/status_page.js +++ b/src/plugins/status_page/public/status_page.js @@ -41,7 +41,7 @@ const chrome = require('ui/chrome') // reason to stay on the status page if the status is green; reload // the window so the user is shown the page they were requesting. const statusPageUrl = chrome.addBasePath('/status'); - if ((overall.state === 'green') && ($window.location.pathname !== statusPageUrl)) { + if (overall.state === 'green' && $window.location.pathname !== statusPageUrl) { return $window.location.reload(); } }) From aa05237c9d77142a17c7ce6554b1aa12a3c2ecdb Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 12:49:48 -0700 Subject: [PATCH 5/8] Removing redundant comments --- src/plugins/status_page/public/status_page.js | 3 --- src/ui/settings/index.js | 4 ---- 2 files changed, 7 deletions(-) diff --git a/src/plugins/status_page/public/status_page.js b/src/plugins/status_page/public/status_page.js index c33cb72789482..9e9e852fc8408 100644 --- a/src/plugins/status_page/public/status_page.js +++ b/src/plugins/status_page/public/status_page.js @@ -37,9 +37,6 @@ const chrome = require('ui/chrome') ui.serverStateMessage = overall.title; } - // Unless the status page was explicitly requested, there is no - // reason to stay on the status page if the status is green; reload - // the window so the user is shown the page they were requesting. const statusPageUrl = chrome.addBasePath('/status'); if (overall.state === 'green' && $window.location.pathname !== statusPageUrl) { return $window.location.reload(); diff --git a/src/ui/settings/index.js b/src/ui/settings/index.js index 53d14678834d4..09c56c85dd313 100644 --- a/src/ui/settings/index.js +++ b/src/ui/settings/index.js @@ -26,12 +26,8 @@ export default function setupSettings(kbnServer, server, config) { function userSettingsNotFound(kibanaVersion) { let message; if (server.plugins.elasticsearch.status.state === 'green') { - // If Kibana index is ready but we still couldn't find user-provided settings in it, - // turn Kibana plugin to red server.plugins.kibana.status.red('Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'); } else { - // Otherwise, simply log a warning because a page refresh (once the Kibana index is ready) will - // solve the problem server.log(['warning', 'settings'], 'User-provided settings were requested before the Kibana index was ready'); } return {}; From db780bd645d4b120889facf42dc6b8a766a31460 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 13:26:23 -0700 Subject: [PATCH 6/8] Removing window reload code in favor of the right fix for what is a legacy issue --- src/plugins/status_page/public/status_page.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/plugins/status_page/public/status_page.js b/src/plugins/status_page/public/status_page.js index 9e9e852fc8408..2fc65f299b803 100644 --- a/src/plugins/status_page/public/status_page.js +++ b/src/plugins/status_page/public/status_page.js @@ -9,7 +9,7 @@ import uiModules from 'ui/modules'; const chrome = require('ui/chrome') .setRootTemplate(require('plugins/status_page/status_page.html')) -.setRootController('ui', function ($http, $window, $scope) { +.setRootController('ui', function ($http, $scope) { const ui = this; ui.loading = false; @@ -36,11 +36,6 @@ const chrome = require('ui/chrome') ui.serverState = overall.state; ui.serverStateMessage = overall.title; } - - const statusPageUrl = chrome.addBasePath('/status'); - if (overall.state === 'green' && $window.location.pathname !== statusPageUrl) { - return $window.location.reload(); - } }) .catch(function () { if (ui.fetchError) return; From 58f9843c6477e8ebeeff9ff2abcd597f14d825f9 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 13:37:56 -0700 Subject: [PATCH 7/8] Removing unused variable --- src/ui/settings/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/settings/index.js b/src/ui/settings/index.js index 09c56c85dd313..aaf768e40e40d 100644 --- a/src/ui/settings/index.js +++ b/src/ui/settings/index.js @@ -24,7 +24,6 @@ export default function setupSettings(kbnServer, server, config) { } function userSettingsNotFound(kibanaVersion) { - let message; if (server.plugins.elasticsearch.status.state === 'green') { server.plugins.kibana.status.red('Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'); } else { From 34258186bf290732964876d2ee4352fea134b8ce Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 10 Jun 2016 13:38:10 -0700 Subject: [PATCH 8/8] Using template string instead of concatenation --- src/ui/settings/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/settings/index.js b/src/ui/settings/index.js index aaf768e40e40d..a238d6a249cea 100644 --- a/src/ui/settings/index.js +++ b/src/ui/settings/index.js @@ -25,7 +25,7 @@ export default function setupSettings(kbnServer, server, config) { function userSettingsNotFound(kibanaVersion) { if (server.plugins.elasticsearch.status.state === 'green') { - server.plugins.kibana.status.red('Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'); + server.plugins.kibana.status.red(`Could not find user-provided settings for this version of Kibana (${kibanaVersion})`); } else { server.log(['warning', 'settings'], 'User-provided settings were requested before the Kibana index was ready'); }