Skip to content

Commit

Permalink
[5.x] Use single ES document type elastic#12794
Browse files Browse the repository at this point in the history
Partial backport containing 5.x specific changes
  • Loading branch information
tylersmalley authored Jul 19, 2017
1 parent 1f492f0 commit cf5a044
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ uiModules.get('apps/management')

$scope.kbnUrl = Private(UrlProvider);
$scope.indexPattern = $route.current.locals.indexPattern;
docTitle.change($scope.indexPattern.id);
docTitle.change($scope.indexPattern.title);

const otherPatterns = _.filter($route.current.locals.indexPatterns, pattern => {
return pattern.id !== $scope.indexPattern.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ uiRoutes
.when('/management/kibana/indices/:indexPatternId/create-field/', { mode: 'create' })
.defaults(/management\/kibana\/indices\/[^\/]+\/(field|create-field)(\/|$)/, {
template,
mapBreadcrumbs($route, breadcrumbs) {
const { indexPattern } = $route.current.locals;
return breadcrumbs.map(crumb => {
if (crumb.id !== indexPattern.id) {
return crumb;
}

return {
...crumb,
display: indexPattern.title
};
});
},
resolve: {
indexPattern: function ($route, courier) {
return courier.indexPatterns.get($route.current.params.indexPatternId)
Expand Down Expand Up @@ -46,7 +59,7 @@ uiRoutes
throw new Error('unknown fieldSettings mode ' + this.mode);
}

docTitle.change([this.field.name || 'New Scripted Field', this.indexPattern.id]);
docTitle.change([this.field.name || 'New Scripted Field', this.indexPattern.title]);
this.goBack = function () {
kbnUrl.changeToRoute(this.indexPattern, 'edit');
};
Expand Down
4 changes: 4 additions & 0 deletions src/functional_test_runner/lib/mocha/decorate_mocha_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,21 @@ export function decorateMochaUi(lifecycle, context) {
switch (property) {
case 'describe':
case 'describe.only':
case 'describe.skip':
case 'xdescribe':
case 'context':
case 'context.only':
case 'context.skip':
case 'xcontext':
return wrapSuiteFunction(property, value);

case 'it':
case 'it.only':
case 'it.skip':
case 'xit':
case 'specify':
case 'specify.only':
case 'specify.skip':
case 'xspecify':
return wrapTestFunction(property, value);

Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/controls/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="hintbox" ng-if="!indexedFields.length">
<p>
<i class="fa fa-danger text-danger"></i>
<strong>No Compatible Fields:</strong> The "{{ vis.indexPattern.id }}" index pattern does not contain any of the following field types: {{ agg.type.params.byName.field.filterFieldTypes | commaList:false }}
<strong>No Compatible Fields:</strong> The "{{ vis.indexPattern.title }}" index pattern does not contain any of the following field types: {{ agg.type.params.byName.field.filterFieldTypes | commaList:false }}
</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/courier/saved_object/saved_object_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class SavedObjectLoader {
* @param size
* @returns {Promise}
*/
find(search, size = 100) {
find(search = '', size = 100) {
return this.savedObjectsClient.find(
{
type: this.lowercaseType,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function IndexPatternsFieldProvider(Private, shortDotsFilter, $rootScope,
notify.error(
'Unknown field type "' + spec.type + '"' +
' for field "' + spec.name + '"' +
' in indexPattern "' + indexPattern.id + '"'
' in indexPattern "' + indexPattern.title + '"'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export function IndexPatternProvider(Private, $http, config, kbnIndex, Promise,
});
}

async save() {
save() {
return savedObjectsClient.update(type, this.id, this.prepBody())
.then(({ id }) => setId(this, id));
}
Expand Down
61 changes: 0 additions & 61 deletions src/ui/public/kbn_top_nav/__tests__/bread_crumb_urls.js

This file was deleted.

27 changes: 0 additions & 27 deletions src/ui/public/kbn_top_nav/bread_crumbs/bread_crumb_urls.js

This file was deleted.

10 changes: 5 additions & 5 deletions src/ui/public/kbn_top_nav/bread_crumbs/bread_crumbs.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<div class="kuiLocalBreadcrumbs" data-test-subj="breadcrumbs">
<div
class="kuiLocalBreadcrumb"
ng-if="useLinks && (!omitPages || !omitPages.includes(breadcrumb.path))"
ng-if="useLinks"
ng-repeat="breadcrumb in breadcrumbs"
>
<a
class="kuiLocalBreadcrumb__link"
href="{{breadcrumb.url}}"
href="{{ breadcrumb.href }}"
>
{{breadcrumb.title}}
{{ breadcrumb.display }}
</a>
</div>

<div
class="kuiLocalBreadcrumb"
ng-if="!useLinks && (!omitPages || !omitPages.includes(breadcrumb.path))"
ng-if="!useLinks"
ng-repeat="breadcrumb in breadcrumbs"
>
{{ breadcrumb.title }}
{{ breadcrumb.display }}
</div>

<div
Expand Down
38 changes: 23 additions & 15 deletions src/ui/public/kbn_top_nav/bread_crumbs/bread_crumbs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import _ from 'lodash';
import chrome from 'ui/chrome/chrome';
import breadCrumbsTemplate from './bread_crumbs.html';
import { getBreadCrumbUrls } from './bread_crumb_urls';
import { uiModules } from 'ui/modules';
import uiRouter from 'ui/routes';

const module = uiModules.get('kibana');

module.directive('breadCrumbs', function ($location) {
module.directive('breadCrumbs', function () {
return {
restrict: 'E',
replace: true,
Expand All @@ -30,20 +29,29 @@ module.directive('breadCrumbs', function ($location) {
},
template: breadCrumbsTemplate,
controller: function ($scope) {
const breadcrumbs = chrome.getBreadcrumbs();

if ($scope.useLinks) {
const url = '#' + $location.path();
$scope.breadcrumbs = getBreadCrumbUrls(breadcrumbs, url);
} else {
$scope.breadcrumbs = breadcrumbs.map(path => ({
path: path,
title: _.startCase(path)
}));
function omitPagesFilter(crumb) {
return (
!$scope.omitPages ||
!$scope.omitPages.includes(crumb.id)
);
}
if ($scope.omitCurrentPage === true) {
$scope.breadcrumbs.pop();

function omitCurrentPageFilter(crumb) {
return !($scope.omitCurrentPage && crumb.current);
}

$scope.$watchMulti([
'[]omitPages',
'omitCurrentPage'
], function getBreadcrumbs() {
$scope.breadcrumbs = (
uiRouter
.getBreadcrumbs()
.filter(omitPagesFilter)
.filter(omitCurrentPageFilter)
);
});
}
};
});
22 changes: 22 additions & 0 deletions src/ui/public/routes/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { trim, startCase } from 'lodash';

/**
* Take a path (from $location.path() usually) and parse
* it's segments into a list of breadcrumbs
*
* @param {string} path
* @return {Array<Breadcrumb>}
*/
export function parsePathToBreadcrumbs(path) {
return trim(path, '/')
.split('/')
.reduce((acc, id, i, parts) => [
...acc,
{
id,
display: startCase(id),
href: i === 0 ? `#/${id}` : `${acc[i - 1].href}/${id}`,
current: i === (parts.length - 1)
}
], []);
}
37 changes: 25 additions & 12 deletions src/ui/public/routes/route_manager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import _ from 'lodash';
import { defaultsDeep, wrap } from 'lodash';

import { wrapRouteWithPrep } from './wrap_route_with_prep';
import { RouteSetupManager } from './route_setup_manager';
import { parsePathToBreadcrumbs } from './breadcrumbs';

function RouteManager() {
const self = this;
Expand All @@ -15,18 +16,17 @@ function RouteManager() {
const path = args[0];
const route = args[1] || {};

// merge in any defaults
defaults.forEach(function (args) {
if (args[0].test(path)) {
_.merge(route, args[1]);
defaults.forEach(def => {
if (def.regex.test(path)) {
defaultsDeep(route, def.value);
}
});

if (route.reloadOnSearch === void 0) {
if (route.reloadOnSearch == null) {
route.reloadOnSearch = false;
}

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

Expand All @@ -40,14 +40,22 @@ function RouteManager() {
}
};

self.run = function ($location, $route, $injector) {
self.getBreadcrumbs = () => {
const breadcrumbs = parsePathToBreadcrumbs($location.path());
const map = $route.current.mapBreadcrumbs;
return map ? $injector.invoke(map, null, { breadcrumbs }) : breadcrumbs;
};
};

const wrapSetupAndChain = (fn, ...args) => {
fn.apply(setup, args);
return this;
};

this.addSetupWork = _.wrap(setup.addSetupWork, wrapSetupAndChain);
this.afterSetupWork = _.wrap(setup.afterSetupWork, wrapSetupAndChain);
this.afterWork = _.wrap(setup.afterWork, wrapSetupAndChain);
this.addSetupWork = wrap(setup.addSetupWork, wrapSetupAndChain);
this.afterSetupWork = wrap(setup.afterSetupWork, wrapSetupAndChain);
this.afterWork = wrap(setup.afterWork, wrapSetupAndChain);

self.when = function (path, route) {
when.push([path, route]);
Expand All @@ -56,8 +64,8 @@ function RouteManager() {

// before attaching the routes to the routeProvider, test the RE
// against the .when() path and add/override the resolves if there is a match
self.defaults = function (RE, def) {
defaults.push([RE, def]);
self.defaults = function (regex, value) {
defaults.push({ regex, value });
return self;
};

Expand All @@ -66,6 +74,11 @@ function RouteManager() {
return self;
};

self.getBreadcrumbs = function () {
// overwritten in self.run();
return [];
};

self.RouteManager = RouteManager;
}

Expand Down
Loading

0 comments on commit cf5a044

Please sign in to comment.