Merge pull request #7516 from tylersmalley/7481-require-index-pattern
Adds route option for requireDefaultIndex
This commit is contained in:
commit
b4c3991588
16 changed files with 68 additions and 20 deletions
|
@ -18,11 +18,8 @@ import uiRoutes from 'ui/routes';
|
|||
import uiModules from 'ui/modules';
|
||||
import indexTemplate from 'plugins/kibana/dashboard/index.html';
|
||||
|
||||
|
||||
|
||||
require('ui/saved_objects/saved_object_registry').register(require('plugins/kibana/dashboard/services/saved_dashboard_register'));
|
||||
|
||||
|
||||
const app = uiModules.get('app/dashboard', [
|
||||
'elasticsearch',
|
||||
'ngRoute',
|
||||
|
@ -33,6 +30,9 @@ const app = uiModules.get('app/dashboard', [
|
|||
]);
|
||||
|
||||
uiRoutes
|
||||
.defaults(/dashboard/, {
|
||||
requireDefaultIndex: true
|
||||
})
|
||||
.when('/dashboard', {
|
||||
template: indexTemplate,
|
||||
resolve: {
|
||||
|
|
|
@ -36,6 +36,9 @@ const app = uiModules.get('apps/discover', [
|
|||
]);
|
||||
|
||||
uiRoutes
|
||||
.defaults(/discover/, {
|
||||
requireDefaultIndex: true
|
||||
})
|
||||
.when('/discover/:id?', {
|
||||
template: indexTemplate,
|
||||
reloadOnSearch: false,
|
||||
|
|
|
@ -20,7 +20,6 @@ uiRoutes
|
|||
});
|
||||
|
||||
require('ui/index_patterns/route_setup/load_default')({
|
||||
notRequiredRe: /^\/management\/data\//,
|
||||
whenMissingRedirectTo: '/management/data/index'
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ const indexPatternsResolutions = {
|
|||
// add a dependency to all of the subsection routes
|
||||
uiRoutes
|
||||
.defaults(/management\/kibana\/indices/, {
|
||||
resolve: indexPatternsResolutions
|
||||
resolve: indexPatternsResolutions,
|
||||
requireDefaultIndex: true
|
||||
});
|
||||
|
||||
uiRoutes
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
<th>Actions <kbn-info info="Edit or restore the default value."></kbn-info></th>
|
||||
<th class="col-xs-4 col-sm-4">Name</th>
|
||||
<th class="col-xs-4 col-sm-5">Value</th>
|
||||
<th class="col-xs-3 col-sm-2">Actions <kbn-info info="Edit or restore the default value."></kbn-info></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
@ -144,8 +144,12 @@ kbn-management-objects {
|
|||
kbn-management-advanced {
|
||||
// super specific rule to override bootstrap's equally specific rule
|
||||
// https://github.com/twbs/bootstrap/blob/1f329f8f17aa989eabc6e94bdcab93e69ef0e463/less/tables.less#L35
|
||||
.table > tbody > tr > td {
|
||||
vertical-align: middle;
|
||||
.table {
|
||||
table-layout: fixed;
|
||||
|
||||
tbody > tr > td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ import uiRoutes from 'ui/routes';
|
|||
|
||||
|
||||
uiRoutes
|
||||
.defaults(/visualize/, {
|
||||
requireDefaultIndex: true
|
||||
})
|
||||
.when('/visualize', {
|
||||
redirectTo: '/visualize/step/1'
|
||||
});
|
||||
|
@ -28,4 +31,3 @@ uiRoutes
|
|||
|
||||
require('ui/saved_objects/saved_object_registry')
|
||||
.register(require('plugins/kibana/visualize/saved_visualizations/saved_visualization_register'));
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ let notify = new Notifier({
|
|||
|
||||
module.exports = function (opts) {
|
||||
opts = opts || {};
|
||||
let notRequiredRe = opts.notRequiredRe || null;
|
||||
let whenMissingRedirectTo = opts.whenMissingRedirectTo || null;
|
||||
let defaultRequiredToasts = null;
|
||||
|
||||
|
@ -18,21 +17,20 @@ module.exports = function (opts) {
|
|||
.addSetupWork(function loadDefaultIndexPattern(Private, Promise, $route, config, indexPatterns) {
|
||||
let getIds = Private(GetIdsProvider);
|
||||
let rootSearchSource = Private(CourierDataSourceRootSearchSourceProvider);
|
||||
let path = _.get($route, 'current.$$route.originalPath');
|
||||
let route = _.get($route, 'current.$$route');
|
||||
|
||||
return getIds()
|
||||
.then(function (patterns) {
|
||||
let defaultId = config.get('defaultIndex');
|
||||
let defined = !!defaultId;
|
||||
let exists = _.contains(patterns, defaultId);
|
||||
let required = !notRequiredRe || !path.match(notRequiredRe);
|
||||
|
||||
if (defined && !exists) {
|
||||
config.remove('defaultIndex');
|
||||
defaultId = defined = false;
|
||||
}
|
||||
|
||||
if (!defined && required) {
|
||||
if (!defined && route.requireDefaultIndex) {
|
||||
throw new NoDefaultIndexPattern();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,5 +100,17 @@ describe('routes/route_manager', function () {
|
|||
expect($rp.when.secondCall.args[1]).to.have.property('reloadOnSearch', false);
|
||||
expect($rp.when.lastCall.args[1]).to.have.property('reloadOnSearch', true);
|
||||
});
|
||||
|
||||
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', false);
|
||||
expect($rp.when.secondCall.args[1]).to.have.property('requireDefaultIndex', false);
|
||||
expect($rp.when.lastCall.args[1]).to.have.property('requireDefaultIndex', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,6 +26,10 @@ function RouteManager() {
|
|||
route.reloadOnSearch = false;
|
||||
}
|
||||
|
||||
if (route.requireDefaultIndex === void 0) {
|
||||
route.requireDefaultIndex = false;
|
||||
}
|
||||
|
||||
wrapRouteWithPrep(route, setup);
|
||||
$routeProvider.when(path, route);
|
||||
});
|
||||
|
|
|
@ -14,6 +14,9 @@ bdd.describe('user input reactions', function () {
|
|||
return esClient.deleteAndUpdateConfigDoc()
|
||||
.then(function () {
|
||||
return settingsPage.navigateTo();
|
||||
})
|
||||
.then(function () {
|
||||
return settingsPage.clickExistingData();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@ bdd.describe('creating and deleting default index', function describeIndexTests(
|
|||
return esClient.deleteAndUpdateConfigDoc()
|
||||
.then(function () {
|
||||
return settingsPage.navigateTo();
|
||||
})
|
||||
.then(function () {
|
||||
return settingsPage.clickExistingData();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -34,7 +34,10 @@ bdd.describe('index result field sort', function describeIndexTests() {
|
|||
columns.forEach(function (col) {
|
||||
bdd.describe('sort by heading - ' + col.heading, function indexPatternCreation() {
|
||||
bdd.before(function () {
|
||||
return settingsPage.navigateTo();
|
||||
return settingsPage.navigateTo()
|
||||
.then(function () {
|
||||
return settingsPage.clickExistingData();
|
||||
});
|
||||
});
|
||||
|
||||
bdd.beforeEach(function () {
|
||||
|
|
|
@ -14,6 +14,9 @@ bdd.describe('initial state', function () {
|
|||
return esClient.deleteAndUpdateConfigDoc()
|
||||
.then(function () {
|
||||
return settingsPage.navigateTo();
|
||||
})
|
||||
.then(function () {
|
||||
return settingsPage.clickExistingData();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -12,6 +12,12 @@ bdd.describe('creating and deleting default index', function describeIndexTests(
|
|||
bdd.before(function () {
|
||||
// delete .kibana index and then wait for Kibana to re-create it
|
||||
return esClient.deleteAndUpdateConfigDoc()
|
||||
.then(function () {
|
||||
return settingsPage.navigateTo();
|
||||
})
|
||||
.then(function () {
|
||||
return settingsPage.clickExistingData();
|
||||
})
|
||||
.then(function () {
|
||||
return settingsPage.createIndexPattern();
|
||||
})
|
||||
|
|
|
@ -14,16 +14,20 @@ export default (function () {
|
|||
return this.remote.findDisplayedByCssSelector('.app-link:nth-child(5) a').click();
|
||||
},
|
||||
|
||||
clickPath: function (path) {
|
||||
return this.remote.findDisplayedByCssSelector('[kbn-href="#/management/' + path + '"]').click();
|
||||
clickLinkText: function (text) {
|
||||
return this.remote.findDisplayedByLinkText(text).click();
|
||||
},
|
||||
|
||||
clickKibanaSettings: function () {
|
||||
return this.clickPath('kibana/settings');
|
||||
return this.clickLinkText('Advanced Settings');
|
||||
},
|
||||
|
||||
clickKibanaIndicies: function () {
|
||||
return this.clickPath('kibana/indices');
|
||||
return this.clickLinkText('Index Patterns');
|
||||
},
|
||||
|
||||
clickExistingData: function () {
|
||||
return this.clickLinkText('Existing Data');
|
||||
},
|
||||
|
||||
getAdvancedSettings: function getAdvancedSettings(propertyName) {
|
||||
|
@ -315,6 +319,9 @@ export default (function () {
|
|||
|
||||
return common.try(function () {
|
||||
return self.navigateTo()
|
||||
.then(function () {
|
||||
return self.clickExistingData();
|
||||
})
|
||||
.then(function () {
|
||||
return self.selectTimeFieldOption('@timestamp');
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue