) {
return Object.entries(apmIndices)
.map(([key, value]) => [key, value?.trim()])
- .filter(([key, value]) => !!value)
+ .filter(([_, value]) => !!value)
.reduce((obj, [key, value]) => ({ ...obj, [key as string]: value }), {});
}
diff --git a/x-pack/plugins/apm/server/routes/errors.ts b/x-pack/plugins/apm/server/routes/errors.ts
index 7e45f412d4bdb..1615550027d3c 100644
--- a/x-pack/plugins/apm/server/routes/errors.ts
+++ b/x-pack/plugins/apm/server/routes/errors.ts
@@ -12,7 +12,7 @@ import { getErrorGroups } from '../lib/errors/get_error_groups';
import { setupRequest } from '../lib/helpers/setup_request';
import { uiFiltersRt, rangeRt } from './default_api_types';
-export const errorsRoute = createRoute((core) => ({
+export const errorsRoute = createRoute(() => ({
path: '/api/apm/services/{serviceName}/errors',
params: {
path: t.type({
diff --git a/x-pack/plugins/apm/server/routes/service_nodes.ts b/x-pack/plugins/apm/server/routes/service_nodes.ts
index a6e9175fcb651..8721407671825 100644
--- a/x-pack/plugins/apm/server/routes/service_nodes.ts
+++ b/x-pack/plugins/apm/server/routes/service_nodes.ts
@@ -9,7 +9,7 @@ import { setupRequest } from '../lib/helpers/setup_request';
import { getServiceNodes } from '../lib/service_nodes';
import { rangeRt, uiFiltersRt } from './default_api_types';
-export const serviceNodesRoute = createRoute((core) => ({
+export const serviceNodesRoute = createRoute(() => ({
path: '/api/apm/services/{serviceName}/serviceNodes',
params: {
path: t.type({
diff --git a/x-pack/plugins/apm/server/routes/services.ts b/x-pack/plugins/apm/server/routes/services.ts
index 996bfbd9184d1..8672c6c108c4c 100644
--- a/x-pack/plugins/apm/server/routes/services.ts
+++ b/x-pack/plugins/apm/server/routes/services.ts
@@ -17,7 +17,7 @@ import { uiFiltersRt, rangeRt } from './default_api_types';
import { getServiceAnnotations } from '../lib/services/annotations';
import { dateAsStringRt } from '../../common/runtime_types/date_as_string_rt';
-export const servicesRoute = createRoute((core) => ({
+export const servicesRoute = createRoute(() => ({
path: '/api/apm/services',
params: {
query: t.intersection([uiFiltersRt, rangeRt]),
diff --git a/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts
index 6fd864a337165..f5c9cc2adf238 100644
--- a/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts
+++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts
@@ -24,7 +24,7 @@ import {
import { jsonRt } from '../../../common/runtime_types/json_rt';
// get list of configurations
-export const agentConfigurationRoute = createRoute((core) => ({
+export const agentConfigurationRoute = createRoute(() => ({
path: '/api/apm/settings/agent-configuration',
handler: async ({ context, request }) => {
const setup = await setupRequest(context, request);
@@ -137,7 +137,7 @@ export const createOrUpdateAgentConfigurationRoute = createRoute(() => ({
}));
// Lookup single configuration (used by APM Server)
-export const agentConfigurationSearchRoute = createRoute((core) => ({
+export const agentConfigurationSearchRoute = createRoute(() => ({
method: 'POST',
path: '/api/apm/settings/agent-configuration/search',
params: {
diff --git a/x-pack/plugins/apm/server/routes/settings/apm_indices.ts b/x-pack/plugins/apm/server/routes/settings/apm_indices.ts
index 2d5722744f93e..e52ce760e026a 100644
--- a/x-pack/plugins/apm/server/routes/settings/apm_indices.ts
+++ b/x-pack/plugins/apm/server/routes/settings/apm_indices.ts
@@ -34,7 +34,7 @@ export const apmIndicesRoute = createRoute(() => ({
}));
// save ui indices
-export const saveApmIndicesRoute = createRoute((core) => ({
+export const saveApmIndicesRoute = createRoute(() => ({
method: 'POST',
path: '/api/apm/settings/apm-indices/save',
options: {
@@ -50,7 +50,7 @@ export const saveApmIndicesRoute = createRoute((core) => ({
'apm_oss.metricsIndices': t.string,
}),
},
- handler: async ({ context, request }) => {
+ handler: async ({ context }) => {
const { body } = context.params;
const savedObjectsClient = context.core.savedObjects.client;
return await saveApmIndices(savedObjectsClient, body);
diff --git a/x-pack/plugins/apm/server/routes/settings/custom_link.ts b/x-pack/plugins/apm/server/routes/settings/custom_link.ts
index f32840fe08b9c..83c23a75e999d 100644
--- a/x-pack/plugins/apm/server/routes/settings/custom_link.ts
+++ b/x-pack/plugins/apm/server/routes/settings/custom_link.ts
@@ -17,7 +17,7 @@ import { getTransaction } from '../../lib/settings/custom_link/get_transaction';
import { listCustomLinks } from '../../lib/settings/custom_link/list_custom_links';
import { createRoute } from '../create_route';
-export const customLinkTransactionRoute = createRoute((core) => ({
+export const customLinkTransactionRoute = createRoute(() => ({
path: '/api/apm/settings/custom_links/transaction',
params: {
query: filterOptionsRt,
@@ -31,7 +31,7 @@ export const customLinkTransactionRoute = createRoute((core) => ({
},
}));
-export const listCustomLinksRoute = createRoute((core) => ({
+export const listCustomLinksRoute = createRoute(() => ({
path: '/api/apm/settings/custom_links',
params: {
query: filterOptionsRt,
diff --git a/x-pack/plugins/canvas/public/application.tsx b/x-pack/plugins/canvas/public/application.tsx
index 8751d8102ad37..c799f36a283c1 100644
--- a/x-pack/plugins/canvas/public/application.tsx
+++ b/x-pack/plugins/canvas/public/application.tsx
@@ -33,7 +33,7 @@ import { CapabilitiesStrings } from '../i18n';
import { startServices, services } from './services';
// @ts-ignore Untyped local
-import { destroyHistory } from './lib/history_provider';
+import { createHistory, destroyHistory } from './lib/history_provider';
// @ts-ignore Untyped local
import { stopRouter } from './lib/router_provider';
import { initFunctions } from './functions';
@@ -97,6 +97,9 @@ export const initializeCanvas = async (
services.expressions.getService().registerFunction(fn);
}
+ // Re-initialize our history
+ createHistory();
+
// Create Store
const canvasStore = await createStore(coreSetup, setupPlugins);
diff --git a/x-pack/plugins/canvas/public/apps/workpad/workpad_app/workpad_telemetry.tsx b/x-pack/plugins/canvas/public/apps/workpad/workpad_app/workpad_telemetry.tsx
index 47b461f22ad65..3014369d94857 100644
--- a/x-pack/plugins/canvas/public/apps/workpad/workpad_app/workpad_telemetry.tsx
+++ b/x-pack/plugins/canvas/public/apps/workpad/workpad_app/workpad_telemetry.tsx
@@ -69,6 +69,7 @@ export const withUnconnectedElementsLoadedTelemetry = (
) =>
function ElementsLoadedTelemetry(props: ElementsLoadedTelemetryProps) {
const { telemetryElementCounts, workpad, telemetryResolvedArgs, ...other } = props;
+ const { error, pending } = telemetryElementCounts;
const [currentWorkpadId, setWorkpadId] = useState(undefined);
const [hasReported, setHasReported] = useState(false);
@@ -87,27 +88,20 @@ export const withUnconnectedElementsLoadedTelemetry = (
0
);
- if (
- workpadElementCount === 0 ||
- (resolvedArgsAreForWorkpad && telemetryElementCounts.pending === 0)
- ) {
+ if (workpadElementCount === 0 || (resolvedArgsAreForWorkpad && pending === 0)) {
setHasReported(true);
} else {
setHasReported(false);
}
- } else if (
- !hasReported &&
- telemetryElementCounts.pending === 0 &&
- resolvedArgsAreForWorkpad
- ) {
- if (telemetryElementCounts.error > 0) {
+ } else if (!hasReported && pending === 0 && resolvedArgsAreForWorkpad) {
+ if (error > 0) {
trackMetric(METRIC_TYPE.LOADED, [WorkpadLoadedMetric, WorkpadLoadedWithErrorsMetric]);
} else {
trackMetric(METRIC_TYPE.LOADED, WorkpadLoadedMetric);
}
setHasReported(true);
}
- });
+ }, [currentWorkpadId, hasReported, error, pending, telemetryResolvedArgs, workpad]);
return ;
};
diff --git a/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset.examples.storyshot b/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset.examples.storyshot
index 6601f570209e9..14791cd3d8b25 100644
--- a/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset.examples.storyshot
+++ b/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset.examples.storyshot
@@ -63,6 +63,7 @@ exports[`Storyshots components/Assets/Asset airplane 1`] = `
>
@@ -88,6 +89,7 @@ exports[`Storyshots components/Assets/Asset airplane 1`] = `
>
@@ -118,6 +120,7 @@ exports[`Storyshots components/Assets/Asset airplane 1`] = `
>
@@ -148,6 +151,7 @@ exports[`Storyshots components/Assets/Asset airplane 1`] = `
>
@@ -237,6 +241,7 @@ exports[`Storyshots components/Assets/Asset marker 1`] = `
>
@@ -262,6 +267,7 @@ exports[`Storyshots components/Assets/Asset marker 1`] = `
>
@@ -292,6 +298,7 @@ exports[`Storyshots components/Assets/Asset marker 1`] = `
>
@@ -322,6 +329,7 @@ exports[`Storyshots components/Assets/Asset marker 1`] = `
>
diff --git a/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset_manager.stories.storyshot b/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset_manager.stories.storyshot
index aff630b21c770..1b8f1480759f6 100644
--- a/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset_manager.stories.storyshot
+++ b/x-pack/plugins/canvas/public/components/asset_manager/__examples__/__snapshots__/asset_manager.stories.storyshot
@@ -422,6 +422,7 @@ Array [
>
@@ -447,6 +448,7 @@ Array [
>
@@ -477,6 +479,7 @@ Array [
>
@@ -507,6 +510,7 @@ Array [
>
@@ -585,6 +589,7 @@ Array [
>
@@ -610,6 +615,7 @@ Array [
>
@@ -640,6 +646,7 @@ Array [
>
@@ -670,6 +677,7 @@ Array [
>
diff --git a/x-pack/plugins/canvas/public/components/router/index.ts b/x-pack/plugins/canvas/public/components/router/index.ts
index 5e014870f5158..fa857c6f0cd3c 100644
--- a/x-pack/plugins/canvas/public/components/router/index.ts
+++ b/x-pack/plugins/canvas/public/components/router/index.ts
@@ -11,7 +11,6 @@ import {
enableAutoplay,
setRefreshInterval,
setAutoplayInterval,
- // @ts-ignore untyped local
} from '../../state/actions/workpad';
// @ts-ignore untyped local
import { Router as Component } from './router';
diff --git a/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_controls.stories.storyshot b/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_controls.stories.storyshot
index 6f12f68356467..408b0679c415f 100644
--- a/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_controls.stories.storyshot
+++ b/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_controls.stories.storyshot
@@ -16,6 +16,7 @@ exports[`Storyshots components/SavedElementsModal/ElementControls has two button
>
@@ -42,6 +43,7 @@ exports[`Storyshots components/SavedElementsModal/ElementControls has two button
>
diff --git a/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_grid.stories.storyshot b/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_grid.stories.storyshot
index be0fb0573c394..1c506819df1fb 100644
--- a/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_grid.stories.storyshot
+++ b/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/element_grid.stories.storyshot
@@ -66,6 +66,7 @@ exports[`Storyshots components/SavedElementsModal/ElementGrid default 1`] = `
>
@@ -92,6 +93,7 @@ exports[`Storyshots components/SavedElementsModal/ElementGrid default 1`] = `
>
@@ -170,6 +172,7 @@ exports[`Storyshots components/SavedElementsModal/ElementGrid default 1`] = `
>
@@ -196,6 +199,7 @@ exports[`Storyshots components/SavedElementsModal/ElementGrid default 1`] = `
>
@@ -274,6 +278,7 @@ exports[`Storyshots components/SavedElementsModal/ElementGrid default 1`] = `
>
@@ -300,6 +305,7 @@ exports[`Storyshots components/SavedElementsModal/ElementGrid default 1`] = `
>
diff --git a/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/saved_elements_modal.stories.storyshot b/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/saved_elements_modal.stories.storyshot
index 03093b41300b8..04b2184f27462 100644
--- a/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/saved_elements_modal.stories.storyshot
+++ b/x-pack/plugins/canvas/public/components/saved_elements_modal/__examples__/__snapshots__/saved_elements_modal.stories.storyshot
@@ -362,6 +362,7 @@ Array [
>
@@ -388,6 +389,7 @@ Array [
>
@@ -466,6 +468,7 @@ Array [
>
@@ -492,6 +495,7 @@ Array [
>
@@ -570,6 +574,7 @@ Array [
>
@@ -596,6 +601,7 @@ Array [
>
@@ -851,6 +857,7 @@ Array [
>
@@ -877,6 +884,7 @@ Array [
>
diff --git a/x-pack/plugins/canvas/public/components/sidebar_header/__examples__/__snapshots__/sidebar_header.stories.storyshot b/x-pack/plugins/canvas/public/components/sidebar_header/__examples__/__snapshots__/sidebar_header.stories.storyshot
index 4d5b9570ee20f..16263aa7ea384 100644
--- a/x-pack/plugins/canvas/public/components/sidebar_header/__examples__/__snapshots__/sidebar_header.stories.storyshot
+++ b/x-pack/plugins/canvas/public/components/sidebar_header/__examples__/__snapshots__/sidebar_header.stories.storyshot
@@ -55,6 +55,7 @@ exports[`Storyshots components/Sidebar/SidebarHeader with layer controls 1`] = `
>
@@ -80,6 +81,7 @@ exports[`Storyshots components/Sidebar/SidebarHeader with layer controls 1`] = `
>
@@ -105,6 +107,7 @@ exports[`Storyshots components/Sidebar/SidebarHeader with layer controls 1`] = `
>
@@ -130,6 +133,7 @@ exports[`Storyshots components/Sidebar/SidebarHeader with layer controls 1`] = `
>
diff --git a/x-pack/plugins/canvas/public/components/workpad_color_picker/index.ts b/x-pack/plugins/canvas/public/components/workpad_color_picker/index.ts
index c6dddab3b5dd1..abd40731078ec 100644
--- a/x-pack/plugins/canvas/public/components/workpad_color_picker/index.ts
+++ b/x-pack/plugins/canvas/public/components/workpad_color_picker/index.ts
@@ -5,7 +5,6 @@
*/
import { connect } from 'react-redux';
-// @ts-ignore
import { addColor, removeColor } from '../../state/actions/workpad';
import { getWorkpadColors } from '../../state/selectors/workpad';
diff --git a/x-pack/plugins/canvas/public/components/workpad_config/index.js b/x-pack/plugins/canvas/public/components/workpad_config/index.ts
similarity index 63%
rename from x-pack/plugins/canvas/public/components/workpad_config/index.js
rename to x-pack/plugins/canvas/public/components/workpad_config/index.ts
index 913cf7093e726..e417821fd4f67 100644
--- a/x-pack/plugins/canvas/public/components/workpad_config/index.js
+++ b/x-pack/plugins/canvas/public/components/workpad_config/index.ts
@@ -7,28 +7,29 @@
import { connect } from 'react-redux';
import { get } from 'lodash';
-import { sizeWorkpad, setName, setWorkpadCSS } from '../../state/actions/workpad';
+import { sizeWorkpad as setSize, setName, setWorkpadCSS } from '../../state/actions/workpad';
import { getWorkpad } from '../../state/selectors/workpad';
import { DEFAULT_WORKPAD_CSS } from '../../../common/lib/constants';
import { WorkpadConfig as Component } from './workpad_config';
+import { State } from '../../../types';
-const mapStateToProps = (state) => {
+const mapStateToProps = (state: State) => {
const workpad = getWorkpad(state);
return {
- name: get(workpad, 'name'),
+ name: get(workpad, 'name'),
size: {
- width: get(workpad, 'width'),
- height: get(workpad, 'height'),
+ width: get(workpad, 'width'),
+ height: get(workpad, 'height'),
},
- css: get(workpad, 'css', DEFAULT_WORKPAD_CSS),
+ css: get(workpad, 'css', DEFAULT_WORKPAD_CSS),
};
};
const mapDispatchToProps = {
- setSize: (size) => sizeWorkpad(size),
- setName: (name) => setName(name),
- setWorkpadCSS: (css) => setWorkpadCSS(css),
+ setSize,
+ setName,
+ setWorkpadCSS,
};
export const WorkpadConfig = connect(mapStateToProps, mapDispatchToProps)(Component);
diff --git a/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.js b/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.js
deleted file mode 100644
index 45758c9965653..0000000000000
--- a/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.js
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import React, { PureComponent } from 'react';
-import PropTypes from 'prop-types';
-import {
- EuiFieldText,
- EuiFieldNumber,
- EuiBadge,
- EuiButtonIcon,
- EuiFormRow,
- EuiFlexGroup,
- EuiFlexItem,
- EuiSpacer,
- EuiTitle,
- EuiToolTip,
- EuiTextArea,
- EuiAccordion,
- EuiText,
- EuiButton,
-} from '@elastic/eui';
-import { DEFAULT_WORKPAD_CSS } from '../../../common/lib/constants';
-import { ComponentStrings } from '../../../i18n';
-
-const { WorkpadConfig: strings } = ComponentStrings;
-
-export class WorkpadConfig extends PureComponent {
- static propTypes = {
- size: PropTypes.object.isRequired,
- name: PropTypes.string.isRequired,
- css: PropTypes.string,
- setSize: PropTypes.func.isRequired,
- setName: PropTypes.func.isRequired,
- setWorkpadCSS: PropTypes.func.isRequired,
- };
-
- state = {
- css: this.props.css,
- };
-
- render() {
- const { size, name, setSize, setName, setWorkpadCSS } = this.props;
- const { css } = this.state;
- const rotate = () => setSize({ width: size.height, height: size.width });
-
- const badges = [
- {
- name: '1080p',
- size: { height: 1080, width: 1920 },
- },
- {
- name: '720p',
- size: { height: 720, width: 1280 },
- },
- {
- name: 'A4',
- size: { height: 842, width: 590 },
- },
- {
- name: strings.getUSLetterButtonLabel(),
- size: { height: 792, width: 612 },
- },
- ];
-
- return (
-
-
-
- {strings.getTitle()}
-
-
-
-
-
-
- setName(e.target.value)} />
-
-
-
-
-
-
-
- setSize({ width: Number(e.target.value), height: size.height })}
- value={size.width}
- />
-
-
-
-
-
-
-
-
-
-
-
- setSize({ height: Number(e.target.value), width: size.width })}
- value={size.height}
- />
-
-
-
-
-
-
-
- {badges.map((badge, i) => (
- setSize(badge.size)}
- aria-label={strings.getPageSizeBadgeAriaLabel(badge.name)}
- onClickAriaLabel={strings.getPageSizeBadgeOnClickAriaLabel(badge.name)}
- >
- {badge.name}
-
- ))}
-
-
-
-
-
-
- {strings.getGlobalCSSLabel()}
-
-
- }
- >
-
- this.setState({ css: e.target.value })}
- rows={10}
- />
-
- setWorkpadCSS(css || DEFAULT_WORKPAD_CSS)}>
- {strings.getApplyStylesheetButtonLabel()}
-
-
-
-
-
-
- );
- }
-}
diff --git a/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.tsx b/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.tsx
new file mode 100644
index 0000000000000..7b7a1e08b2c5d
--- /dev/null
+++ b/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.tsx
@@ -0,0 +1,175 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import React, { FunctionComponent, useState } from 'react';
+import PropTypes from 'prop-types';
+import {
+ EuiFieldText,
+ EuiFieldNumber,
+ EuiBadge,
+ EuiButtonIcon,
+ EuiFormRow,
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+ EuiTitle,
+ EuiToolTip,
+ EuiTextArea,
+ EuiAccordion,
+ EuiText,
+ EuiButton,
+} from '@elastic/eui';
+import { DEFAULT_WORKPAD_CSS } from '../../../common/lib/constants';
+import { ComponentStrings } from '../../../i18n';
+
+const { WorkpadConfig: strings } = ComponentStrings;
+
+interface Props {
+ size: {
+ height: number;
+ width: number;
+ };
+ name: string;
+ css?: string;
+ setSize: ({ height, width }: { height: number; width: number }) => void;
+ setName: (name: string) => void;
+ setWorkpadCSS: (css: string) => void;
+}
+
+export const WorkpadConfig: FunctionComponent = (props) => {
+ const [css, setCSS] = useState(props.css);
+ const { size, name, setSize, setName, setWorkpadCSS } = props;
+ const rotate = () => setSize({ width: size.height, height: size.width });
+
+ const badges = [
+ {
+ name: '1080p',
+ size: { height: 1080, width: 1920 },
+ },
+ {
+ name: '720p',
+ size: { height: 720, width: 1280 },
+ },
+ {
+ name: 'A4',
+ size: { height: 842, width: 590 },
+ },
+ {
+ name: strings.getUSLetterButtonLabel(),
+ size: { height: 792, width: 612 },
+ },
+ ];
+
+ return (
+
+
+
+ {strings.getTitle()}
+
+
+
+
+
+
+ setName(e.target.value)} />
+
+
+
+
+
+
+
+ setSize({ width: Number(e.target.value), height: size.height })}
+ value={size.width}
+ />
+
+
+
+
+
+
+
+
+
+
+
+ setSize({ height: Number(e.target.value), width: size.width })}
+ value={size.height}
+ />
+
+
+
+
+
+
+
+ {badges.map((badge, i) => (
+ setSize(badge.size)}
+ aria-label={strings.getPageSizeBadgeAriaLabel(badge.name)}
+ onClickAriaLabel={strings.getPageSizeBadgeOnClickAriaLabel(badge.name)}
+ >
+ {badge.name}
+
+ ))}
+
+
+
+
+
+
+ {strings.getGlobalCSSLabel()}
+
+
+ }
+ >
+
+ setCSS(e.target.value)}
+ rows={10}
+ />
+
+ setWorkpadCSS(css || DEFAULT_WORKPAD_CSS)}>
+ {strings.getApplyStylesheetButtonLabel()}
+
+
+
+
+
+
+ );
+};
+
+WorkpadConfig.propTypes = {
+ size: PropTypes.object.isRequired,
+ name: PropTypes.string.isRequired,
+ css: PropTypes.string,
+ setSize: PropTypes.func.isRequired,
+ setName: PropTypes.func.isRequired,
+ setWorkpadCSS: PropTypes.func.isRequired,
+};
diff --git a/x-pack/plugins/canvas/public/components/workpad_header/view_menu/index.ts b/x-pack/plugins/canvas/public/components/workpad_header/view_menu/index.ts
index e561607cb101e..0765973915f77 100644
--- a/x-pack/plugins/canvas/public/components/workpad_header/view_menu/index.ts
+++ b/x-pack/plugins/canvas/public/components/workpad_header/view_menu/index.ts
@@ -14,13 +14,11 @@ import { State, CanvasWorkpadBoundingBox } from '../../../../types';
import { fetchAllRenderables } from '../../../state/actions/elements';
// @ts-ignore Untyped local
import { setZoomScale, setFullscreen, selectToplevelNodes } from '../../../state/actions/transient';
-// @ts-ignore Untyped local
import {
setWriteable,
setRefreshInterval,
enableAutoplay,
setAutoplayInterval,
- // @ts-ignore Untyped local
} from '../../../state/actions/workpad';
import { getZoomScale, canUserWrite } from '../../../state/selectors/app';
import {
@@ -75,7 +73,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
},
doRefresh: () => dispatch(fetchAllRenderables()),
setRefreshInterval: (interval: number) => dispatch(setRefreshInterval(interval)),
- enableAutoplay: (autoplay: number) => dispatch(enableAutoplay(autoplay)),
+ enableAutoplay: (autoplay: number) => dispatch(enableAutoplay(!!autoplay)),
setAutoplayInterval: (interval: number) => dispatch(setAutoplayInterval(interval)),
});
diff --git a/x-pack/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot b/x-pack/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot
index 14466cab1a698..f8583d7cd0dc0 100644
--- a/x-pack/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot
+++ b/x-pack/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot
@@ -169,6 +169,7 @@ exports[`Storyshots arguments/SeriesStyle/components simple: no series 1`] = `
>
diff --git a/x-pack/plugins/canvas/public/lib/create_thunk.ts b/x-pack/plugins/canvas/public/lib/create_thunk.ts
new file mode 100644
index 0000000000000..cbcaeeccc8b93
--- /dev/null
+++ b/x-pack/plugins/canvas/public/lib/create_thunk.ts
@@ -0,0 +1,23 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { Dispatch, Action } from 'redux';
+// @ts-ignore untyped dependency
+import { createThunk as createThunkFn } from 'redux-thunks/cjs';
+import { State } from '../../types';
+
+type CreateThunk = (
+ type: string,
+ fn: (
+ params: { type: string; dispatch: Dispatch; getState: () => State },
+ ...args: Arguments
+ ) => void
+) => (...args: Arguments) => Action;
+
+// This declaration exists because redux-thunks is not typed, and has a dependency on
+// Canvas State. Therefore, creating a wrapper that strongly-types the function-- and creates
+// a single point of replacement, should the need arise-- is a nice workaround.
+export const createThunk = createThunkFn as CreateThunk;
diff --git a/x-pack/plugins/canvas/public/lib/history_provider.js b/x-pack/plugins/canvas/public/lib/history_provider.js
index 649f101126012..396372eeb85c1 100644
--- a/x-pack/plugins/canvas/public/lib/history_provider.js
+++ b/x-pack/plugins/canvas/public/lib/history_provider.js
@@ -134,7 +134,7 @@ function wrapHistoryInstance(history) {
return wrappedHistory;
}
-let instances = new WeakMap();
+const instances = new WeakMap();
const getHistoryInstance = (win) => {
// if no window object, use memory module
@@ -144,6 +144,15 @@ const getHistoryInstance = (win) => {
return createHashStateHistory();
};
+export const createHistory = (win = getWindow()) => {
+ // create and cache wrapped history instance
+ const historyInstance = getHistoryInstance(win);
+ const wrappedInstance = wrapHistoryInstance(historyInstance);
+ instances.set(win, wrappedInstance);
+
+ return wrappedInstance;
+};
+
export const historyProvider = (win = getWindow()) => {
// return cached instance if one exists
const instance = instances.get(win);
@@ -151,14 +160,13 @@ export const historyProvider = (win = getWindow()) => {
return instance;
}
- // create and cache wrapped history instance
- const historyInstance = getHistoryInstance(win);
- const wrappedInstance = wrapHistoryInstance(historyInstance);
- instances.set(win, wrappedInstance);
-
- return wrappedInstance;
+ return createHistory(win);
};
-export const destroyHistory = () => {
- instances = new WeakMap();
+export const destroyHistory = (win = getWindow()) => {
+ const instance = instances.get(win);
+
+ if (instance) {
+ instance.resetOnChange();
+ }
};
diff --git a/x-pack/plugins/canvas/public/state/actions/elements.js b/x-pack/plugins/canvas/public/state/actions/elements.js
index 47fbc782f90d3..e89e62917da39 100644
--- a/x-pack/plugins/canvas/public/state/actions/elements.js
+++ b/x-pack/plugins/canvas/public/state/actions/elements.js
@@ -5,10 +5,10 @@
*/
import { createAction } from 'redux-actions';
-import { createThunk } from 'redux-thunks/cjs';
import immutable from 'object-path-immutable';
import { get, pick, cloneDeep, without } from 'lodash';
import { toExpression, safeElementFromExpression } from '@kbn/interpreter/common';
+import { createThunk } from '../../lib/create_thunk';
import { getPages, getNodeById, getNodes, getSelectedPageIndex } from '../selectors/workpad';
import { getValue as getResolvedArgsValue } from '../selectors/resolved_args';
import { getDefaultElement } from '../defaults';
diff --git a/x-pack/plugins/canvas/public/state/actions/embeddable.ts b/x-pack/plugins/canvas/public/state/actions/embeddable.ts
index e2cf588ec20a9..a153cb7f4354d 100644
--- a/x-pack/plugins/canvas/public/state/actions/embeddable.ts
+++ b/x-pack/plugins/canvas/public/state/actions/embeddable.ts
@@ -6,8 +6,7 @@
import { Dispatch } from 'redux';
import { createAction } from 'redux-actions';
-// @ts-ignore Untyped
-import { createThunk } from 'redux-thunks';
+import { createThunk } from '../../lib/create_thunk';
// @ts-ignore Untyped Local
import { fetchRenderable } from './elements';
import { State } from '../../../types';
diff --git a/x-pack/plugins/canvas/public/state/actions/workpad.js b/x-pack/plugins/canvas/public/state/actions/workpad.ts
similarity index 54%
rename from x-pack/plugins/canvas/public/state/actions/workpad.js
rename to x-pack/plugins/canvas/public/state/actions/workpad.ts
index 167c156dce998..47df38838f890 100644
--- a/x-pack/plugins/canvas/public/state/actions/workpad.js
+++ b/x-pack/plugins/canvas/public/state/actions/workpad.ts
@@ -5,26 +5,28 @@
*/
import { createAction } from 'redux-actions';
-import { createThunk } from 'redux-thunks/cjs';
import { without, includes } from 'lodash';
+import { createThunk } from '../../lib/create_thunk';
import { getWorkpadColors } from '../selectors/workpad';
+// @ts-ignore
import { fetchAllRenderables } from './elements';
+import { CanvasWorkpad } from '../../../types';
-export const sizeWorkpad = createAction('sizeWorkpad');
-export const setName = createAction('setName');
-export const setWriteable = createAction('setWriteable');
-export const setColors = createAction('setColors');
-export const setRefreshInterval = createAction('setRefreshInterval');
-export const setWorkpadCSS = createAction('setWorkpadCSS');
-export const enableAutoplay = createAction('enableAutoplay');
-export const setAutoplayInterval = createAction('setAutoplayInterval');
-export const resetWorkpad = createAction('resetWorkpad');
+export const sizeWorkpad = createAction<{ height: number; width: number }>('sizeWorkpad');
+export const setName = createAction('setName');
+export const setWriteable = createAction('setWriteable');
+export const setColors = createAction('setColors');
+export const setRefreshInterval = createAction('setRefreshInterval');
+export const setWorkpadCSS = createAction('setWorkpadCSS');
+export const enableAutoplay = createAction('enableAutoplay');
+export const setAutoplayInterval = createAction('setAutoplayInterval');
+export const resetWorkpad = createAction('resetWorkpad');
export const initializeWorkpad = createThunk('initializeWorkpad', ({ dispatch }) => {
dispatch(fetchAllRenderables());
});
-export const addColor = createThunk('addColor', ({ dispatch, getState }, color) => {
+export const addColor = createThunk('addColor', ({ dispatch, getState }, color: string) => {
const colors = getWorkpadColors(getState()).slice(0);
if (!includes(colors, color)) {
colors.push(color);
@@ -32,16 +34,20 @@ export const addColor = createThunk('addColor', ({ dispatch, getState }, color)
dispatch(setColors(colors));
});
-export const removeColor = createThunk('removeColor', ({ dispatch, getState }, color) => {
+export const removeColor = createThunk('removeColor', ({ dispatch, getState }, color: string) => {
dispatch(setColors(without(getWorkpadColors(getState()), color)));
});
export const setWorkpad = createThunk(
'setWorkpad',
- ({ dispatch, type }, workpad, { loadPages = true } = {}) => {
+ (
+ { dispatch, type },
+ workpad: CanvasWorkpad,
+ { loadPages = true }: { loadPages?: boolean } = {}
+ ) => {
dispatch(createAction(type)(workpad)); // set the workpad object in state
if (loadPages) {
dispatch(initializeWorkpad());
- } // load all the elements on the workpad
+ }
}
);
diff --git a/x-pack/plugins/data_enhanced/public/plugin.ts b/x-pack/plugins/data_enhanced/public/plugin.ts
index 72e0817eea8df..879c73587ed96 100644
--- a/x-pack/plugins/data_enhanced/public/plugin.ts
+++ b/x-pack/plugins/data_enhanced/public/plugin.ts
@@ -29,19 +29,20 @@ export interface DataEnhancedStartDependencies {
export type DataEnhancedSetup = ReturnType;
export type DataEnhancedStart = ReturnType;
-export class DataEnhancedPlugin implements Plugin {
- constructor() {}
-
- public setup(core: CoreSetup, { data }: DataEnhancedSetupDependencies) {
+export class DataEnhancedPlugin
+ implements Plugin {
+ public setup(
+ core: CoreSetup,
+ { data }: DataEnhancedSetupDependencies
+ ) {
data.autocomplete.addQuerySuggestionProvider(
KUERY_LANGUAGE_NAME,
setupKqlQuerySuggestionProvider(core)
);
- data.search.registerSearchStrategyProvider(ASYNC_SEARCH_STRATEGY, asyncSearchStrategyProvider);
- data.search.registerSearchStrategyProvider(
- ES_SEARCH_STRATEGY,
- enhancedEsSearchStrategyProvider
- );
+ const asyncSearchStrategy = asyncSearchStrategyProvider(core);
+ const esSearchStrategy = enhancedEsSearchStrategyProvider(core, asyncSearchStrategy);
+ data.search.registerSearchStrategy(ASYNC_SEARCH_STRATEGY, asyncSearchStrategy);
+ data.search.registerSearchStrategy(ES_SEARCH_STRATEGY, esSearchStrategy);
}
public start(core: CoreStart, plugins: DataEnhancedStartDependencies) {
diff --git a/x-pack/plugins/data_enhanced/public/search/async_search_strategy.test.ts b/x-pack/plugins/data_enhanced/public/search/async_search_strategy.test.ts
index 6c635cc5b4489..3013f9966f068 100644
--- a/x-pack/plugins/data_enhanced/public/search/async_search_strategy.test.ts
+++ b/x-pack/plugins/data_enhanced/public/search/async_search_strategy.test.ts
@@ -6,35 +6,37 @@
import { of } from 'rxjs';
import { AbortController } from 'abort-controller';
+import { CoreSetup } from '../../../../../src/core/public';
import { coreMock } from '../../../../../src/core/public/mocks';
+import { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
+import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks';
import { asyncSearchStrategyProvider } from './async_search_strategy';
-import { IAsyncSearchOptions } from './types';
-import { CoreStart } from 'kibana/public';
+import { IAsyncSearchOptions } from '.';
+import { DataEnhancedStartDependencies } from '../plugin';
describe('Async search strategy', () => {
- let mockCoreStart: MockedKeys;
+ let mockCoreSetup: jest.Mocked>;
+ let mockDataStart: jest.Mocked;
const mockSearch = jest.fn();
const mockRequest = { params: {}, serverStrategy: 'foo' };
const mockOptions: IAsyncSearchOptions = { pollInterval: 0 };
beforeEach(() => {
- mockCoreStart = coreMock.createStart();
+ mockCoreSetup = coreMock.createSetup();
+ mockDataStart = dataPluginMock.createStartContract();
+ (mockDataStart.search.getSearchStrategy as jest.Mock).mockReturnValue({ search: mockSearch });
+ mockCoreSetup.getStartServices.mockResolvedValue([
+ undefined as any,
+ { data: mockDataStart },
+ undefined,
+ ]);
mockSearch.mockReset();
});
it('only sends one request if the first response is complete', async () => {
mockSearch.mockReturnValueOnce(of({ id: 1, total: 1, loaded: 1 }));
- const asyncSearch = asyncSearchStrategyProvider({
- core: mockCoreStart,
- getSearchStrategy: jest.fn().mockImplementation(() => {
- return () => {
- return {
- search: mockSearch,
- };
- };
- }),
- });
+ const asyncSearch = asyncSearchStrategyProvider(mockCoreSetup);
await asyncSearch.search(mockRequest, mockOptions).toPromise();
@@ -51,17 +53,7 @@ describe('Async search strategy', () => {
of({ id: 1, total: 2, loaded: 2, is_running: false, is_partial: false })
);
- const asyncSearch = asyncSearchStrategyProvider({
- core: mockCoreStart,
- getSearchStrategy: jest.fn().mockImplementation(() => {
- return () => {
- return {
- search: mockSearch,
- };
- };
- }),
- });
-
+ const asyncSearch = asyncSearchStrategyProvider(mockCoreSetup);
expect(mockSearch).toBeCalledTimes(0);
await asyncSearch.search(mockRequest, mockOptions).toPromise();
@@ -75,17 +67,7 @@ describe('Async search strategy', () => {
.mockReturnValueOnce(of({ id: 1, total: 2, loaded: 2, is_running: false, is_partial: true }))
.mockReturnValueOnce(of({ id: 1, total: 2, loaded: 2, is_running: false, is_partial: true }));
- const asyncSearch = asyncSearchStrategyProvider({
- core: mockCoreStart,
- getSearchStrategy: jest.fn().mockImplementation(() => {
- return () => {
- return {
- search: mockSearch,
- };
- };
- }),
- });
-
+ const asyncSearch = asyncSearchStrategyProvider(mockCoreSetup);
expect(mockSearch).toBeCalledTimes(0);
await asyncSearch
@@ -104,16 +86,7 @@ describe('Async search strategy', () => {
of({ id: 1, total: 2, loaded: 2, is_running: false, is_partial: false })
);
- const asyncSearch = asyncSearchStrategyProvider({
- core: mockCoreStart,
- getSearchStrategy: jest.fn().mockImplementation(() => {
- return () => {
- return {
- search: mockSearch,
- };
- };
- }),
- });
+ const asyncSearch = asyncSearchStrategyProvider(mockCoreSetup);
expect(mockSearch).toBeCalledTimes(0);
@@ -131,16 +104,7 @@ describe('Async search strategy', () => {
of({ id: 1, total: 2, loaded: 2, is_running: false, is_partial: false })
);
- const asyncSearch = asyncSearchStrategyProvider({
- core: mockCoreStart,
- getSearchStrategy: jest.fn().mockImplementation(() => {
- return () => {
- return {
- search: mockSearch,
- };
- };
- }),
- });
+ const asyncSearch = asyncSearchStrategyProvider(mockCoreSetup);
expect(mockSearch).toBeCalledTimes(0);
@@ -157,16 +121,7 @@ describe('Async search strategy', () => {
.mockReturnValueOnce(of({ id: 1, total: 2, loaded: 2 }))
.mockReturnValueOnce(of({ id: 1, total: 2, loaded: 2 }));
- const asyncSearch = asyncSearchStrategyProvider({
- core: mockCoreStart,
- getSearchStrategy: jest.fn().mockImplementation(() => {
- return () => {
- return {
- search: mockSearch,
- };
- };
- }),
- });
+ const asyncSearch = asyncSearchStrategyProvider(mockCoreSetup);
const abortController = new AbortController();
const options = { ...mockOptions, signal: abortController.signal };
@@ -178,7 +133,7 @@ describe('Async search strategy', () => {
} catch (e) {
expect(e.name).toBe('AbortError');
expect(mockSearch).toBeCalledTimes(1);
- expect(mockCoreStart.http.delete).toBeCalled();
+ expect(mockCoreSetup.http.delete).toBeCalled();
}
});
});
diff --git a/x-pack/plugins/data_enhanced/public/search/async_search_strategy.ts b/x-pack/plugins/data_enhanced/public/search/async_search_strategy.ts
index 18b5b976b3c1b..7de4dd28ad3d7 100644
--- a/x-pack/plugins/data_enhanced/public/search/async_search_strategy.ts
+++ b/x-pack/plugins/data_enhanced/public/search/async_search_strategy.ts
@@ -4,17 +4,18 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { EMPTY, fromEvent, NEVER, Observable, throwError, timer } from 'rxjs';
-import { mergeMap, expand, takeUntil } from 'rxjs/operators';
+import { EMPTY, fromEvent, NEVER, throwError, timer, Observable, from } from 'rxjs';
+import { mergeMap, expand, takeUntil, share, flatMap } from 'rxjs/operators';
+import { CoreSetup } from '../../../../../src/core/public';
import { AbortError } from '../../../../../src/plugins/data/common';
import {
- IKibanaSearchResponse,
- ISearchContext,
+ ISearch,
ISearchStrategy,
+ ISyncSearchRequest,
SYNC_SEARCH_STRATEGY,
- TSearchStrategyProvider,
} from '../../../../../src/plugins/data/public';
-import { IAsyncSearchRequest, IAsyncSearchOptions, IAsyncSearchResponse } from './types';
+import { IAsyncSearchOptions, IAsyncSearchResponse, IAsyncSearchRequest } from './types';
+import { DataEnhancedStartDependencies } from '../plugin';
export const ASYNC_SEARCH_STRATEGY = 'ASYNC_SEARCH_STRATEGY';
@@ -24,55 +25,59 @@ declare module '../../../../../src/plugins/data/public' {
}
}
-export const asyncSearchStrategyProvider: TSearchStrategyProvider = (
- context: ISearchContext
-): ISearchStrategy => {
- const syncStrategyProvider = context.getSearchStrategy(SYNC_SEARCH_STRATEGY);
- const { search } = syncStrategyProvider(context);
- return {
- search: (
- request: IAsyncSearchRequest,
- { pollInterval = 1000, ...options }: IAsyncSearchOptions = {}
- ): Observable => {
- const { serverStrategy } = request;
- let id: string | undefined = request.id;
+export function asyncSearchStrategyProvider(
+ core: CoreSetup
+): ISearchStrategy {
+ const startServices$ = from(core.getStartServices()).pipe(share());
- const aborted$ = options.signal
- ? fromEvent(options.signal, 'abort').pipe(
- mergeMap(() => {
- // If we haven't received the response to the initial request, including the ID, then
- // we don't need to send a follow-up request to delete this search. Otherwise, we
- // send the follow-up request to delete this search, then throw an abort error.
- if (id !== undefined) {
- context.core.http.delete(`/internal/search/${request.serverStrategy}/${id}`);
- }
- return throwError(new AbortError());
- })
- )
- : NEVER;
+ const search: ISearch = (
+ request: ISyncSearchRequest,
+ { pollInterval = 1000, ...options }: IAsyncSearchOptions = {}
+ ) => {
+ const { serverStrategy } = request;
+ let { id } = request;
- return search(request, options).pipe(
- expand((response: IAsyncSearchResponse) => {
- // If the response indicates of an error, stop polling and complete the observable
- if (!response || (response.is_partial && !response.is_running)) {
+ const aborted$ = options.signal
+ ? fromEvent(options.signal, 'abort').pipe(
+ mergeMap(() => {
+ // If we haven't received the response to the initial request, including the ID, then
+ // we don't need to send a follow-up request to delete this search. Otherwise, we
+ // send the follow-up request to delete this search, then throw an abort error.
+ if (id !== undefined) {
+ core.http.delete(`/internal/search/${request.serverStrategy}/${id}`);
+ }
return throwError(new AbortError());
- }
+ })
+ )
+ : NEVER;
+
+ return startServices$.pipe(
+ flatMap((startServices) => {
+ const syncSearch = startServices[1].data.search.getSearchStrategy(SYNC_SEARCH_STRATEGY);
+ return (syncSearch.search(request, options) as Observable).pipe(
+ expand((response) => {
+ // If the response indicates of an error, stop polling and complete the observable
+ if (!response || (response.is_partial && !response.is_running)) {
+ return throwError(new AbortError());
+ }
- // If the response indicates it is complete, stop polling and complete the observable
- if (!response.is_running) return EMPTY;
+ // If the response indicates it is complete, stop polling and complete the observable
+ if (!response.is_running) return EMPTY;
- id = response.id;
+ id = response.id;
- // Delay by the given poll interval
- return timer(pollInterval).pipe(
- // Send future requests using just the ID from the response
- mergeMap(() => {
- return search({ id, serverStrategy }, options);
- })
- );
- }),
- takeUntil(aborted$)
- );
- },
+ // Delay by the given poll interval
+ return timer(pollInterval).pipe(
+ // Send future requests using just the ID from the response
+ mergeMap(() => {
+ return search({ id, serverStrategy }, options);
+ })
+ );
+ }),
+ takeUntil(aborted$)
+ );
+ })
+ );
};
-};
+ return { search };
+}
diff --git a/x-pack/plugins/data_enhanced/public/search/es_search_strategy.test.ts b/x-pack/plugins/data_enhanced/public/search/es_search_strategy.test.ts
new file mode 100644
index 0000000000000..5d6bd53e2c945
--- /dev/null
+++ b/x-pack/plugins/data_enhanced/public/search/es_search_strategy.test.ts
@@ -0,0 +1,35 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { CoreSetup } from '../../../../../src/core/public';
+import { coreMock } from '../../../../../src/core/public/mocks';
+import { ES_SEARCH_STRATEGY } from '../../../../../src/plugins/data/common';
+import { enhancedEsSearchStrategyProvider } from './es_search_strategy';
+import { IAsyncSearchOptions } from '.';
+
+describe('Enhanced ES search strategy', () => {
+ let mockCoreSetup: jest.Mocked;
+ const mockSearch = { search: jest.fn() };
+
+ beforeEach(() => {
+ mockCoreSetup = coreMock.createSetup();
+ mockSearch.search.mockClear();
+ });
+
+ it('returns a strategy with `search` that calls the async search `search`', () => {
+ const request = { params: {} };
+ const options: IAsyncSearchOptions = { pollInterval: 0 };
+
+ const esSearch = enhancedEsSearchStrategyProvider(mockCoreSetup, mockSearch);
+ esSearch.search(request, options);
+
+ expect(mockSearch.search.mock.calls[0][0]).toEqual({
+ ...request,
+ serverStrategy: ES_SEARCH_STRATEGY,
+ });
+ expect(mockSearch.search.mock.calls[0][1]).toEqual(options);
+ });
+});
diff --git a/x-pack/plugins/data_enhanced/public/search/es_search_strategy.ts b/x-pack/plugins/data_enhanced/public/search/es_search_strategy.ts
index 3a511c7b5a176..c4b293a52a104 100644
--- a/x-pack/plugins/data_enhanced/public/search/es_search_strategy.ts
+++ b/x-pack/plugins/data_enhanced/public/search/es_search_strategy.ts
@@ -5,42 +5,40 @@
*/
import { Observable } from 'rxjs';
+import { CoreSetup } from '../../../../../src/core/public';
import { ES_SEARCH_STRATEGY, IEsSearchResponse } from '../../../../../src/plugins/data/common';
import {
- TSearchStrategyProvider,
- ISearchContext,
ISearch,
getEsPreference,
+ ISearchStrategy,
UI_SETTINGS,
} from '../../../../../src/plugins/data/public';
import { IEnhancedEsSearchRequest, EnhancedSearchParams } from '../../common';
import { ASYNC_SEARCH_STRATEGY } from './async_search_strategy';
import { IAsyncSearchOptions } from './types';
-export const enhancedEsSearchStrategyProvider: TSearchStrategyProvider