Skip to content

Commit

Permalink
move saved query UI components ⇒ NP (elastic#51870) (elastic#51980)
Browse files Browse the repository at this point in the history
* move saved query UI components to NP

* Fixed search bar test

* Added service to siem mock

* change import css
  • Loading branch information
Liza Katz authored Dec 2, 2019
1 parent 877c641 commit fa7cfba
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 30 deletions.
6 changes: 1 addition & 5 deletions src/legacy/core_plugins/data/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

@import './query/query_bar/index';

@import 'src/plugins/data/public/ui/filter_bar/index';

@import 'src/plugins/data/public/ui/typeahead/index';

@import './search/search_bar/index';
@import '../../../../plugins/data/public/ui/index'

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const mockTimeHistory = {
jest.mock('../../../../../../../plugins/data/public', () => {
return {
FilterBar: () => <div className="filterBar" />,
createSavedQueryService: () => {},
};
});

Expand Down Expand Up @@ -106,6 +105,11 @@ function wrapSearchBarInContext(testProps: any) {
notifications: startMock.notifications,
http: startMock.http,
storage: createMockStorage(),
data: {
query: {
savedQueries: {},
},
},
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import { get, isEqual } from 'lodash';

import { IndexPattern } from '../../../../../data/public';
import { QueryBarTopRow } from '../../../query';
import { SavedQueryMeta, SaveQueryForm } from './saved_query_management/save_query_form';
import { SavedQueryManagementComponent } from './saved_query_management/saved_query_management_component';

import {
withKibana,
Expand All @@ -40,10 +38,11 @@ import {
esFilters,
TimeHistoryContract,
FilterBar,
SavedQueryService,
createSavedQueryService,
SavedQuery,
SavedQueryAttributes,
SavedQueryMeta,
SaveQueryForm,
SavedQueryManagementComponent,
} from '../../../../../../../plugins/data/public';

interface SearchBarInjectedDeps {
Expand Down Expand Up @@ -112,8 +111,8 @@ class SearchBarUI extends Component<SearchBarProps, State> {
showAutoRefreshOnly: false,
};

private savedQueryService!: SavedQueryService;
private services = this.props.kibana.services;
private savedQueryService = this.services.data.query.savedQueries;
public filterBarRef: Element | null = null;
public filterBarWrapperRef: Element | null = null;

Expand Down Expand Up @@ -368,9 +367,6 @@ class SearchBarUI extends Component<SearchBarProps, State> {
this.setFilterBarHeight();
this.ro.observe(this.filterBarRef);
}
if (this.services.savedObjects) {
this.savedQueryService = createSavedQueryService(this.services.savedObjects.client);
}
}

public componentDidUpdate() {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* under the License.
*/

import { IndexPatternMissingIndices } from './errors';
import {
ILLEGAL_CHARACTERS_KEY,
CONTAINS_SPACES_KEY,
ILLEGAL_CHARACTERS_VISIBLE,
ILLEGAL_CHARACTERS,
IndexPatternMissingIndices,
validateIndexPattern,
} from './lib';
import { getRoutes, getFromSavedObject } from './utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/* eslint-disable */

import { KbnError } from '../../../kibana_utils/public';
import { KbnError } from '../../../../kibana_utils/public';

/**
* Tried to call a method that relies on SearchSource having an indexPattern assigned
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/index_patterns/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
export { getTitle } from './get_title';
export * from './types';
export { validateIndexPattern } from './validate_index_pattern';
export { IndexPatternMissingIndices } from './errors';
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
* under the License.
*/

// TODO: remove when index patterns are moved here.
jest.mock('ui/new_platform');

import { stubIndexPattern, stubFields } from '../stubs';
import { getSuggestionsProvider } from './value_suggestions';
import { IUiSettingsClient } from 'kibana/public';
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/data/public/ui/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

@import './filter_bar/index';

@import './typeahead/index';

@import './saved_query_management/index';
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import {

import { existsOperator, isBetweenOperator, isOneOfOperator, isOperator } from './filter_operators';

jest.mock('ui/new_platform');

describe('Filter editor utils', () => {
describe('getFieldFromFilter', () => {
it('should return the field from the filter', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/data/public/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ export { SuggestionsComponent } from './typeahead/suggestions_component';
export { IndexPatternSelect } from './index_pattern_select';
export { FilterBar } from './filter_bar';
export { applyFiltersPopover } from './apply_filters';
// temp export
// temp export - will be removed as final components are migrated to NP
export { QueryLanguageSwitcher } from './query_string_input/language_switcher';
export { SavedQueryManagementComponent } from './saved_query_management';
export { SaveQueryForm, SavedQueryMeta } from './saved_query_form';
20 changes: 20 additions & 0 deletions src/plugins/data/public/ui/saved_query_form/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { SavedQueryMeta, SaveQueryForm } from '../saved_query_form/save_query_form';
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { sortBy, isEqual } from 'lodash';
import {
SavedQuery,
SavedQueryAttributes,
SavedQueryService,
} from '../../../../../../../../plugins/data/public';
import { SavedQuery, SavedQueryAttributes, SavedQueryService } from '../..';

interface Props {
savedQuery?: SavedQueryAttributes;
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/data/public/ui/saved_query_management/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { SavedQueryManagementComponent } from './saved_query_management_component';
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { EuiListGroupItem, EuiConfirmModal, EuiOverlayMask, EuiIconTip } from '@
import React, { Fragment, useState } from 'react';
import classNames from 'classnames';
import { i18n } from '@kbn/i18n';
import { SavedQuery } from '../../../../../../../../plugins/data/public';
import { SavedQuery } from '../..';

interface Props {
savedQuery: SavedQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
import { i18n } from '@kbn/i18n';
import React, { FunctionComponent, useEffect, useState, Fragment } from 'react';
import { sortBy } from 'lodash';
import { SavedQuery, SavedQueryService } from '../../../../../../../../plugins/data/public';
import { SavedQuery, SavedQueryService } from '../..';
import { SavedQueryListItem } from './saved_query_list_item';

const perPage = 50;
Expand Down
5 changes: 5 additions & 0 deletions x-pack/legacy/plugins/siem/public/mock/test_providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ const services = {
storage: {
get: () => {},
},
data: {
query: {
savedQueries: {},
},
},
};

const localStorageMock = () => {
Expand Down

0 comments on commit fa7cfba

Please sign in to comment.