Skip to content

Commit

Permalink
Part 8
Browse files Browse the repository at this point in the history
  • Loading branch information
stacey-gammon committed Apr 12, 2017
1 parent 436fbb5 commit 5c24019
Show file tree
Hide file tree
Showing 48 changed files with 129 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import _ from 'lodash';
import $ from 'jquery';
import rison from 'rison-node';
import { fieldCalculator } from 'plugins/kibana/discover/components/field_chooser/lib/field_calculator';
import IndexPatternsFieldListProvider from 'ui/index_patterns/_field_list';
import { IndexPatternsFieldListProvider } from 'ui/index_patterns/_field_list';
import uiModules from 'ui/modules';
import fieldChooserTemplate from 'plugins/kibana/discover/components/field_chooser/field_chooser.html';
const app = uiModules.get('apps/discover');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DocTitleProvider } from 'ui/doc_title';
import UtilsBrushEventProvider from 'ui/utils/brush_event';
import PluginsKibanaDiscoverHitSortFnProvider from 'plugins/kibana/discover/_hit_sort_fn';
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
import FilterManagerProvider from 'ui/filter_manager';
import { FilterManagerProvider } from 'ui/filter_manager';
import { AggTypesBucketsIntervalOptionsProvider } from 'ui/agg_types/buckets/_interval_options';
import stateMonitorFactory from 'ui/state_management/state_monitor_factory';
import uiRoutes from 'ui/routes';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'ui/field_editor';
import 'plugins/kibana/management/sections/indices/_index_header';
import IndexPatternsFieldProvider from 'ui/index_patterns/_field';
import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field';
import UrlProvider from 'ui/url';
import uiRoutes from 'ui/routes';
import fieldEditorTemplate from 'plugins/kibana/management/sections/indices/_field_editor.html';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import angular from 'angular';
import rison from 'rison-node';
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
import objectViewHTML from 'plugins/kibana/management/sections/objects/_view.html';
import IndexPatternsCastMappingTypeProvider from 'ui/index_patterns/_cast_mapping_type';
import { IndexPatternsCastMappingTypeProvider } from 'ui/index_patterns/_cast_mapping_type';
import uiRoutes from 'ui/routes';
import uiModules from 'ui/modules';

Expand Down
3 changes: 2 additions & 1 deletion src/fixtures/stubbed_logstash_index_pattern.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import _ from 'lodash';
import TestUtilsStubIndexPatternProvider from 'test_utils/stub_index_pattern';
import IndexPatternsFieldTypesProvider from 'ui/index_patterns/_field_types';
import { IndexPatternsFieldTypesProvider } from 'ui/index_patterns/_field_types';
import FixturesLogstashFieldsProvider from 'fixtures/logstash_fields';

