From 795204d9b3bd06706d8be8574e13898f5e3be40e Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 19 Mar 2020 11:44:11 +0100 Subject: [PATCH 1/3] [ML] Fix pivot preview. --- .../components/pivot_preview/use_pivot_preview_data.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts b/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts index c3ccddbfc2906e..51f2b7a656cfdb 100644 --- a/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts +++ b/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts @@ -47,7 +47,12 @@ export interface UsePivotPreviewDataReturnType { export interface GetTransformsResponse { preview: PreviewData; - mappings: PreviewMappings; + generated_dest_index: { + mappings: PreviewMappings; + // Not in use yet + aliases: any; + settings: any; + }; } export const usePivotPreviewData = ( @@ -79,7 +84,7 @@ export const usePivotPreviewData = ( try { const resp: GetTransformsResponse = await api.getTransformsPreview(previewRequest); setPreviewData(resp.preview); - setPreviewMappings(resp.mappings); + setPreviewMappings(resp.generated_dest_index.mappings); setStatus(PIVOT_PREVIEW_STATUS.LOADED); } catch (e) { setErrorMessage(JSON.stringify(e, null, 2)); From 69d66b96f87897227c7d3294f166f2ef853c32bc Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 19 Mar 2020 11:46:08 +0100 Subject: [PATCH 2/3] [ML] Unskip functional tests. --- x-pack/test/functional/apps/transform/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/transform/index.ts b/x-pack/test/functional/apps/transform/index.ts index 5dcfd876f5b53d..60b72f122f1131 100644 --- a/x-pack/test/functional/apps/transform/index.ts +++ b/x-pack/test/functional/apps/transform/index.ts @@ -8,8 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function({ getService, loadTestFile }: FtrProviderContext) { const transform = getService('transform'); - // prevent test failures with current ES snapshot, see https://github.com/elastic/kibana/issues/60516 - describe.skip('transform', function() { + describe('transform', function() { this.tags(['ciGroup9', 'transform']); before(async () => { From 9b2acf1c6be33615efa7006a477bd91a6faa1fc5 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 19 Mar 2020 12:01:29 +0100 Subject: [PATCH 3/3] [ML] Types cleanup. --- .../transform/public/app/common/index.ts | 1 + .../public/app/common/pivot_preview.ts | 29 +++++++++++++++++++ .../pivot_preview/use_pivot_preview_data.ts | 27 +++-------------- .../transform/public/app/hooks/use_api.ts | 4 +-- 4 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 x-pack/plugins/transform/public/app/common/pivot_preview.ts diff --git a/x-pack/plugins/transform/public/app/common/index.ts b/x-pack/plugins/transform/public/app/common/index.ts index e81fadddbea69f..ee026e2e590a44 100644 --- a/x-pack/plugins/transform/public/app/common/index.ts +++ b/x-pack/plugins/transform/public/app/common/index.ts @@ -36,6 +36,7 @@ export { TRANSFORM_MODE, } from './transform_stats'; export { getDiscoverUrl } from './navigation'; +export { GetTransformsResponse, PreviewData, PreviewMappings } from './pivot_preview'; export { getEsAggFromAggConfig, isPivotAggsConfigWithUiSupport, diff --git a/x-pack/plugins/transform/public/app/common/pivot_preview.ts b/x-pack/plugins/transform/public/app/common/pivot_preview.ts new file mode 100644 index 00000000000000..14368a80b01318 --- /dev/null +++ b/x-pack/plugins/transform/public/app/common/pivot_preview.ts @@ -0,0 +1,29 @@ +/* + * 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 { ES_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; + +import { Dictionary } from '../../../common/types/common'; + +interface EsMappingType { + type: ES_FIELD_TYPES; +} + +export type PreviewItem = Dictionary; +export type PreviewData = PreviewItem[]; +export interface PreviewMappings { + properties: Dictionary; +} + +export interface GetTransformsResponse { + preview: PreviewData; + generated_dest_index: { + mappings: PreviewMappings; + // Not in use yet + aliases: any; + settings: any; + }; +} diff --git a/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts b/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts index 51f2b7a656cfdb..83fa7ba189ff0d 100644 --- a/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts +++ b/x-pack/plugins/transform/public/app/components/pivot_preview/use_pivot_preview_data.ts @@ -9,8 +9,7 @@ import { useEffect, useState } from 'react'; import { dictionaryToArray } from '../../../../common/types/common'; import { useApi } from '../../hooks/use_api'; -import { Dictionary } from '../../../../common/types/common'; -import { IndexPattern, ES_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; +import { IndexPattern } from '../../../../../../../src/plugins/data/public'; import { getPreviewRequestBody, @@ -18,6 +17,8 @@ import { PivotAggsConfigDict, PivotGroupByConfigDict, PivotQuery, + PreviewData, + PreviewMappings, } from '../../common'; export enum PIVOT_PREVIEW_STATUS { @@ -27,16 +28,6 @@ export enum PIVOT_PREVIEW_STATUS { ERROR, } -interface EsMappingType { - type: ES_FIELD_TYPES; -} - -export type PreviewItem = Dictionary; -type PreviewData = PreviewItem[]; -interface PreviewMappings { - properties: Dictionary; -} - export interface UsePivotPreviewDataReturnType { errorMessage: string; status: PIVOT_PREVIEW_STATUS; @@ -45,16 +36,6 @@ export interface UsePivotPreviewDataReturnType { previewRequest: PreviewRequestBody; } -export interface GetTransformsResponse { - preview: PreviewData; - generated_dest_index: { - mappings: PreviewMappings; - // Not in use yet - aliases: any; - settings: any; - }; -} - export const usePivotPreviewData = ( indexPatternTitle: IndexPattern['title'], query: PivotQuery, @@ -82,7 +63,7 @@ export const usePivotPreviewData = ( setStatus(PIVOT_PREVIEW_STATUS.LOADING); try { - const resp: GetTransformsResponse = await api.getTransformsPreview(previewRequest); + const resp = await api.getTransformsPreview(previewRequest); setPreviewData(resp.preview); setPreviewMappings(resp.generated_dest_index.mappings); setStatus(PIVOT_PREVIEW_STATUS.LOADED); diff --git a/x-pack/plugins/transform/public/app/hooks/use_api.ts b/x-pack/plugins/transform/public/app/hooks/use_api.ts index c503051ed90afb..39341dd1add65b 100644 --- a/x-pack/plugins/transform/public/app/hooks/use_api.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_api.ts @@ -8,7 +8,7 @@ import { TransformId, TransformEndpointRequest, TransformEndpointResult } from ' import { API_BASE_PATH } from '../../../common/constants'; import { useAppDependencies } from '../app_dependencies'; -import { PreviewRequestBody } from '../common'; +import { GetTransformsResponse, PreviewRequestBody } from '../common'; import { EsIndex } from './use_api_types'; @@ -37,7 +37,7 @@ export const useApi = () => { body: JSON.stringify(transformsInfo), }); }, - getTransformsPreview(obj: PreviewRequestBody): Promise { + getTransformsPreview(obj: PreviewRequestBody): Promise { return http.post(`${API_BASE_PATH}transforms/_preview`, { body: JSON.stringify(obj) }); }, startTransforms(transformsInfo: TransformEndpointRequest[]): Promise {