diff --git a/src/legacy/ui/public/agg_types/buckets/filters.js b/src/legacy/ui/public/agg_types/buckets/filters.js index c68c7e20c4a2a..17166d2d74ab8 100644 --- a/src/legacy/ui/public/agg_types/buckets/filters.js +++ b/src/legacy/ui/public/agg_types/buckets/filters.js @@ -24,6 +24,7 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterFilters } from './create_filter/filters'; import { decorateQuery, luceneStringToDsl } from '@kbn/es-query'; import '../directives/click_focus'; +import '../directives/parse_query'; import filtersTemplate from '../controls/filters.html'; import { i18n } from '@kbn/i18n'; diff --git a/src/legacy/ui/public/parse_query/parse_query.js b/src/legacy/ui/public/agg_types/directives/parse_query.js similarity index 90% rename from src/legacy/ui/public/parse_query/parse_query.js rename to src/legacy/ui/public/agg_types/directives/parse_query.js index 4b3f9d24f72de..a5ac727b6676d 100644 --- a/src/legacy/ui/public/parse_query/parse_query.js +++ b/src/legacy/ui/public/agg_types/directives/parse_query.js @@ -17,10 +17,9 @@ * under the License. */ -import { toUser } from './lib/to_user'; -import { fromUser } from './lib/from_user'; +import { toUser, fromUser } from '../../query_bar/lib'; +import { uiModules } from '../../modules'; -import { uiModules } from '../modules'; uiModules .get('kibana') .directive('parseQuery', function () { diff --git a/src/legacy/ui/public/query_bar/components/query_bar.tsx b/src/legacy/ui/public/query_bar/components/query_bar.tsx index 508f7980eda9e..7a0627a1c9c58 100644 --- a/src/legacy/ui/public/query_bar/components/query_bar.tsx +++ b/src/legacy/ui/public/query_bar/components/query_bar.tsx @@ -34,8 +34,7 @@ import { getAutocompleteProvider, } from '../../autocomplete_providers'; import chrome from '../../chrome'; -import { fromUser, toUser } from '../../parse_query'; -import { matchPairs } from '../lib/match_pairs'; +import { fromUser, matchPairs, toUser } from '../lib'; import { QueryLanguageSwitcher } from './language_switcher'; import { SuggestionsComponent } from './typeahead/suggestions_component'; diff --git a/src/legacy/ui/public/directives/__tests__/parse_query.js b/src/legacy/ui/public/query_bar/lib/__tests__/lib_user_input.js similarity index 66% rename from src/legacy/ui/public/directives/__tests__/parse_query.js rename to src/legacy/ui/public/query_bar/lib/__tests__/lib_user_input.js index 12d9d12053286..ef98f3d07c5b9 100644 --- a/src/legacy/ui/public/directives/__tests__/parse_query.js +++ b/src/legacy/ui/public/query_bar/lib/__tests__/lib_user_input.js @@ -17,66 +17,14 @@ * under the License. */ -import angular from 'angular'; import expect from '@kbn/expect'; -import ngMock from 'ng_mock'; -// Load the kibana app dependencies. +import { toUser, fromUser } from '../'; -let $rootScope; -let $compile; -let config; -let $elemScope; -let $elem; - -let cycleIndex = 0; -const markup = ''; -import { toUser } from '../../parse_query/lib/to_user'; -import '../../parse_query/index'; -import { fromUser } from '../../parse_query/lib/from_user'; - -const init = function () { - // Load the application - ngMock.module('kibana'); - - // Create the scope - ngMock.inject(function ($injector, _$rootScope_, _$compile_, _$timeout_, _config_) { - $compile = _$compile_; - config = _config_; - - // Give us a scope - $rootScope = _$rootScope_; - }); -}; - -const compile = function () { - $rootScope.mockModel = 'cycle' + cycleIndex++; - $rootScope.mockQueryInput = undefined; - - $elem = angular.element(markup); - $compile($elem)($rootScope); - $elemScope = $elem.isolateScope(); - $rootScope.$digest(); -}; - -describe('parse-query directive', function () { - describe('initialization', function () { - beforeEach(function () { - init(); - compile(); - }); - - it('should use the model', function () { - expect($elemScope).to.have.property('ngModel'); - }); - }); +describe('user input helpers', function () { describe('user input parser', function () { - beforeEach(function () { - config.set('query:queryString:options', {}); - }); - it('should return the input if passed an object', function () { expect(fromUser({ foo: 'bar' })).to.eql({ foo: 'bar' }); }); @@ -129,5 +77,4 @@ describe('parse-query directive', function () { expect(toUser(400)).to.be('400'); }); }); - }); diff --git a/src/legacy/ui/public/parse_query/lib/from_user.ts b/src/legacy/ui/public/query_bar/lib/from_user.ts similarity index 100% rename from src/legacy/ui/public/parse_query/lib/from_user.ts rename to src/legacy/ui/public/query_bar/lib/from_user.ts diff --git a/src/legacy/ui/public/parse_query/index.ts b/src/legacy/ui/public/query_bar/lib/index.ts similarity index 89% rename from src/legacy/ui/public/parse_query/index.ts rename to src/legacy/ui/public/query_bar/lib/index.ts index 75c311e9e6f05..852f9fd269b32 100644 --- a/src/legacy/ui/public/parse_query/index.ts +++ b/src/legacy/ui/public/query_bar/lib/index.ts @@ -17,7 +17,6 @@ * under the License. */ -import './parse_query'; - -export * from './lib/from_user'; -export * from './lib/to_user'; +export * from './match_pairs'; +export * from './from_user'; +export * from './to_user'; diff --git a/src/legacy/ui/public/parse_query/lib/to_user.ts b/src/legacy/ui/public/query_bar/lib/to_user.ts similarity index 100% rename from src/legacy/ui/public/parse_query/lib/to_user.ts rename to src/legacy/ui/public/query_bar/lib/to_user.ts