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

[unified search] Query string input uses data views plugin directly instead of via deprecated data plugin reference #143611

Merged
merged 10 commits into from
Oct 20, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export const QueryBarTopRow = React.memo(
notifications,
docLinks,
http,
dataViews,
} = kibana.services;

const isQueryLangSelected = props.query && !isOfQueryType(props.query);
Expand Down Expand Up @@ -550,6 +551,7 @@ export const QueryBarTopRow = React.memo(
docLinks,
http,
uiSettings,
dataViews,
}}
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import { compact, debounce, isEmpty, isEqual, isFunction, partition } from 'loda
import { CoreStart, DocLinksStart, Toast } from '@kbn/core/public';
import type { Query } from '@kbn/es-query';
import { DataPublicPluginStart, getQueryLog } from '@kbn/data-plugin/public';
import { type DataView, DataView as KibanaDataView } from '@kbn/data-views-plugin/public';
import {
type DataView,
DataView as KibanaDataView,
DataViewsPublicPluginStart,
} from '@kbn/data-views-plugin/public';
import type { PersistedLog } from '@kbn/data-plugin/public';
import { getFieldSubtypeNested, KIBANA_USER_QUERY_LANGUAGE_KEY } from '@kbn/data-plugin/common';
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
Expand Down Expand Up @@ -61,6 +65,7 @@ export interface QueryStringInputDependencies {
http: CoreStart['http'];
docLinks: DocLinksStart;
uiSettings: CoreStart['uiSettings'];
dataViews: DataViewsPublicPluginStart;
}

