[UnifiedSearch] Expose QueryStringInput via plugin contract (#173810)

## Summary

Expose QueryStringInput via plugin contract this will make sure deps are
handled by the component itself.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Shahzad 2024-01-03 16:28:34 +01:00 committed by GitHub
parent 76e812133a
commit 999d8fde76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 144 additions and 272 deletions

View file

@ -38,6 +38,7 @@ const createStartContract = (): Start => {
SearchBar: jest.fn().mockReturnValue(null),
AggregateQuerySearchBar: jest.fn().mockReturnValue(null),
FiltersBuilderLazy: jest.fn(),
QueryStringInput: jest.fn().mockReturnValue('QueryStringInput'),
},
};
};

View file

@ -9,6 +9,7 @@ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '@kbn/cor
import { Storage, IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { APPLY_FILTER_TRIGGER } from '@kbn/data-plugin/public';
import { createQueryStringInput } from './query_string_input/get_query_string_input';
import { UPDATE_FILTER_REFERENCES_TRIGGER, updateFilterReferencesTrigger } from './triggers';
import { ConfigSchema } from '../config';
import { setIndexPatterns, setTheme, setOverlays } from './services';
@ -108,6 +109,18 @@ export class UnifiedSearchPublicPlugin
getCustomSearchBar,
AggregateQuerySearchBar: SearchBar,
FiltersBuilderLazy,
QueryStringInput: createQueryStringInput({
data,
dataViews,
docLinks: core.docLinks,
http: core.http,
notifications: core.notifications,
storage: this.storage,
uiSettings: core.uiSettings,
unifiedSearch: {
autocomplete: autocompleteStart,
},
}),
},
autocomplete: autocompleteStart,
};

View file

@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React from 'react';
import { QueryStringInput, QueryStringInputProps } from '.';
export function createQueryStringInput(deps: QueryStringInputProps['deps']) {
return (props: Omit<QueryStringInputProps, 'deps'>) => {
return <QueryStringInput {...props} deps={deps} />;
};
}

View file

