From fdc9430ab77d2b275b52872bee275dd4b2603042 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Sun, 31 Mar 2019 16:51:02 +0300 Subject: [PATCH 1/2] Moved parse_query directive to agg_types Moved fromQuery toQuery to query bar --- src/legacy/ui/public/agg_types/buckets/filters.js | 1 + .../{ => agg_types}/directives/__tests__/parse_query.js | 5 ++--- .../{parse_query => agg_types/directives}/parse_query.js | 5 ++--- src/legacy/ui/public/query_bar/components/query_bar.tsx | 3 +-- .../ui/public/{parse_query => query_bar}/lib/from_user.ts | 0 .../ui/public/{parse_query => query_bar/lib}/index.ts | 7 +++---- .../ui/public/{parse_query => query_bar}/lib/to_user.ts | 0 7 files changed, 9 insertions(+), 12 deletions(-) rename src/legacy/ui/public/{ => agg_types}/directives/__tests__/parse_query.js (96%) rename src/legacy/ui/public/{parse_query => agg_types/directives}/parse_query.js (90%) rename src/legacy/ui/public/{parse_query => query_bar}/lib/from_user.ts (100%) rename src/legacy/ui/public/{parse_query => query_bar/lib}/index.ts (89%) rename src/legacy/ui/public/{parse_query => query_bar}/lib/to_user.ts (100%) 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/directives/__tests__/parse_query.js b/src/legacy/ui/public/agg_types/directives/__tests__/parse_query.js similarity index 96% rename from src/legacy/ui/public/directives/__tests__/parse_query.js rename to src/legacy/ui/public/agg_types/directives/__tests__/parse_query.js index 12d9d12053286..760d3e28af994 100644 --- a/src/legacy/ui/public/directives/__tests__/parse_query.js +++ b/src/legacy/ui/public/agg_types/directives/__tests__/parse_query.js @@ -31,9 +31,8 @@ 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'; +import '../parse_query'; +import { toUser, fromUser } from '../../../query_bar/lib'; const init = function () { // Load the application 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 d7d52881567ed..6ac933f21f598 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/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 From f6ffcf33ce5242063a1a3446db43b037ccecc3f3 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Wed, 3 Apr 2019 10:50:37 +0300 Subject: [PATCH 2/2] moved user input tests away from angular -> query_bar --- .../lib/__tests__/lib_user_input.js} | 56 +------------------ 1 file changed, 2 insertions(+), 54 deletions(-) rename src/legacy/ui/public/{agg_types/directives/__tests__/parse_query.js => query_bar/lib/__tests__/lib_user_input.js} (67%) diff --git a/src/legacy/ui/public/agg_types/directives/__tests__/parse_query.js b/src/legacy/ui/public/query_bar/lib/__tests__/lib_user_input.js similarity index 67% rename from src/legacy/ui/public/agg_types/directives/__tests__/parse_query.js rename to src/legacy/ui/public/query_bar/lib/__tests__/lib_user_input.js index 760d3e28af994..ef98f3d07c5b9 100644 --- a/src/legacy/ui/public/agg_types/directives/__tests__/parse_query.js +++ b/src/legacy/ui/public/query_bar/lib/__tests__/lib_user_input.js @@ -17,65 +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 '../parse_query'; -import { toUser, fromUser } from '../../../query_bar/lib'; - -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' }); }); @@ -128,5 +77,4 @@ describe('parse-query directive', function () { expect(toUser(400)).to.be('400'); }); }); - });