export interface QueryStringInputProps {
Expand Down Expand Up @@ -196,7 +201,7 @@ export default class QueryStringInputUI extends PureComponent<QueryStringInputPr
const currentAbortController = this.fetchIndexPatternsAbortController;

const objectPatternsFromStrings = await fetchIndexPatterns(
this.props.deps.data.indexPatterns,
this.props.deps.data.dataViews,
idOrTitlePatterns
);

Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_default_editor/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "visDefaultEditor",
"version": "kibana",
"ui": true,
"requiredPlugins": ["dataViews"],
"optionalPlugins": ["visualizations"],
"requiredBundles": [
"unifiedSearch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function FilterRow({
const { services } = useKibana<VisDefaultEditorKibanaServices>();
const {
data,
dataViews,
unifiedSearch,
usageCollection,
storage,
Expand Down Expand Up @@ -118,6 +119,7 @@ function FilterRow({
size="s"
deps={{
data,
dataViews,
unifiedSearch,
usageCollection,
storage,
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/vis_default_editor/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ 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 { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';

export interface VisDefaultEditorKibanaServices {
data: DataPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
appName: string;
unifiedSearch: {
autocomplete: AutocompleteStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function QueryBarWrapper({
docLinks,
uiSettings,
data,
dataViews,
storage,
usageCollection,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function TraceSearchBox({
error,
loading,
}: Props) {
const { unifiedSearch, core, data } = useApmPluginContext();
const { unifiedSearch, core, data, dataViews } = useApmPluginContext();
const { notifications, http, docLinks, uiSettings } = core;
const {
services: { storage },
Expand Down Expand Up @@ -153,6 +153,7 @@ export function TraceSearchBox({
docLinks,
uiSettings,
data,
dataViews,
storage,
}}
/>
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/.storybook/context/stubs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Stubs =
| 'licensing'
| 'storage'
| 'data'
| 'dataViews'
| 'unifiedSearch'
| 'deprecations'
| 'fatalErrors'
Expand All @@ -24,6 +25,7 @@ export const stubbedStartServices: StubbedStartServices = {
licensing: {} as FleetStartServices['licensing'],
storage: {} as FleetStartServices['storage'],
data: {} as FleetStartServices['data'],
dataViews: {} as FleetStartServices['dataViews'],
unifiedSearch: {} as FleetStartServices['unifiedSearch'],
deprecations: {} as FleetStartServices['deprecations'],
fatalErrors: {} as FleetStartServices['fatalErrors'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const SearchBar: React.FunctionComponent<Props> = ({
}) => {
const {
data,
dataViews,
unifiedSearch,
storage,
notifications,
Expand Down Expand Up @@ -131,6 +132,7 @@ export const SearchBar: React.FunctionComponent<Props> = ({
docLinks,
uiSettings,
data,
dataViews,
storage,
usageCollection,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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 } =
const { data, notifications, http, docLinks, uiSettings, unifiedSearch, storage, dataViews } =
useStartServices();
const [indexPatternFields, setIndexPatternFields] = useState<FieldSpec[]>();

Expand Down Expand Up @@ -81,7 +81,7 @@ 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, storage }}
deps={{ unifiedSearch, notifications, http, docLinks, uiSettings, data, dataViews, storage }}
/>
);
});
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/public/mock/plugin_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
import { cloudMock } from '@kbn/cloud-plugin/public/mocks';
import { homePluginMock } from '@kbn/home-plugin/public/mocks';
Expand All @@ -28,6 +29,7 @@ export const createStartDepsMock = () => {
return {
licensing: licensingMock.createStart(),
data: dataPluginMock.createStartContract(),
dataViews: dataViewPluginMocks.createStartContract(),
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
navigation: navigationPluginMock.createStartContract(),
customIntegrations: customIntegrationsMock.createStart(),
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
import { DEFAULT_APP_CATEGORIES, AppNavLinkStatus } from '@kbn/core/public';

import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import type { LicensingPluginStart } from '@kbn/licensing-plugin/public';
Expand Down Expand Up @@ -96,6 +97,7 @@ export interface FleetSetupDeps {
export interface FleetStartDeps {
licensing: LicensingPluginStart;
data: DataPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
navigation: NavigationPublicPluginStart;
customIntegrations: CustomIntegrationsStart;
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/graph/public/components/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function SearchBarComponent(props: SearchBarStateProps & SearchBarProps)
appName,
unifiedSearch,
data,
dataViews,
storage,
notifications,
http,
Expand Down Expand Up @@ -176,6 +177,7 @@ export function SearchBarComponent(props: SearchBarStateProps & SearchBarProps)
deps={{
unifiedSearch,
data,
dataViews,
storage,
notifications,
http,
Expand Down
13 changes: 11 additions & 2 deletions x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const LogsToolbar = () => {
const { filterQueryDraft, isFilterQueryDraftValid, applyLogFilterQuery, setLogFilterQueryDraft } =
useLogFilterStateContext();
const { setSurroundingLogsId } = useLogEntryFlyoutContext();
const { http, notifications, docLinks, uiSettings, data, storage, unifiedSearch } =
const { http, notifications, docLinks, uiSettings, data, dataViews, storage, unifiedSearch } =
useKibanaContextForPlugin().services;

const {
Expand Down Expand Up @@ -77,7 +77,16 @@ export const LogsToolbar = () => {
appName={i18n.translate('xpack.infra.appName', {
defaultMessage: 'Infra logs',
})}
deps={{ unifiedSearch, notifications, http, docLinks, uiSettings, data, storage }}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
dataViews,
storage,
}}
/>
</QueryBarFlexItem>
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const QueryInput = ({
const { inputValue, handleInputChange } = useDebouncedValue({ value, onChange });
const lensAppServices = useKibana<LensAppServices>().services;

const { data, uiSettings, http, notifications, docLinks, storage, unifiedSearch } =
const { data, uiSettings, http, notifications, docLinks, storage, unifiedSearch, dataViews } =
lensAppServices;

return (
Expand Down Expand Up @@ -74,7 +74,7 @@ export const QueryInput = ({
appName={i18n.translate('xpack.lens.queryInput.appName', {
defaultMessage: 'Lens',
})}
deps={{ unifiedSearch, notifications, http, docLinks, uiSettings, data, storage }}
deps={{ unifiedSearch, notifications, http, docLinks, uiSettings, data, storage, dataViews }}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { CoreStart } from '@kbn/core/public';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { useKibana, KibanaReactContextValue } from '@kbn/kibana-react-plugin/public';
Expand All @@ -27,6 +28,7 @@ import type { MlServicesContext } from '../../app';

interface StartPlugins {
data: DataPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
security?: SecurityPluginSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
share: SharePluginStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
const [errorMessage, setErrorMessage] = useState<ErrorMessage | undefined>(undefined);

const { services } = useMlKibana();
const { unifiedSearch, data, storage, appName, notifications, http, docLinks, uiSettings } =
services;
const {
unifiedSearch,
data,
storage,
appName,
notifications,
http,
docLinks,
uiSettings,
dataViews,
} = services;

const searchChangeHandler = (q: Query) => setSearchInput(q);

Expand Down Expand Up @@ -203,7 +212,16 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
dataTestSubj="mlDFAnalyticsQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
appName={appName}
deps={{ unifiedSearch, notifications, http, docLinks, uiSettings, data, storage }}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
storage,
dataViews,
}}
/>
</EuiFlexItem>
{filters && filters.options && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,17 @@ export const ExplorerQueryBar: FC<ExplorerQueryBarProps> = ({
}) => {
const { anomalyExplorerCommonStateService } = useAnomalyExplorerContext();
const { services } = useMlKibana();
const { unifiedSearch, data, storage, appName, notifications, http, docLinks, uiSettings } =
services;
const {
unifiedSearch,
data,
storage,
appName,
notifications,
http,
docLinks,
uiSettings,
dataViews,
} = services;

// The internal state of the input query bar updated on every key stroke.
const [searchInput, setSearchInput] = useState<Query>(
Expand Down Expand Up @@ -171,7 +180,16 @@ export const ExplorerQueryBar: FC<ExplorerQueryBarProps> = ({
dataTestSubj="explorerQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
appName={appName}
deps={{ unifiedSearch, notifications, http, docLinks, uiSettings, data, storage }}
deps={{
unifiedSearch,
notifications,
http,
docLinks,
uiSettings,
data,
storage,
dataViews,
}}
/>
}
isOpen={errorMessage?.query === searchInput.query && errorMessage?.message !== ''}
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/stack_alerts/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"kibanaReact",
"savedObjects",
"data",
"dataViews",
"kibanaUtils"
],
"configPath": ["xpack", "stack_alerts"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { fromKueryExpression, luceneStringToDsl } from '@kbn/es-query';
import type { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public';
import type { DataView } from '@kbn/data-plugin/common';
import type { DataView, DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { Query } from '@kbn/es-query';
import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
Expand Down Expand Up @@ -45,6 +45,7 @@ const DEFAULT_VALUES = {
interface KibanaDeps {
http: HttpSetup;
docLinks: DocLinksStart;
dataViews: DataViewsPublicPluginStart;
uiSettings: IUiSettingsClient;
notifications: CoreStart['notifications'];
storage: IStorageWrapper;
Expand Down Expand Up @@ -79,7 +80,7 @@ export const GeoContainmentAlertTypeExpression: React.FunctionComponent<
boundaryNameField,
} = ruleParams;

const { http, docLinks, uiSettings, notifications, storage, usageCollection } =
const { http, docLinks, uiSettings, notifications, storage, usageCollection, dataViews } =
useKibana<KibanaDeps>().services;

const [indexPattern, _setIndexPattern] = useState<DataView>({
Expand Down Expand Up @@ -226,6 +227,7 @@ export const GeoContainmentAlertTypeExpression: React.FunctionComponent<
docLinks,
uiSettings,
data,
dataViews,
storage,
usageCollection,
}}
Expand Down Expand Up @@ -281,6 +283,7 @@ export const GeoContainmentAlertTypeExpression: React.FunctionComponent<
docLinks,
uiSettings,
data,
dataViews,
storage,
usageCollection,
}}
Expand Down
Loading