Skip to content

Commit

Permalink
Handle indexes with no default set
Browse files Browse the repository at this point in the history
It's possible to add indexes to Kibana without specifying one as the default.

Previously we were re-using the edit index route, allowing for the id to be optional. If it was not specified, we used the defaultIndex. To handle redirecting to the create index route, we would need to throw an exception to prevent the route from rendering.

Instead, this creates a new route for the landing page, which redirects to the defaultIndex or the edit index page respectively.

Signed-off-by: Tyler Smalley <[email protected]>
  • Loading branch information
Tyler Smalley committed Jun 29, 2016
1 parent 1248b2f commit 5f5a7be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
25 changes: 18 additions & 7 deletions src/plugins/kibana/public/management/sections/indices/_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@ import editTemplate from 'plugins/kibana/management/sections/indices/_edit.html'
import IngestProvider from 'ui/ingest';

uiRoutes
.when('/management/kibana/indices/:indexPatternId?', {
.when('/management/kibana/indices/:indexPatternId', {
template: editTemplate,
resolve: {
indexPattern: function ($route, config, courier) {
const params = $route.current.params;
indexPattern: function ($route, courier) {
return courier.indexPatterns
.get($route.current.params.indexPatternId)
.catch(courier.redirectWhenMissing('/management/data/index'));
}
}
});

uiRoutes
.when('/management/kibana/indices', {
resolve: {
redirect: function ($location, config) {
const defaultIndex = config.get('defaultIndex');
let path = '/management/data/index';

if (typeof params.indexPatternId === 'undefined') {
params.indexPatternId = config.get('defaultIndex');
if (defaultIndex) {
path = `/management/kibana/indices/${defaultIndex}`;
}

return courier.indexPatterns.get(params.indexPatternId)
.catch(courier.redirectWhenMissing('/management/data/index'));
$location.path(path).replace();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const indexPatternsResolutions = {
// add a dependency to all of the subsection routes
uiRoutes
.defaults(/management\/kibana\/indices/, {
resolve: indexPatternsResolutions,
requireDefaultIndex: true
resolve: indexPatternsResolutions
});

uiRoutes
Expand Down

0 comments on commit 5f5a7be

Please sign in to comment.