@ -18,7 +18,7 @@ import { CoreStart, DocLinksStart } from '@kbn/core/public';
import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { AutocompleteSetup, AutocompleteStart } from './autocomplete';
import type { IndexPatternSelectProps, StatefulSearchBarProps } from '.';
import type { IndexPatternSelectProps, QueryStringInputProps, StatefulSearchBarProps } from '.';
import type { FiltersBuilderProps } from './filters_builder/filters_builder';
import { StatefulSearchBarDeps } from './search_bar/create_search_bar';
@ -53,6 +53,7 @@ export interface UnifiedSearchPublicPluginStartUi {
SearchBar: (props: StatefulSearchBarProps<Query>) => React.ReactElement;
AggregateQuerySearchBar: AggQuerySearchBarComp;
FiltersBuilderLazy: React.ComponentType<FiltersBuilderProps>;
QueryStringInput: React.ComponentType<Omit<QueryStringInputProps, 'deps'>>;
}
/**

View file

@ -8,13 +8,13 @@
"server": false,
"browser": true,
"requiredPlugins": [
"dataViews"
"dataViews",
"unifiedSearch",
],
"optionalPlugins": [
"visualizations"
],
"requiredBundles": [
"unifiedSearch",
"kibanaUtils",
"kibanaReact",
"data",

View file

@ -12,7 +12,6 @@ import { i18n } from '@kbn/i18n';
import type { Query } from '@kbn/es-query';
import { IAggConfig } from '@kbn/data-plugin/public';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
@ -45,14 +44,9 @@ function FilterRow({
const { services } = useKibana<VisDefaultEditorKibanaServices>();
const {
data,
dataViews,
unifiedSearch,
usageCollection,
storage,
notifications,
http,
docLinks,
uiSettings,
unifiedSearch: {
ui: { QueryStringInput },
},
appName,
} = services;
@ -117,17 +111,6 @@ function FilterRow({
bubbleSubmitEvent={true}
languageSwitcherPopoverAnchorPosition="leftDown"
size="s"
deps={{
data,
dataViews,
unifiedSearch,
usageCollection,
storage,
notifications,
http,
docLinks,
uiSettings,
}}
appName={appName}
/>
</EuiFormRow>

View file

@ -9,7 +9,7 @@
import type { CoreStart, DocLinksStart } from '@kbn/core/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import type { AutocompleteStart } from '@kbn/unified-search-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
@ -17,9 +17,7 @@ export interface VisDefaultEditorKibanaServices {
data: DataPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
appName: string;
unifiedSearch: {
autocomplete: AutocompleteStart;
};
unifiedSearch: UnifiedSearchPublicPluginStart;
usageCollection?: UsageCollectionStart;
storage: IStorageWrapper;
notifications: CoreStart['notifications'];

View file

@ -13,9 +13,6 @@ import {
EuiSelectOption,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { ApmPluginStartDeps } from '../../../../plugin';
import {
TraceSearchQuery,
TraceSearchType,
@ -54,11 +51,11 @@ export function TraceSearchBox({
onQueryCommit,
loading,
}: Props) {
const { unifiedSearch, core, data, dataViews } = useApmPluginContext();
const { notifications, http, docLinks, uiSettings } = core;
const {
services: { storage },
} = useKibana<ApmPluginStartDeps>();
unifiedSearch: {
ui: { QueryStringInput },
},
} = useApmPluginContext();
const { dataView } = useApmDataView();
@ -106,16 +103,6 @@ export function TraceSearchBox({
defaultMessage: 'APM',
}
)}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
storage,
}}
/>
</form>
)}

View file

@ -9,7 +9,6 @@ import React, { memo, useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import type { FieldSpec } from '@kbn/data-plugin/common';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { useStartServices } from '../../../../../hooks';
@ -28,8 +27,12 @@ export const LogQueryBar: React.FunctionComponent<{
isQueryValid: boolean;
onUpdateQuery: (query: string, runQuery?: boolean) => void;
}> = memo(({ query, isQueryValid, onUpdateQuery }) => {
const { data, notifications, http, docLinks, uiSettings, unifiedSearch, storage, dataViews } =
useStartServices();
const {
data,
unifiedSearch: {
ui: { QueryStringInput },
},
} = useStartServices();
const [indexPatternFields, setIndexPatternFields] = useState<FieldSpec[]>();
useEffect(() => {
@ -81,7 +84,6 @@ export const LogQueryBar: React.FunctionComponent<{
onUpdateQuery(newQuery.query as string, true);
}}
appName={i18n.translate('xpack.fleet.appTitle', { defaultMessage: 'Fleet' })}
deps={{ unifiedSearch, notifications, http, docLinks, uiSettings, data, dataViews, storage }}
/>
);
});

View file

@ -27,7 +27,6 @@
"spaces"
],
"requiredBundles": [
"unifiedSearch",
"kibanaUtils",
"kibanaReact"
]

View file

@ -30,41 +30,51 @@ import { ReactWrapper } from 'enzyme';
import { createMockGraphStore } from '../state_management/mocks';
import { Provider } from 'react-redux';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { createQueryStringInput } from '@kbn/unified-search-plugin/public/query_string_input/get_query_string_input';
import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
jest.mock('../services/source_modal', () => ({ openSourceModal: jest.fn() }));
const waitForIndexPatternFetch = () => new Promise((r) => setTimeout(r));
function getServiceMocks() {
return {
uiSettings: {
get: (key: string) => {
return 10;
const docLinks = {
links: {
query: {
kueryQuerySyntax: '',
},
} as IUiSettingsClient,
},
} as DocLinksStart;
const uiSettings = {
get: (key: string) => {
return 10;
},
} as IUiSettingsClient;
return {
savedObjects: {} as SavedObjectsStart,
savedObjectsManagement: {} as SavedObjectsManagementPluginStart,
notifications: {} as NotificationsStart,
docLinks: {
links: {
query: {
kueryQuerySyntax: '',
},
},
} as DocLinksStart,
http: {} as HttpStart,
overlays: {} as OverlayStart,
storage: {
get: () => {},
},
data: {
query: {
savedQueries: {},
},
},
unifiedSearch: {
autocomplete: {
hasQuerySuggestions: () => false,
ui: {
QueryStringInput: createQueryStringInput({
docLinks,
uiSettings,
storage: {
get: () => {},
set: () => {},
remove: () => {},
clear: () => {},
} as IStorageWrapper,
data: dataPluginMock.createStartContract(),
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
notifications: {} as NotificationsStart,
http: {} as HttpStart,
dataViews: dataViewPluginMocks.createStartContract(),
}),
},
},
};

View file

@ -7,16 +7,18 @@
import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiToolTip } from '@elastic/eui';
import React, { useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { connect } from 'react-redux';
import { toElasticsearchQuery, fromKueryExpression, Query } from '@kbn/es-query';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { TooltipWrapper } from '@kbn/visualization-utils';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { IUnifiedSearchPluginServices } from '@kbn/unified-search-plugin/public/types';
import {
IUnifiedSearchPluginServices,
UnifiedSearchPublicPluginStart,
} from '@kbn/unified-search-plugin/public/types';
import { ContentManagementPublicStart } from '@kbn/content-management-plugin/public';
import { IndexPatternSavedObject, IndexPatternProvider, WorkspaceField } from '../types';
import { openSourceModal } from '../services/source_modal';
import {
@ -96,19 +98,19 @@ export function SearchBarComponent(props: SearchBarStateProps & SearchBarProps)
}, [currentDatasource, indexPatternProvider, onIndexPatternChange]);
const kibana = useKibana<
IUnifiedSearchPluginServices & { contentManagement: ContentManagementPublicStart }
IUnifiedSearchPluginServices & {
contentManagement: ContentManagementPublicStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
}
>();
const { services, overlays } = kibana;
const {
uiSettings,
appName,
unifiedSearch,
data,
dataViews,
storage,
notifications,
http,
docLinks,
unifiedSearch: {
ui: { QueryStringInput },
},
contentManagement,
} = services;
if (!overlays) return null;
@ -178,16 +180,6 @@ export function SearchBarComponent(props: SearchBarStateProps & SearchBarProps)
query={query}
onChange={setQuery}
appName={appName}
deps={{
unifiedSearch,
data,
dataViews,
storage,
notifications,
http,
docLinks,
uiSettings,
}}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>

View file

@ -55,8 +55,7 @@
"lens",
"maps",
"savedObjectsFinder",
"usageCollection",
"unifiedSearch"
"usageCollection"
],
"extraPublicDirs": ["common"]
}

View file

@ -7,18 +7,15 @@
import React, { FC, useEffect, useMemo, useState } from 'react';
import { debounce } from 'lodash';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { EuiButtonGroup, EuiCode, EuiFlexGroup, EuiFlexItem, EuiInputPopover } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { fromKueryExpression, luceneStringToDsl, toElasticsearchQuery } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/common';
import type { Query } from '@kbn/es-query';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { QueryErrorMessage } from '@kbn/ml-error-utils';
import { SEARCH_QUERY_LANGUAGE, SearchQueryLanguage } from '@kbn/ml-query-utils';
import { PLUGIN_ID } from '../../../../../../../common/constants/app';
import { Dictionary } from '../../../../../../../common/types/common';
import { removeFilterFromQueryString } from '../../../../../explorer/explorer_utils';
@ -54,8 +51,11 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
);
const { services } = useMlKibana();
const { unifiedSearch, data, storage, notifications, http, docLinks, uiSettings, dataViews } =
services;
const {
unifiedSearch: {
ui: { QueryStringInput },
},
} = services;
const searchChangeHandler = (q: Query) => setSearchInput(q);
@ -199,16 +199,6 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
dataTestSubj="mlDFAnalyticsQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
appName={PLUGIN_ID}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
storage,
dataViews,
}}
/>
</EuiFlexItem>
{filters && filters.options && (

View file

@ -10,7 +10,6 @@ import { EuiCode, EuiInputPopover } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { fromKueryExpression, luceneStringToDsl, toElasticsearchQuery } from '@kbn/es-query';
import type { Query } from '@kbn/es-query';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/common';
import type { QueryErrorMessage } from '@kbn/ml-error-utils';
import type { InfluencersFilterQuery } from '@kbn/ml-anomaly-utils';
@ -111,14 +110,9 @@ export const ExplorerQueryBar: FC<ExplorerQueryBarProps> = ({
const { anomalyExplorerCommonStateService } = useAnomalyExplorerContext();
const { services } = useMlKibana();
const {
unifiedSearch,
data,
storage,
notifications,
http,
docLinks,
uiSettings,
dataViews: dataViewsService,
unifiedSearch: {
ui: { QueryStringInput },
},
} = services;
// The internal state of the input query bar updated on every key stroke.
@ -177,16 +171,6 @@ export const ExplorerQueryBar: FC<ExplorerQueryBarProps> = ({
dataTestSubj="explorerQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
appName={PLUGIN_ID}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
storage,
dataViews: dataViewsService,
}}
/>
}
isOpen={queryErrorMessage?.query === searchInput.query && queryErrorMessage?.message !== ''}

View file

@ -6,7 +6,6 @@
*/
import { EuiFormRow } from '@elastic/eui';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import React, { ReactNode } from 'react';
import { Controller, FieldPath, useFormContext } from 'react-hook-form';
import { useCreateDataView } from '../../../../hooks/use_create_data_view';
@ -32,8 +31,11 @@ export function QueryBuilder({
required,
tooltip,
}: Props) {
const { data, docLinks, dataViews, http, notifications, storage, uiSettings, unifiedSearch } =
useKibana().services;
const {
unifiedSearch: {
ui: { QueryStringInput },
},
} = useKibana().services;
const { control, getFieldState } = useFormContext<CreateSLOForm>();
@ -67,16 +69,6 @@ export function QueryBuilder({
appName="Observability"
bubbleSubmitEvent={false}
dataTestSubj={dataTestSubj}
deps={{
data,
dataViews,
docLinks,
http,
notifications,
storage,
uiSettings,
unifiedSearch,
}}
disableAutoFocus
disableLanguageSwitcher
indexPatterns={dataView ? [dataView] : []}

View file

@ -119,6 +119,9 @@ const mockKibana = () => {
get: () => {},
},
unifiedSearch: {
ui: {
QueryStringInput: () => <div>Query String Input</div>,
},
autocomplete: {
hasQuerySuggestions: () => {},
},

View file

@ -18,7 +18,6 @@ import {
import { EuiSelectableOptionCheckedType } from '@elastic/eui/src/components/selectable/selectable_option';
import { Query } from '@kbn/es-query';
import { i18n } from '@kbn/i18n';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import React, { useState } from 'react';
import { useCreateDataView } from '../../../hooks/use_create_data_view';
import { useKibana } from '../../../utils/kibana_react';
@ -70,8 +69,11 @@ const SORT_OPTIONS: Array<Item<SortField>> = [
export type ViewMode = 'default' | 'compact';
export function SloListSearchBar({ loading, onChangeQuery, onChangeSort, initialState }: Props) {
const { data, dataViews, docLinks, http, notifications, storage, uiSettings, unifiedSearch } =
useKibana().services;
const {
unifiedSearch: {
ui: { QueryStringInput },
},
} = useKibana().services;
const { dataView } = useCreateDataView({ indexPatternString: '.slo-observability.summary-*' });
const [query, setQuery] = useState(initialState.kqlQuery);
@ -97,16 +99,6 @@ export function SloListSearchBar({ loading, onChangeQuery, onChangeSort, initial
<QueryStringInput
appName="Observability"
bubbleSubmitEvent={false}
deps={{
data,
dataViews,
docLinks,
http,
notifications,
storage,
uiSettings,
unifiedSearch,
}}
disableAutoFocus
onSubmit={(value: Query) => {
setQuery(String(value.query));

View file

@ -110,6 +110,9 @@ const mockKibana = () => {
},
},
unifiedSearch: {
ui: {
QueryStringInput: () => <div>Query String Input</div>,
},
autocomplete: {
hasQuerySuggestions: () => {},
},

View file

@ -6,7 +6,6 @@
*/
import React, { useState } from 'react';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import type { DataView, DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { Query } from '@kbn/es-query';
@ -39,15 +38,9 @@ interface Props {
export const QueryInput = (props: Props) => {
const {
data,
dataViews,
docLinks,
http,
notifications,
storage,
uiSettings,
unifiedSearch,
usageCollection,
unifiedSearch: {
ui: { QueryStringInput },
},
} = useKibana<{
data: DataPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
@ -82,17 +75,6 @@ export const QueryInput = (props: Props) => {
}
}}
appName={STACK_ALERTS_FEATURE_ID}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
storage,
usageCollection,
}}
/>
);
};

View file

@ -8,7 +8,6 @@
import React, { useEffect, useState } from 'react';
import { EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { useFetcher } from '@kbn/observability-shared-plugin/public';
import { SYNTHETICS_INDEX_PATTERN } from '../../../../../common/constants';
@ -38,15 +37,10 @@ export const AlertQueryBar = ({ query = '', onChange }: Props) => {
const {
appName,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
unifiedSearch,
storage,
usageCollection,
unifiedSearch: {
ui: { QueryStringInput },
},
} = services;
const [inputVal, setInputVal] = useState<string>(query);
@ -85,17 +79,6 @@ export const AlertQueryBar = ({ query = '', onChange }: Props) => {
defaultMessage: 'Filter using kql syntax',
})}
appName={appName}
deps={{
unifiedSearch,
data,
dataViews,
storage,
notifications,
http,
docLinks,
uiSettings,
usageCollection,
}}
/>
</EuiFlexItem>
);

View file

@ -36,7 +36,6 @@
"alerting"
],
"requiredBundles": [
"unifiedSearch",
"esUiShared",
"discover",
"kibanaUtils",

View file

@ -23,7 +23,6 @@ import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'
import { SharePluginStart } from '@kbn/share-plugin/public';
import type { Storage } from '@kbn/kibana-utils-plugin/public';
import type { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { savedSearchPluginMock } from '@kbn/saved-search-plugin/public/mocks';
import { contentManagementMock } from '@kbn/content-management-plugin/public/mocks';
@ -32,6 +31,7 @@ import { MlSharedContext } from './shared_context';
import type { GetMlSharedImportsReturnType } from '../../shared_imports';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks';
const coreSetup = coreMock.createSetup();
const coreStart = coreMock.createStart();
@ -93,7 +93,7 @@ const appDependencies: AppDependencies = {
share: { urlGenerators: { getUrlGenerator: jest.fn() } } as unknown as SharePluginStart,
ml: {} as GetMlSharedImportsReturnType,
triggersActionsUi: {} as jest.Mocked<TriggersAndActionsUIPublicPluginStart>,
unifiedSearch: {} as jest.Mocked<UnifiedSearchPublicPluginStart>,
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
savedObjectsManagement: {} as jest.Mocked<SavedObjectsManagementPluginStart>,
settings: settingsServiceMock.createStartContract(),
savedSearch: savedSearchPluginMock.createStartContract(),

View file

@ -6,16 +6,11 @@
*/
import React, { type FC } from 'react';
import { EuiCode, EuiInputPopover } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { PLUGIN } from '../../../../../../common/constants';
import { SearchItems } from '../../../../hooks/use_search_items';
import { StepDefineFormHook, QUERY_LANGUAGE_KUERY } from '../step_define';
import { useAppDependencies } from '../../../../app_dependencies';
@ -30,15 +25,9 @@ export const SourceSearchBar: FC<SourceSearchBarProps> = ({ dataView, searchBar
} = searchBar;
const {
uiSettings,
notifications,
http,
docLinks,
data,
dataViews,
storage,
unifiedSearch,
usageCollection,
unifiedSearch: {
ui: { QueryStringInput },
},
} = useAppDependencies();
return (
@ -67,17 +56,6 @@ export const SourceSearchBar: FC<SourceSearchBarProps> = ({ dataView, searchBar
dataTestSubj="transformQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
appName={PLUGIN.getI18nName()}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
storage,
usageCollection,
}}
/>
}
isOpen={queryErrorMessage?.query === searchInput.query && queryErrorMessage?.message !== ''}

View file

@ -30,6 +30,7 @@ import { StepDefineForm } from './step_define_form';
import { MlSharedContext } from '../../../../__mocks__/shared_context';
import { getMlSharedImports } from '../../../../../shared_imports';
import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks';
jest.mock('../../../../../shared_imports');
jest.mock('../../../../app_dependencies');
@ -81,6 +82,7 @@ describe('Transform: <DefinePivotForm />', () => {
const services = {
...startMock,
data: dataPluginMock.createStartContract(),
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
appName: 'the-test-app',
storage: createMockStorage(),
};

View file

@ -36,7 +36,6 @@
],
"optionalPlugins": ["cloud", "data", "fleet", "home", "ml", "spaces", "telemetry"],
"requiredBundles": [
"unifiedSearch",
"fleet",
"kibanaReact",
"kibanaUtils",

View file

@ -117,6 +117,7 @@ const Application = (props: UptimeAppProps) => {
...plugins,
storage,
data: startPlugins.data,
unifiedSearch: startPlugins.unifiedSearch,
fleet: startPlugins.fleet,
inspector: startPlugins.inspector,
triggersActionsUi: startPlugins.triggersActionsUi,

View file

@ -8,7 +8,6 @@
import React, { useEffect, useState } from 'react';
import { EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { isValidKuery } from '../../query_bar/query_bar';
import * as labels from '../translations';
@ -26,15 +25,9 @@ export const AlertQueryBar = ({ query = '', onChange }: Props) => {
const {
appName,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
unifiedSearch,
storage,
usageCollection,
unifiedSearch: {
ui: { QueryStringInput },
},
} = services;
const [inputVal, setInputVal] = useState<string>(query);
@ -70,17 +63,6 @@ export const AlertQueryBar = ({ query = '', onChange }: Props) => {
defaultMessage: 'Filter using kql syntax',
})}
appName={appName}
deps={{
unifiedSearch,
data,
dataViews,
storage,
notifications,
http,
docLinks,
uiSettings,
usageCollection,
}}
/>
</EuiFlexItem>
);

View file

@ -8,7 +8,6 @@
import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexItem } from '@elastic/eui';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { SyntaxType, useQueryBar } from './use_query_bar';
import { KQL_PLACE_HOLDER, SIMPLE_SEARCH_PLACEHOLDER } from './translations';
@ -38,15 +37,9 @@ export const QueryBar = () => {
const {
appName,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
unifiedSearch,
storage,
usageCollection,
unifiedSearch: {
ui: { QueryStringInput },
},
} = services;
const { query, setQuery, submitImmediately } = useQueryBar();
@ -94,17 +87,6 @@ export const QueryBar = () => {
}
isInvalid={isInValid()}
appName={appName}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
storage,
usageCollection,
}}
/>
</EuiFlexItem>
);

View file

@ -8,14 +8,13 @@
import React from 'react';
import { OverviewPageComponent } from './overview';
import { render } from '../lib/helper/rtl_helpers';
import { SIMPLE_SEARCH_PLACEHOLDER } from '../components/overview/query_bar/translations';
describe('MonitorPage', () => {
it('renders expected elements for valid props', async () => {
const { findByText, findByPlaceholderText } = render(<OverviewPageComponent />);
const { findByText } = render(<OverviewPageComponent />);
expect(await findByText('No uptime monitors found')).toBeInTheDocument();
expect(await findByPlaceholderText(SIMPLE_SEARCH_PLACEHOLDER)).toBeInTheDocument();
expect(await findByText('QueryStringInput')).toBeInTheDocument();
});
});