export default function stubbedLogstashIndexPatternService(Private) {
const StubIndexPattern = Private(TestUtilsStubIndexPatternProvider);
const fieldTypes = Private(IndexPatternsFieldTypesProvider);
Expand Down
12 changes: 6 additions & 6 deletions src/test_utils/stub_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import _ from 'lodash';
import sinon from 'sinon';
import Promise from 'bluebird';
import IndexedArray from 'ui/indexed_array';
import IndexPattern from 'ui/index_patterns/_index_pattern';
import formatHit from 'ui/index_patterns/_format_hit';
import getComputedFields from 'ui/index_patterns/_get_computed_fields';
import { IndexPatternProvider } from 'ui/index_patterns/_index_pattern';
import { formatHit } from 'ui/index_patterns/_format_hit';
import { getComputedFields } from 'ui/index_patterns/_get_computed_fields';
import RegistryFieldFormatsProvider from 'ui/registry/field_formats';
import IndexPatternsFlattenHitProvider from 'ui/index_patterns/_flatten_hit';
import IndexPatternsFieldProvider from 'ui/index_patterns/_field';
import { IndexPatternsFlattenHitProvider } from 'ui/index_patterns/_flatten_hit';
import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field';

export default function (Private) {
const fieldFormats = Private(RegistryFieldFormatsProvider);
Expand All @@ -24,7 +24,7 @@ export default function (Private) {
this.getSourceFiltering = sinon.spy();
this.metaFields = ['_id', '_type', '_source'];
this.fieldFormatMap = {};
this.routes = IndexPattern.routes;
this.routes = IndexPatternProvider.routes;

this.toIndexList = _.constant(Promise.resolve([pattern]));
this.toDetailedIndexList = _.constant(Promise.resolve([
Expand Down
4 changes: 2 additions & 2 deletions src/test_utils/stub_mapper.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import MapperService from 'ui/index_patterns/_mapper';
import { IndexPatternsMapperProvider } from 'ui/index_patterns/_mapper';
import stubbedLogstashFields from 'fixtures/logstash_fields';
import sinon from 'auto-release-sinon';

export function stubMapper(Private, mockLogstashFields = Private(stubbedLogstashFields)) {
const stubbedMapper = Private(MapperService);
const stubbedMapper = Private(IndexPatternsMapperProvider);

sinon.stub(stubbedMapper, 'getFieldsForIndexPattern', function () {
return Promise.resolve(mockLogstashFields.filter(field => field.scripted === false));
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/courier/__tests__/saved_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sinon from 'auto-release-sinon';
import BluebirdPromise from 'bluebird';

import SavedObjectFactory from '../saved_object/saved_object';
import IndexPatternFactory from 'ui/index_patterns/_index_pattern';
import { IndexPatternProvider } from 'ui/index_patterns/_index_pattern';
import DocSourceProvider from '../data_source/admin_doc_source';

import { stubMapper } from 'test_utils/stub_mapper';
Expand Down Expand Up @@ -98,7 +98,7 @@ describe('Saved Object', function () {

beforeEach(ngMock.inject(function (es, esAdmin, Private, $window) {
SavedObject = Private(SavedObjectFactory);
IndexPattern = Private(IndexPatternFactory);
IndexPattern = Private(IndexPatternProvider);
esAdminStub = esAdmin;
esDataStub = es;
DocSource = Private(DocSourceProvider);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/field_editor/__tests__/field_editor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $ from 'jquery';
import ngMock from 'ng_mock';
import expect from 'expect.js';
import IndexPatternsFieldProvider from 'ui/index_patterns/_field';
import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field';
import RegistryFieldFormatsProvider from 'ui/registry/field_formats';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import _ from 'lodash';
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/field_editor/field_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'angular-bootstrap-colorpicker';
import 'angular-bootstrap-colorpicker/css/colorpicker.css';
import _ from 'lodash';
import RegistryFieldFormatsProvider from 'ui/registry/field_formats';
import IndexPatternsFieldProvider from 'ui/index_patterns/_field';
import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field';
import uiModules from 'ui/modules';
import fieldEditorTemplate from 'ui/field_editor/field_editor.html';
import IndexPatternsCastMappingTypeProvider from 'ui/index_patterns/_cast_mapping_type';
import { IndexPatternsCastMappingTypeProvider } from 'ui/index_patterns/_cast_mapping_type';
import { scriptedFields as docLinks } from '../documentation_links/documentation_links';
import './field_editor.less';
import { GetEnabledScriptingLanguagesProvider, getSupportedScriptingLanguages } from '../scripting_languages';
Expand Down
3 changes: 3 additions & 0 deletions src/ui/public/filter_manager/filter_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ export function FilterManagerProvider(Private) {
return filterManager;
}

// Used in x-pack. TODO: switch references to named and remove.
export default FilterManagerProvider;

6 changes: 3 additions & 3 deletions src/ui/public/highlight/__tests__/highlight_html.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import expect from 'expect.js';
import highlightTags from '../highlight_tags';
import htmlTags from '../html_tags';
import getHighlightHtml from '../highlight_html';
import { highlightTags } from '../highlight_tags';
import { htmlTags } from '../html_tags';
import { getHighlightHtml } from '../highlight_html';

describe('getHighlightHtml', function () {
const text = '' +
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/highlight/__tests__/highlight_request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import getHighlightRequestProvider from '../highlight_request';
import { getHighlightRequestProvider } from '../highlight_request';

describe('getHighlightRequest', () => {
const queryStringQuery = { query_string: { query: 'foo' } };
Expand Down
9 changes: 2 additions & 7 deletions src/ui/public/highlight/highlight.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
import getHighlightHtml from './highlight_html';
import getHighlightRequestProvider from './highlight_request';

export default {
getHighlightHtml,
getHighlightRequestProvider
};
export { getHighlightHtml } from './highlight_html';
export { getHighlightRequestProvider } from './highlight_request';
6 changes: 3 additions & 3 deletions src/ui/public/highlight/highlight_html.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import _ from 'lodash';
import angular from 'angular';
import highlightTags from './highlight_tags';
import htmlTags from './html_tags';
import { highlightTags } from './highlight_tags';
import { htmlTags } from './html_tags';

export default function getHighlightHtml(fieldValue, highlights) {
export function getHighlightHtml(fieldValue, highlights) {
let highlightHtml = (typeof fieldValue === 'object')
? angular.toJson(fieldValue)
: fieldValue;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/highlight/highlight_request.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import highlightTags from './highlight_tags';
import { highlightTags } from './highlight_tags';

const FRAGMENT_SIZE = Math.pow(2, 31) - 1; // Max allowed value for fragment_size (limit of a java int)

Expand All @@ -26,7 +26,7 @@ function getHighlightQuery(query) {
return clone;
}

export default function getHighlightRequestProvider(config) {
export function getHighlightRequestProvider(config) {
return function getHighlightRequest(query) {
if (!config.get('doc_table:highlight')) return;

Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/highlight/highlight_tags.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// By default, ElasticSearch surrounds matched values in <em></em>. This is not ideal because it is possible that
// the value could contain <em></em> in the value. We define these custom tags that we would never expect to see
// inside a field value.
export default {
export const highlightTags = {
pre: '@kibana-highlighted-field@',
post: '@/kibana-highlighted-field@'
};
2 changes: 1 addition & 1 deletion src/ui/public/highlight/html_tags.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// These are the html tags that will replace the highlight tags.
export default {
export const htmlTags = {
pre: '<mark>',
post: '</mark>'
};
3 changes: 2 additions & 1 deletion src/ui/public/index_patterns/__tests__/_cast_mapping_type.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import _ from 'lodash';
import ngMock from 'ng_mock';
import expect from 'expect.js';
import IndexPatternsCastMappingTypeProvider from 'ui/index_patterns/_cast_mapping_type';
import { IndexPatternsCastMappingTypeProvider } from 'ui/index_patterns/_cast_mapping_type';

describe('type normalizer (castMappingType)', function () {
let fn;
beforeEach(ngMock.module('kibana'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import { getComputedFields } from 'ui/index_patterns/_get_computed_fields';

describe('get computed fields', function () {

let indexPattern;

let getComputedFields;

let fn;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
getComputedFields = require('ui/index_patterns/_get_computed_fields');
indexPattern.getComputedFields = getComputedFields.bind(indexPattern);
fn = indexPattern.getComputedFields;

}));

it('should be a function', function () {
Expand Down
9 changes: 5 additions & 4 deletions src/ui/public/index_patterns/__tests__/_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import FixturesLogstashFieldsProvider from 'fixtures/logstash_fields';
import FixturesStubbedDocSourceResponseProvider from 'fixtures/stubbed_doc_source_response';
import DocSourceProvider from 'ui/courier/data_source/admin_doc_source';
import UtilsMappingSetupProvider from 'ui/utils/mapping_setup';
import IndexPatternsIntervalsProvider from 'ui/index_patterns/_intervals';
import IndexPatternsIndexPatternProvider from 'ui/index_patterns/_index_pattern';
import { IndexPatternsIntervalsProvider } from 'ui/index_patterns/_intervals';
import { IndexPatternProvider } from 'ui/index_patterns/_index_pattern';
import NoDigestPromises from 'test_utils/no_digest_promises';
import { stubMapper } from 'test_utils/stub_mapper';
import { IndexPatternsCalculateIndicesProvider } from 'ui/index_patterns/_calculate_indices';

describe('index pattern', function () {
NoDigestPromises.activateForSuite();
Expand Down Expand Up @@ -51,7 +52,7 @@ describe('index pattern', function () {
{ index: 'bar', max: Infinity, min: -Infinity }
]);
});
Private.stub(require('ui/index_patterns/_calculate_indices'), calculateIndices);
Private.stub(IndexPatternsCalculateIndicesProvider, calculateIndices);

// spy on intervals
intervals = Private(IndexPatternsIntervalsProvider);
Expand All @@ -60,7 +61,7 @@ describe('index pattern', function () {
{ index: 'bar', max: Infinity, min: -Infinity }
]);

IndexPattern = Private(IndexPatternsIndexPatternProvider);
IndexPattern = Private(IndexPatternProvider);
}));

// create an indexPattern instance for each test
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/__tests__/_map_field.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import IndexPatternsMapFieldProvider from 'ui/index_patterns/_map_field';
import { IndexPatternsMapFieldProvider } from 'ui/index_patterns/_map_field';
describe('field mapping normalizer (mapField)', function () {

let fn;
Expand Down
26 changes: 16 additions & 10 deletions src/ui/public/index_patterns/__tests__/_pattern_to_wildcard.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
import expect from 'expect.js';
describe('Index pattern to wildcard', function () {
import { IndexPatternsPatternToWildcardProvider } from 'ui/index_patterns/_pattern_to_wildcard';
import ngMock from 'ng_mock';

const fn = require('ui/index_patterns/_pattern_to_wildcard')();
describe('Index pattern to wildcard', function () {
let indexPatternToWildcard;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
indexPatternToWildcard = Private(IndexPatternsPatternToWildcardProvider);
}));

it('should be a function', function () {
expect(fn).to.be.a(Function);
expect(indexPatternToWildcard).to.be.a(Function);
});

it('should parse patterns with a single escaped sequence', function () {
expect(fn('[foo-]YYYY')).to.equal('foo-*');
expect(indexPatternToWildcard('[foo-]YYYY')).to.equal('foo-*');
});

it('should parse patterns with a multiple escaped sequences', function () {
expect(fn('[foo-]YYYY[-bar]')).to.equal('foo-*-bar');
expect(fn('[foo-]YYYY[-bar-]MM')).to.equal('foo-*-bar-*');
expect(indexPatternToWildcard('[foo-]YYYY[-bar]')).to.equal('foo-*-bar');
expect(indexPatternToWildcard('[foo-]YYYY[-bar-]MM')).to.equal('foo-*-bar-*');
});

it('should handle leading patterns', function () {
expect(fn('YYYY[-foo]')).to.equal('*-foo');
expect(indexPatternToWildcard('YYYY[-foo]')).to.equal('*-foo');
});

it('should ignore [ when inside an escape', function () {
expect(fn('[f[oo-]YYYY')).to.equal('f[oo-*');
expect(indexPatternToWildcard('[f[oo-]YYYY')).to.equal('f[oo-*');
});

// Not sure if this behavior is useful, but this is how the code works
it('should add ] to the string when outside the pattern', function () {
expect(fn('[foo-]]YYYY')).to.equal('foo-]*');
expect(indexPatternToWildcard('[foo-]]YYYY')).to.equal('foo-]*');
});

it('should ignore ] when outside an escape', function () {
expect(fn('[f]oo-]YYYY')).to.equal('f*');
expect(indexPatternToWildcard('[f]oo-]YYYY')).to.equal('f*');
});
});
5 changes: 3 additions & 2 deletions src/ui/public/index_patterns/__tests__/calculate_indices.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import sinon from 'auto-release-sinon';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import moment from 'moment';
import IndexPatternsCalculateIndicesProvider from 'ui/index_patterns/_calculate_indices';
describe('ui/index_patterns/_calculate_indices', () => {
import { IndexPatternsCalculateIndicesProvider } from 'ui/index_patterns/_calculate_indices';

describe('IndexPatternsCalculateIndicesProvider', () => {
let $rootScope;
let calculateIndices;
let es;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/__tests__/flatten_hit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import IndexPatternsFlattenHitProvider from 'ui/index_patterns/_flatten_hit';
import { IndexPatternsFlattenHitProvider } from 'ui/index_patterns/_flatten_hit';

describe('IndexPattern#flattenHit()', function () {
let flattenHit;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/index_patterns/__tests__/index_patterns.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ngMock from 'ng_mock';
import expect from 'expect.js';
import sinon from 'auto-release-sinon';
import IndexPatternProvider from '../_index_pattern';
import IndexPatternsProvider from '../index_patterns';
import { IndexPatternProvider } from '../_index_pattern';
import { IndexPatternsProvider } from '../index_patterns';

describe('IndexPatterns service', function () {
let indexPatterns;
Expand All @@ -14,7 +14,7 @@ describe('IndexPatterns service', function () {

// prevent IndexPattern initialization from doing anything
Private.stub(
require('../_index_pattern'),
IndexPatternProvider,
function (...args) {
const indexPattern = new IndexPattern(...args);
sinon.stub(indexPattern, 'init', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/__tests__/intervals.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import IndexPatternsIntervalsProvider from 'ui/index_patterns/_intervals';
import { IndexPatternsIntervalsProvider } from 'ui/index_patterns/_intervals';

describe('Index Patterns', function () {
describe('interval.toIndexList()', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/_calculate_indices.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function omitIndicesWithoutTimeField(indices, timeFieldName) {
return _.pick(indices, index => index.fields[timeFieldName]);
}

export default function CalculateIndicesFactory(Promise, es) {
export function IndexPatternsCalculateIndicesProvider(es) {

// Uses the field stats api to determine the names of indices that need to
// be queried against that match the given pattern and fall within the
Expand Down
3 changes: 2 additions & 1 deletion src/ui/public/index_patterns/_cast_mapping_type.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import IndexedArray from 'ui/indexed_array';
export default function CastMappingTypeFn() {

export function IndexPatternsCastMappingTypeProvider() {

castMappingType.types = new IndexedArray({
index: ['name'],
Expand Down
Loading

0 comments on commit 5c24019

Please sign in to comment.