Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move search bar to NP #52622

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ export function plugin() {
export { DataStart };

export { Field, FieldType, IFieldList, IndexPattern } from './index_patterns';
export { SearchBar, SearchBarProps } from './search';
export {
SavedQueryAttributes,
SavedQuery,
SavedQueryTimeFilter,
} from '../../../../plugins/data/public';
export { SavedQuery, SavedQueryTimeFilter } from '../../../../plugins/data/public';

/** @public static code */
export * from '../common';
Expand Down
30 changes: 4 additions & 26 deletions src/legacy/core_plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
*/

import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { createSearchBar, StatetfulSearchBarProps } from './search';
import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public';
import { DataPublicPluginStart } from '../../../../plugins/data/public';
import { initLegacyModule } from './shim/legacy_module';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { setFieldFormats } from '../../../../plugins/data/public/services';
Expand All @@ -35,11 +32,8 @@ export interface DataPluginStartDependencies {
*
* @public
*/
export interface DataStart {
ui: {
SearchBar: React.ComponentType<StatetfulSearchBarProps>;
};
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DataStart {}

/**
* Data Plugin - public
Expand All @@ -54,28 +48,12 @@ export interface DataStart {
*/

export class DataPlugin implements Plugin<void, DataStart, {}, DataPluginStartDependencies> {
private storage!: IStorageWrapper;

public setup(core: CoreSetup) {
this.storage = new Storage(window.localStorage);
}
public setup(core: CoreSetup) {}

public start(core: CoreStart, { data }: DataPluginStartDependencies): DataStart {
// This is required for when Angular code uses Field and FieldList.
setFieldFormats(data.fieldFormats);
initLegacyModule(data.indexPatterns);

const SearchBar = createSearchBar({
core,
data,
storage: this.storage,
});

return {
ui: {
SearchBar,
},
};
return {};
}

public stop() {}
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/core_plugins/data/public/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@
* specific language governing permissions and limitations
* under the License.
*/

export * from './search_bar';
20 changes: 0 additions & 20 deletions src/legacy/core_plugins/data/public/search/search_bar/index.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions src/legacy/core_plugins/data/public/shim/legacy_module.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { SavedObjectsClientProvider } from 'ui/saved_objects';
import uiRoutes from 'ui/routes';
import angularTemplate from './angular_template.html';
import 'ui/index_patterns';
import { npStart } from 'ui/new_platform';
import { setup as managementSetup } from '../../../../../../management/public/legacy';
import { getCreateBreadcrumbs } from '../breadcrumbs';

Expand All @@ -41,7 +41,7 @@ uiRoutes.when('/management/kibana/index_pattern', {
const services = {
config: $injector.get('config'),
es: $injector.get('es'),
indexPatterns: $injector.get('indexPatterns'),
indexPatterns: npStart.plugins.data.indexPatterns,
$http: $injector.get('$http'),
savedObjectsClient: Private(SavedObjectsClientProvider),
indexPatternCreationType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { docTitle } from 'ui/doc_title';
import { KbnUrlProvider } from 'ui/url';
import uiRoutes from 'ui/routes';
import { toastNotifications } from 'ui/notify';
import { npStart } from 'ui/new_platform';

import template from './create_edit_field.html';
import { getEditFieldBreadcrumbs, getCreateFieldBreadcrumbs } from '../../breadcrumbs';
Expand Down Expand Up @@ -96,7 +97,8 @@ uiRoutes
});
},
resolve: {
indexPattern: function ($route, Promise, redirectWhenMissing, indexPatterns) {
indexPattern: function ($route, Promise, redirectWhenMissing) {
const { indexPatterns } = npStart.plugins.data;
return Promise.resolve(indexPatterns.get($route.current.params.indexPatternId))
.catch(redirectWhenMissing('/management/kibana/index_patterns'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { IndexedFieldsTable } from './indexed_fields_table';
import { ScriptedFieldsTable } from './scripted_fields_table';
import { i18n } from '@kbn/i18n';
import { I18nContext } from 'ui/i18n';
import { npStart } from 'ui/new_platform';

import { getEditBreadcrumbs } from '../breadcrumbs';

Expand Down Expand Up @@ -168,7 +169,8 @@ uiRoutes.when('/management/kibana/index_patterns/:indexPatternId', {
template,
k7Breadcrumbs: getEditBreadcrumbs,
resolve: {
indexPattern: function ($route, Promise, redirectWhenMissing, indexPatterns) {
indexPattern: function ($route, Promise, redirectWhenMissing) {
const { indexPatterns } = npStart.plugins.data;
return Promise.resolve(indexPatterns.get($route.current.params.indexPatternId)).catch(
redirectWhenMissing('/management/kibana/index_patterns')
);
Expand All @@ -179,7 +181,7 @@ uiRoutes.when('/management/kibana/index_patterns/:indexPatternId', {
uiModules
.get('apps/management')
.controller('managementIndexPatternsEdit', function (
$scope, $location, $route, Promise, config, indexPatterns, Private, AppState, confirmModal) {
$scope, $location, $route, Promise, config, Private, AppState, confirmModal) {
const $state = $scope.state = new AppState();

$scope.fieldWildcardMatcher = (...args) => fieldWildcardMatcher(...args, config.get('metaFields'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const REACT_OBJECTS_TABLE_DOM_ELEMENT_ID = 'reactSavedObjectsTable';

function updateObjectsTable($scope, $injector) {
const Private = $injector.get('Private');
const indexPatterns = $injector.get('indexPatterns');
const indexPatterns = npStart.plugins.data.indexPatterns;
const $http = $injector.get('$http');
const kbnUrl = $injector.get('kbnUrl');
const config = $injector.get('config');
Expand Down
3 changes: 1 addition & 2 deletions src/legacy/core_plugins/navigation/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/

import { npSetup, npStart } from 'ui/new_platform';
import { start as dataShim } from '../../data/public/legacy';
import { plugin } from '.';

const navPlugin = plugin();

export const setup = navPlugin.setup(npSetup.core);

export const start = navPlugin.start(npStart.core, {
data: dataShim,
data: npStart.plugins.data,
});
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/navigation/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/

import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { TopNavMenuExtensionsRegistry, TopNavMenuExtensionsRegistrySetup } from './top_nav_menu';
import { createTopNav } from './top_nav_menu/create_top_nav_menu';
import { TopNavMenuProps } from './top_nav_menu/top_nav_menu';
import { DataStart } from '../../data/public';

/**
* Interface for this plugin's returned `setup` contract.
Expand All @@ -44,7 +44,7 @@ export interface NavigationStart {
}

export interface NavigationPluginStartDependencies {
data: DataStart;
data: DataPublicPluginStart;
}

export class NavigationPlugin implements Plugin<NavigationSetup, NavigationStart> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import React from 'react';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { TopNavMenuProps, TopNavMenu } from './top_nav_menu';
import { TopNavMenuData } from './top_nav_menu_data';
import { DataStart } from '../../../../core_plugins/data/public';

export function createTopNav(data: DataStart, extraConfig: TopNavMenuData[]) {
export function createTopNav(data: DataPublicPluginStart, extraConfig: TopNavMenuData[]) {
return (props: TopNavMenuProps) => {
const config = (props.config || []).concat(extraConfig);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { TopNavMenu } from './top_nav_menu';
import { TopNavMenuData } from './top_nav_menu_data';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';

jest.mock('ui/new_platform');

const mockTimeHistory = {
add: () => {},
get: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import { I18nProvider } from '@kbn/i18n/react';

import { TopNavMenuData } from './top_nav_menu_data';
import { TopNavMenuItem } from './top_nav_menu_item';
import { SearchBarProps, DataStart } from '../../../../core_plugins/data/public';
import { SearchBarProps, DataPublicPluginStart } from '../../../../../plugins/data/public';

export type TopNavMenuProps = Partial<SearchBarProps> & {
appName: string;
config?: TopNavMenuData[];
showSearchBar?: boolean;
data?: DataStart;
data?: DataPublicPluginStart;
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import _ from 'lodash';
import { SavedObjectsClientProvider } from 'ui/saved_objects';
import { npStart } from 'ui/new_platform';

export function ArgValueSuggestionsProvider(Private, indexPatterns) {

const savedObjectsClient = Private(SavedObjectsClientProvider);
export function ArgValueSuggestionsProvider() {
const { indexPatterns } = npStart.plugins.data;
const { client: savedObjectsClient } = npStart.core.savedObjects;

async function getIndexPattern(functionArgs) {
const indexPatternArg = functionArgs.find(argument => {
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/ui/public/saved_objects/saved_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { InvalidJSONProperty, SavedObjectNotFound, expandShorthand } from '../..

import { SearchSource } from '../courier';
import { findObjectByTitle } from './find_object_by_title';
import { SavedObjectsClientProvider } from './saved_objects_client_provider';
import { migrateLegacyQuery } from '../utils/migrate_legacy_query';
import { npStart } from 'ui/new_platform';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -66,8 +65,9 @@ function isErrorNonFatal(error) {
return error.message === OVERWRITE_REJECTED || error.message === SAVE_DUPLICATE_REJECTED;
}

export function SavedObjectProvider(Promise, Private, confirmModalPromise, indexPatterns) {
const savedObjectsClient = Private(SavedObjectsClientProvider);
export function SavedObjectProvider(Promise, confirmModalPromise) {
const { indexPatterns } = npStart.plugins.data;
const { client: savedObjectsClient } = npStart.core.savedObjects;

/**
* The SavedObject class is a base class for saved objects loaded from the server and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import { setNotifications, setFieldFormats } from '../../services';
import { notificationServiceMock } from '../../../../../core/public/notifications/notifications_service.mock';
import { FieldFormatRegisty } from '../../field_formats_provider';

jest.mock('ui/new_platform');

jest.mock('../../../../kibana_utils/public', () => {
const originalModule = jest.requireActual('../../../../kibana_utils/public');

Expand All @@ -50,19 +48,6 @@ jest.mock('../../../../kibana_utils/public', () => {
};
});

jest.mock('ui/notify', () => ({
toastNotifications: {
addDanger: jest.fn(),
addError: jest.fn(),
},
}));

jest.mock('ui/saved_objects', () => {
return {
findObjectByTitle: jest.fn(),
};
});

let mockFieldsFetcherResponse: any[] = [];

jest.mock('./_fields_fetcher', () => ({
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const createStartContract = (): Start => {
query: queryStartMock,
ui: {
IndexPatternSelect: jest.fn(),
SearchBar: jest.fn(),
},
indexPatterns: {} as IndexPatternsContract,
};
Expand Down
Loading