Skip to content

Commit

Permalink
Requiring an index pattern for a route is opt-in
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <[email protected]>
  • Loading branch information
Tyler Smalley committed Jun 21, 2016
1 parent 70b75f1 commit a5220c0
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const app = uiModules.get('app/dashboard', [
uiRoutes
.when('/dashboard', {
template: indexTemplate,
requireDefaultIndex: true,
resolve: {
dash: function (savedDashboards, config) {
return savedDashboards.get();
Expand Down
1 change: 1 addition & 0 deletions src/plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ uiRoutes
.when('/discover/:id?', {
template: indexTemplate,
reloadOnSearch: false,
requireDefaultIndex: true,
resolve: {
ip: function (Promise, courier, config, $location) {
return courier.indexPatterns.getIds()
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/kibana/public/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import management from 'ui/management';

uiRoutes
.when('/management', {
template: landingTemplate,
requireDefaultIndex: false
template: landingTemplate
});

require('ui/index_patterns/route_setup/load_default')({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ const indexPatternsResolutions = {
uiRoutes
.defaults(/management\/kibana\/indices/, {
resolve: indexPatternsResolutions,
requireDefaultIndex: false
requireDefaultIndex: true
});

uiRoutes
.defaults(/management\/data\/index/, {
resolve: indexPatternsResolutions,
requireDefaultIndex: false
resolve: indexPatternsResolutions
});

// wrapper directive, which sets some global stuff up like the left nav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import template from 'plugins/kibana/management/sections/indices/upload/index.ht
import './directives/upload_wizard';

routes.when('/management/data/csv/', {
template: template,
requireDefaultIndex: false
template: template
});

management.getSection('data').register('csv', {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import editorTemplate from 'plugins/kibana/visualize/editor/editor.html';
uiRoutes
.when('/visualize/create', {
template: editorTemplate,
requireDefaultIndex: true,
resolve: {
savedVis: function (savedVisualizations, courier, $route, Private) {
const visTypes = Private(RegistryVisTypesProvider);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/kibana/public/visualize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import uiRoutes from 'ui/routes';

uiRoutes
.when('/visualize', {
redirectTo: '/visualize/step/1'
redirectTo: '/visualize/step/1',
requireDefaultIndex: true
});

// preloading
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/kibana/public/visualize/wizard/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const module = uiModules.get('app/visualize', ['kibana/courier']);
/** Wizard Step 1
/********/
routes.when('/visualize/step/1', {
template: templateStep(1, require('plugins/kibana/visualize/wizard/step_1.html'))
template: templateStep(1, require('plugins/kibana/visualize/wizard/step_1.html')),
requireDefaultIndex: true
});

module.controller('VisualizeWizardStep1', function ($scope, $route, $location, timefilter, Private) {
Expand All @@ -36,6 +37,7 @@ module.controller('VisualizeWizardStep1', function ($scope, $route, $location, t
/********/
routes.when('/visualize/step/2', {
template: templateStep(2, require('plugins/kibana/visualize/wizard/step_2.html')),
requireDefaultIndex: true,
resolve: {
indexPatternIds: function (courier) {
return courier.indexPatterns.getIds();
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/routes/__tests__/_route_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ describe('routes/route_manager', function () {
expect($rp.when.lastCall.args[1]).to.have.property('reloadOnSearch', true);
});

it('sets route.requireDefaultIndex to true by default', function () {
it('sets route.requireDefaultIndex to false by default', function () {
routes.when('/nothing-set');
routes.when('/no-index-required', { requireDefaultIndex: false });
routes.when('/index-required', { requireDefaultIndex: true });
routes.config($rp);

expect($rp.when.callCount).to.be(3);
expect($rp.when.firstCall.args[1]).to.have.property('requireDefaultIndex', true);
expect($rp.when.firstCall.args[1]).to.have.property('requireDefaultIndex', false);
expect($rp.when.secondCall.args[1]).to.have.property('requireDefaultIndex', false);
expect($rp.when.lastCall.args[1]).to.have.property('requireDefaultIndex', true);
});
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/routes/route_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function RouteManager() {
}

if (route.requireDefaultIndex === void 0) {
route.requireDefaultIndex = true;
route.requireDefaultIndex = false;
}

wrapRouteWithPrep(route, setup);
Expand Down

0 comments on commit a5220c0

Please sign in to comment.