diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index f2af61df73d206..53628ea970fb6f 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -39,7 +39,7 @@ "xpack.snapshotRestore": "plugins/snapshot_restore", "xpack.spaces": ["legacy/plugins/spaces", "plugins/spaces"], "xpack.taskManager": "legacy/plugins/task_manager", - "xpack.transform": ["legacy/plugins/transform", "plugins/transform"], + "xpack.transform": "plugins/transform", "xpack.triggersActionsUI": "plugins/triggers_actions_ui", "xpack.upgradeAssistant": "plugins/upgrade_assistant", "xpack.uptime": "legacy/plugins/uptime", diff --git a/x-pack/legacy/plugins/transform/index.ts b/x-pack/legacy/plugins/transform/index.ts index 10f4732152c43a..a4b980c0bf8f3a 100644 --- a/x-pack/legacy/plugins/transform/index.ts +++ b/x-pack/legacy/plugins/transform/index.ts @@ -4,19 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { resolve } from 'path'; - -import { PLUGIN } from './common/constants'; - export function transform(kibana: any) { return new kibana.Plugin({ - id: PLUGIN.ID, + id: 'transform', configPrefix: 'xpack.transform', - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'xpack_main'], - uiExports: { - styleSheetPaths: resolve(__dirname, 'public/app/index.scss'), - managementSections: ['plugins/transform'], - }, }); } diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_api.ts b/x-pack/legacy/plugins/transform/public/app/hooks/use_api.ts deleted file mode 100644 index b7ce5e5298b2ff..00000000000000 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_api.ts +++ /dev/null @@ -1,102 +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 { useAppDependencies } from '../app_dependencies'; -import { PreviewRequestBody, TransformId } from '../common'; -import { httpFactory, Http } from '../services/http_service'; - -import { EsIndex, TransformEndpointRequest, TransformEndpointResult } from './use_api_types'; - -const apiFactory = (basePath: string, indicesBasePath: string, http: Http) => ({ - getTransforms(transformId?: TransformId): Promise { - const transformIdString = transformId !== undefined ? `/${transformId}` : ''; - return http({ - url: `${basePath}/transforms${transformIdString}`, - method: 'GET', - }); - }, - getTransformsStats(transformId?: TransformId): Promise { - if (transformId !== undefined) { - return http({ - url: `${basePath}/transforms/${transformId}/_stats`, - method: 'GET', - }); - } - - return http({ - url: `${basePath}/transforms/_stats`, - method: 'GET', - }); - }, - createTransform(transformId: TransformId, transformConfig: any): Promise { - return http({ - url: `${basePath}/transforms/${transformId}`, - method: 'PUT', - data: transformConfig, - }); - }, - deleteTransforms(transformsInfo: TransformEndpointRequest[]) { - return http({ - url: `${basePath}/delete_transforms`, - method: 'POST', - data: transformsInfo, - }) as Promise; - }, - getTransformsPreview(obj: PreviewRequestBody): Promise { - return http({ - url: `${basePath}/transforms/_preview`, - method: 'POST', - data: obj, - }); - }, - startTransforms(transformsInfo: TransformEndpointRequest[]) { - return http({ - url: `${basePath}/start_transforms`, - method: 'POST', - data: { - transformsInfo, - }, - }) as Promise; - }, - stopTransforms(transformsInfo: TransformEndpointRequest[]) { - return http({ - url: `${basePath}/stop_transforms`, - method: 'POST', - data: { - transformsInfo, - }, - }) as Promise; - }, - getTransformAuditMessages(transformId: TransformId): Promise { - return http({ - url: `${basePath}/transforms/${transformId}/messages`, - method: 'GET', - }); - }, - esSearch(payload: any) { - return http({ - url: `${basePath}/es_search`, - method: 'POST', - data: payload, - }) as Promise; - }, - getIndices() { - return http({ - url: `${indicesBasePath}/index_management/indices`, - method: 'GET', - }) as Promise; - }, -}); - -export const useApi = () => { - const appDeps = useAppDependencies(); - - const basePath = '/api/transform'; - const indicesBasePath = '/api'; - const http = httpFactory(appDeps.core.http); - - return apiFactory(basePath, indicesBasePath, http); -}; diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_api_types.ts b/x-pack/legacy/plugins/transform/public/app/hooks/use_api_types.ts deleted file mode 100644 index d0f81a058b7b3c..00000000000000 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_api_types.ts +++ /dev/null @@ -1,25 +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 { TransformId, TRANSFORM_STATE } from '../common'; - -export interface EsIndex { - name: string; -} - -export interface TransformEndpointRequest { - id: TransformId; - state?: TRANSFORM_STATE; -} - -export interface ResultData { - success: boolean; - error?: any; -} - -export interface TransformEndpointResult { - [key: string]: ResultData; -} diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.test.tsx b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.test.tsx deleted file mode 100644 index 715573e3a6f67d..00000000000000 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.test.tsx +++ /dev/null @@ -1,66 +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, { FC } from 'react'; -import ReactDOM from 'react-dom'; -import { act } from 'react-dom/test-utils'; - -import { SimpleQuery } from '../../../../common'; -import { - SOURCE_INDEX_STATUS, - useSourceIndexData, - UseSourceIndexDataReturnType, -} from './use_source_index_data'; - -jest.mock('../../../../hooks/use_api'); - -type Callback = () => void; -interface TestHookProps { - callback: Callback; -} - -const TestHook: FC = ({ callback }) => { - callback(); - return null; -}; - -const testHook = (callback: Callback) => { - const container = document.createElement('div'); - document.body.appendChild(container); - act(() => { - ReactDOM.render(, container); - }); -}; - -const query: SimpleQuery = { - query_string: { - query: '*', - default_operator: 'AND', - }, -}; - -let sourceIndexObj: UseSourceIndexDataReturnType; - -describe('useSourceIndexData', () => { - test('indexPattern set triggers loading', () => { - testHook(() => { - act(() => { - sourceIndexObj = useSourceIndexData( - { id: 'the-id', title: 'the-title', fields: [] }, - query, - { pageIndex: 0, pageSize: 10 } - ); - }); - }); - - expect(sourceIndexObj.errorMessage).toBe(''); - expect(sourceIndexObj.status).toBe(SOURCE_INDEX_STATUS.LOADING); - expect(sourceIndexObj.tableItems).toEqual([]); - }); - - // TODO add more tests to check data retrieved via `api.esSearch()`. - // This needs more investigation in regards to jest/enzyme's React Hooks support. -}); diff --git a/x-pack/legacy/plugins/transform/public/app/services/http_service.ts b/x-pack/legacy/plugins/transform/public/app/services/http_service.ts deleted file mode 100644 index b42301433145d0..00000000000000 --- a/x-pack/legacy/plugins/transform/public/app/services/http_service.ts +++ /dev/null @@ -1,51 +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 { HttpSetup } from 'kibana/public'; -// service for interacting with the server -import { Dictionary } from '../../../common/types/common'; - -export type Http = (options: Dictionary) => Promise; - -export function httpFactory(httpSetup: HttpSetup) { - return function http(options: Dictionary) { - return new Promise((resolve, reject) => { - if (options && options.url) { - let url = ''; - url = url + (options.url || ''); - const headers = { - 'Content-Type': 'application/json', - ...options.headers, - }; - - const allHeaders = - options.headers === undefined ? headers : { ...options.headers, ...headers }; - const body = options.data === undefined ? null : JSON.stringify(options.data); - - const payload: Dictionary = { - method: options.method || 'GET', - headers: allHeaders, - credentials: 'same-origin', - }; - - if (body !== null) { - payload.body = body; - } - - httpSetup - .fetch(url, payload) - .then(resp => { - resolve(resp); - }) - .catch(resp => { - reject(resp); - }); - } else { - reject(); - } - }); - }; -} diff --git a/x-pack/legacy/plugins/transform/public/app/services/ui_metric/ui_metric.ts b/x-pack/legacy/plugins/transform/public/app/services/ui_metric/ui_metric.ts deleted file mode 100644 index a2f0a6e1a54821..00000000000000 --- a/x-pack/legacy/plugins/transform/public/app/services/ui_metric/ui_metric.ts +++ /dev/null @@ -1,25 +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 { UIM_APP_NAME } from '../../constants'; -import { - createUiStatsReporter, - METRIC_TYPE, -} from '../../../../../../../../src/legacy/core_plugins/ui_metric/public'; - -class UiMetricService { - track?: ReturnType; - - public init = (getReporter: typeof createUiStatsReporter): void => { - this.track = getReporter(UIM_APP_NAME); - }; - - public trackUiMetric = (eventName: string): void => { - if (!this.track) throw Error('UiMetricService not initialized.'); - return this.track(METRIC_TYPE.COUNT, eventName); - }; -} - -export const uiMetricService = new UiMetricService(); diff --git a/x-pack/legacy/plugins/transform/public/plugin.ts b/x-pack/legacy/plugins/transform/public/plugin.ts deleted file mode 100644 index 7f461a3b03a8b9..00000000000000 --- a/x-pack/legacy/plugins/transform/public/plugin.ts +++ /dev/null @@ -1,80 +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 { i18n } from '@kbn/i18n'; -import { renderApp } from './app/app'; -import { ShimCore, ShimPlugins } from './shim'; - -import { breadcrumbService } from './app/services/navigation'; -import { docTitleService } from './app/services/navigation'; -import { textService } from './app/services/text'; -import { uiMetricService } from './app/services/ui_metric'; - -export class Plugin { - public start(core: ShimCore, plugins: ShimPlugins): void { - const { - http, - chrome, - documentation, - docLinks, - docTitle, - injectedMetadata, - notifications, - uiSettings, - savedObjects, - overlays, - } = core; - const { data, management, uiMetric } = plugins; - - // AppCore/AppPlugins to be passed on as React context - const appDependencies = { - core: { - chrome, - documentation, - docLinks, - http, - i18n: core.i18n, - injectedMetadata, - notifications, - uiSettings, - savedObjects, - overlays, - }, - plugins: { - data, - management, - }, - }; - - // Register management section - const esSection = management.sections.getSection('elasticsearch'); - if (esSection !== undefined) { - esSection.registerApp({ - id: 'transform', - title: i18n.translate('xpack.transform.appTitle', { - defaultMessage: 'Transforms', - }), - order: 3, - mount(params) { - breadcrumbService.setup(params.setBreadcrumbs); - params.setBreadcrumbs([ - { - text: i18n.translate('xpack.transform.breadcrumbsTitle', { - defaultMessage: 'Transforms', - }), - }, - ]); - - return renderApp(params.element, appDependencies); - }, - }); - } - - // Initialize services - textService.init(); - uiMetricService.init(uiMetric.createUiStatsReporter); - docTitleService.init(docTitle.change); - } -} diff --git a/x-pack/legacy/plugins/transform/public/shim.ts b/x-pack/legacy/plugins/transform/public/shim.ts deleted file mode 100644 index 55e45ee3e12cef..00000000000000 --- a/x-pack/legacy/plugins/transform/public/shim.ts +++ /dev/null @@ -1,91 +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 { npStart } from 'ui/new_platform'; - -import { docTitle } from 'ui/doc_title/doc_title'; - -// @ts-ignore: allow traversal to fail on x-pack build -import { createUiStatsReporter } from '../../../../../src/legacy/core_plugins/ui_metric/public'; - -import { TRANSFORM_DOC_PATHS } from './app/constants'; - -export type NpCore = typeof npStart.core; -export type NpPlugins = typeof npStart.plugins; - -// AppCore/AppPlugins is the set of core features/plugins -// we pass on via context/hooks to the app and its components. -export type AppCore = Pick< - ShimCore, - | 'chrome' - | 'documentation' - | 'docLinks' - | 'http' - | 'i18n' - | 'injectedMetadata' - | 'savedObjects' - | 'uiSettings' - | 'overlays' - | 'notifications' ->; -export type AppPlugins = Pick; - -export interface AppDependencies { - core: AppCore; - plugins: AppPlugins; -} - -export interface ShimCore extends NpCore { - documentation: Record< - | 'esDocBasePath' - | 'esIndicesCreateIndex' - | 'esPluginDocBasePath' - | 'esQueryDsl' - | 'esStackOverviewDocBasePath' - | 'esTransform' - | 'esTransformPivot' - | 'mlDocBasePath', - string - >; - docTitle: { - change: typeof docTitle.change; - }; -} - -export interface ShimPlugins extends NpPlugins { - uiMetric: { - createUiStatsReporter: typeof createUiStatsReporter; - }; -} - -export function createPublicShim(): { core: ShimCore; plugins: ShimPlugins } { - const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = npStart.core.docLinks; - - return { - core: { - ...npStart.core, - documentation: { - esDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`, - esIndicesCreateIndex: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/indices-create-index.html#indices-create-index`, - esPluginDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/plugins/${DOC_LINK_VERSION}/`, - esQueryDsl: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/query-dsl.html`, - esStackOverviewDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/elastic-stack-overview/${DOC_LINK_VERSION}/`, - esTransform: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/${TRANSFORM_DOC_PATHS.transforms}`, - esTransformPivot: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/put-transform.html#put-transform-request-body`, - mlDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/`, - }, - docTitle: { - change: docTitle.change, - }, - }, - plugins: { - ...npStart.plugins, - uiMetric: { - createUiStatsReporter, - }, - }, - }; -} diff --git a/x-pack/legacy/plugins/transform/common/constants.ts b/x-pack/plugins/transform/common/constants.ts similarity index 97% rename from x-pack/legacy/plugins/transform/common/constants.ts rename to x-pack/plugins/transform/common/constants.ts index 39138c12c8299e..b01a82dffa04ac 100644 --- a/x-pack/legacy/plugins/transform/common/constants.ts +++ b/x-pack/plugins/transform/common/constants.ts @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; -import { LICENSE_TYPE_BASIC, LicenseType } from '../../../common/constants'; +import { LICENSE_TYPE_BASIC, LicenseType } from '../../../legacy/common/constants'; export const DEFAULT_REFRESH_INTERVAL_MS = 30000; export const MINIMUM_REFRESH_INTERVAL_MS = 1000; diff --git a/x-pack/plugins/transform/common/index.ts b/x-pack/plugins/transform/common/index.ts new file mode 100644 index 00000000000000..d7a791e78b3ab3 --- /dev/null +++ b/x-pack/plugins/transform/common/index.ts @@ -0,0 +1,40 @@ +/* + * 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. + */ + +export interface MissingPrivileges { + [key: string]: string[] | undefined; +} + +export interface Privileges { + hasAllPrivileges: boolean; + missingPrivileges: MissingPrivileges; +} + +export type TransformId = string; + +// reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/transforms/DataFrameTransformStats.java#L243 +export enum TRANSFORM_STATE { + ABORTING = 'aborting', + FAILED = 'failed', + INDEXING = 'indexing', + STARTED = 'started', + STOPPED = 'stopped', + STOPPING = 'stopping', +} + +export interface TransformEndpointRequest { + id: TransformId; + state?: TRANSFORM_STATE; +} + +export interface ResultData { + success: boolean; + error?: any; +} + +export interface TransformEndpointResult { + [key: string]: ResultData; +} diff --git a/x-pack/legacy/plugins/transform/common/types/common.ts b/x-pack/plugins/transform/common/types/common.ts similarity index 100% rename from x-pack/legacy/plugins/transform/common/types/common.ts rename to x-pack/plugins/transform/common/types/common.ts diff --git a/x-pack/legacy/plugins/transform/common/types/messages.ts b/x-pack/plugins/transform/common/types/messages.ts similarity index 100% rename from x-pack/legacy/plugins/transform/common/types/messages.ts rename to x-pack/plugins/transform/common/types/messages.ts diff --git a/x-pack/legacy/plugins/transform/common/utils/date_utils.ts b/x-pack/plugins/transform/common/utils/date_utils.ts similarity index 100% rename from x-pack/legacy/plugins/transform/common/utils/date_utils.ts rename to x-pack/plugins/transform/common/utils/date_utils.ts diff --git a/x-pack/legacy/plugins/transform/common/utils/es_utils.ts b/x-pack/plugins/transform/common/utils/es_utils.ts similarity index 100% rename from x-pack/legacy/plugins/transform/common/utils/es_utils.ts rename to x-pack/plugins/transform/common/utils/es_utils.ts diff --git a/x-pack/legacy/plugins/transform/common/utils/object_utils.ts b/x-pack/plugins/transform/common/utils/object_utils.ts similarity index 100% rename from x-pack/legacy/plugins/transform/common/utils/object_utils.ts rename to x-pack/plugins/transform/common/utils/object_utils.ts diff --git a/x-pack/plugins/transform/kibana.json b/x-pack/plugins/transform/kibana.json index 87e38f83ef6407..391a95853cc16c 100644 --- a/x-pack/plugins/transform/kibana.json +++ b/x-pack/plugins/transform/kibana.json @@ -2,13 +2,15 @@ "id": "transform", "version": "kibana", "server": true, - "ui": false, + "ui": true, "requiredPlugins": [ + "data", "home", "licensing", "management" ], "optionalPlugins": [ + "security", "usageCollection" ], "configPath": ["xpack", "transform"] diff --git a/x-pack/legacy/plugins/transform/public/__mocks__/shared_imports.ts b/x-pack/plugins/transform/public/__mocks__/shared_imports.ts similarity index 82% rename from x-pack/legacy/plugins/transform/public/__mocks__/shared_imports.ts rename to x-pack/plugins/transform/public/__mocks__/shared_imports.ts index d7fca9820e6146..bc8ace2932c0e6 100644 --- a/x-pack/legacy/plugins/transform/public/__mocks__/shared_imports.ts +++ b/x-pack/plugins/transform/public/__mocks__/shared_imports.ts @@ -14,6 +14,6 @@ export const useRequest = jest.fn(() => ({ error: null, data: undefined, })); -export { mlInMemoryTableBasicFactory } from '../../../ml/public/application/components/ml_in_memory_table'; +export { mlInMemoryTableBasicFactory } from '../../../../legacy/plugins/ml/public/application/components/ml_in_memory_table'; export const SORT_DIRECTION = { ASC: 'asc' }; export const KqlFilterBar = jest.fn(() => null); diff --git a/x-pack/legacy/plugins/transform/public/app/app.tsx b/x-pack/plugins/transform/public/app/app.tsx similarity index 97% rename from x-pack/legacy/plugins/transform/public/app/app.tsx rename to x-pack/plugins/transform/public/app/app.tsx index efbaabe447efa5..644aedec3eac08 100644 --- a/x-pack/legacy/plugins/transform/public/app/app.tsx +++ b/x-pack/plugins/transform/public/app/app.tsx @@ -14,7 +14,7 @@ import { SectionError } from './components'; import { CLIENT_BASE_PATH, SECTION_SLUG } from './constants'; import { getAppProviders } from './app_dependencies'; import { AuthorizationContext } from './lib/authorization'; -import { AppDependencies } from '../shim'; +import { AppDependencies } from './app_dependencies'; import { CloneTransformSection } from './sections/clone_transform'; import { CreateTransformSection } from './sections/create_transform'; diff --git a/x-pack/plugins/transform/public/app/app_dependencies.mock.ts b/x-pack/plugins/transform/public/app/app_dependencies.mock.ts new file mode 100644 index 00000000000000..4e5af1eca7bd02 --- /dev/null +++ b/x-pack/plugins/transform/public/app/app_dependencies.mock.ts @@ -0,0 +1,28 @@ +/* + * 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 { coreMock } from '../../../../../src/core/public/mocks'; +import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks'; + +import { getAppProviders, AppDependencies } from './app_dependencies'; + +const coreSetup = coreMock.createSetup(); +const coreStart = coreMock.createStart(); +const dataStart = dataPluginMock.createStartContract(); + +const appDependencies: AppDependencies = { + chrome: coreStart.chrome, + data: dataStart, + docLinks: coreStart.docLinks, + i18n: coreStart.i18n, + notifications: coreStart.notifications, + uiSettings: coreStart.uiSettings, + savedObjects: coreStart.savedObjects, + overlays: coreStart.overlays, + http: coreSetup.http, +}; + +export const Providers = getAppProviders(appDependencies); diff --git a/x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx b/x-pack/plugins/transform/public/app/app_dependencies.tsx similarity index 71% rename from x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx rename to x-pack/plugins/transform/public/app/app_dependencies.tsx index ec1b896249be6f..37258dc777d87d 100644 --- a/x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx +++ b/x-pack/plugins/transform/public/app/app_dependencies.tsx @@ -7,25 +7,39 @@ import React, { createContext, useContext, ReactNode } from 'react'; import { HashRouter } from 'react-router-dom'; +import { CoreSetup, CoreStart } from 'src/core/public'; +import { DataPublicPluginStart } from 'src/plugins/data/public'; + import { API_BASE_PATH } from '../../common/constants'; import { setDependencyCache } from '../shared_imports'; -import { AppDependencies } from '../shim'; import { AuthorizationProvider } from './lib/authorization'; +export interface AppDependencies { + chrome: CoreStart['chrome']; + data: DataPublicPluginStart; + docLinks: CoreStart['docLinks']; + http: CoreSetup['http']; + i18n: CoreStart['i18n']; + notifications: CoreStart['notifications']; + uiSettings: CoreStart['uiSettings']; + savedObjects: CoreStart['savedObjects']; + overlays: CoreStart['overlays']; +} + let DependenciesContext: React.Context; const setAppDependencies = (deps: AppDependencies) => { const legacyBasePath = { - prepend: deps.core.http.basePath.prepend, - get: deps.core.http.basePath.get, + prepend: deps.http.basePath.prepend, + get: deps.http.basePath.get, remove: () => {}, }; setDependencyCache({ - autocomplete: deps.plugins.data.autocomplete, - docLinks: deps.core.docLinks, + autocomplete: deps.data.autocomplete, + docLinks: deps.docLinks, basePath: legacyBasePath as any, }); DependenciesContext = createContext(deps); @@ -40,24 +54,15 @@ export const useAppDependencies = () => { return useContext(DependenciesContext); }; -export const useDocumentationLinks = () => { - const { - core: { documentation }, - } = useAppDependencies(); - return documentation; -}; - export const useToastNotifications = () => { const { - core: { - notifications: { toasts: toastNotifications }, - }, + notifications: { toasts: toastNotifications }, } = useAppDependencies(); return toastNotifications; }; export const getAppProviders = (deps: AppDependencies) => { - const I18nContext = deps.core.i18n.Context; + const I18nContext = deps.i18n.Context; // Create App dependencies context and get its provider const AppDependenciesProvider = setAppDependencies(deps); diff --git a/x-pack/legacy/plugins/transform/public/app/common/__mocks__/transform_list_row.json b/x-pack/plugins/transform/public/app/common/__mocks__/transform_list_row.json similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/__mocks__/transform_list_row.json rename to x-pack/plugins/transform/public/app/common/__mocks__/transform_list_row.json diff --git a/x-pack/legacy/plugins/transform/public/app/common/__mocks__/transform_stats.json b/x-pack/plugins/transform/public/app/common/__mocks__/transform_stats.json similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/__mocks__/transform_stats.json rename to x-pack/plugins/transform/public/app/common/__mocks__/transform_stats.json diff --git a/x-pack/legacy/plugins/transform/public/app/common/aggregations.test.ts b/x-pack/plugins/transform/public/app/common/aggregations.test.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/aggregations.test.ts rename to x-pack/plugins/transform/public/app/common/aggregations.test.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/aggregations.ts b/x-pack/plugins/transform/public/app/common/aggregations.ts similarity index 83% rename from x-pack/legacy/plugins/transform/public/app/common/aggregations.ts rename to x-pack/plugins/transform/public/app/common/aggregations.ts index 038d68ff37d876..f098e933e4b134 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/aggregations.ts +++ b/x-pack/plugins/transform/public/app/common/aggregations.ts @@ -4,7 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { composeValidators, patternValidator } from '../../../../ml/common/util/validators'; +import { + composeValidators, + patternValidator, +} from '../../../../../legacy/plugins/ml/common/util/validators'; export type AggName = string; diff --git a/x-pack/legacy/plugins/transform/public/app/common/data_grid.ts b/x-pack/plugins/transform/public/app/common/data_grid.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/data_grid.ts rename to x-pack/plugins/transform/public/app/common/data_grid.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/dropdown.ts b/x-pack/plugins/transform/public/app/common/dropdown.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/dropdown.ts rename to x-pack/plugins/transform/public/app/common/dropdown.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/fields.ts b/x-pack/plugins/transform/public/app/common/fields.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/fields.ts rename to x-pack/plugins/transform/public/app/common/fields.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/index.ts b/x-pack/plugins/transform/public/app/common/index.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/common/index.ts rename to x-pack/plugins/transform/public/app/common/index.ts index 52a6884367bc5f..e81fadddbea69f 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/index.ts +++ b/x-pack/plugins/transform/public/app/common/index.ts @@ -22,7 +22,6 @@ export { useRefreshTransformList, CreateRequestBody, PreviewRequestBody, - TransformId, TransformPivotConfig, IndexName, IndexPattern, @@ -35,7 +34,6 @@ export { isTransformStats, TransformStats, TRANSFORM_MODE, - TRANSFORM_STATE, } from './transform_stats'; export { getDiscoverUrl } from './navigation'; export { diff --git a/x-pack/legacy/plugins/transform/public/app/common/navigation.test.tsx b/x-pack/plugins/transform/public/app/common/navigation.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/navigation.test.tsx rename to x-pack/plugins/transform/public/app/common/navigation.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/common/navigation.tsx b/x-pack/plugins/transform/public/app/common/navigation.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/navigation.tsx rename to x-pack/plugins/transform/public/app/common/navigation.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/common/pivot_aggs.ts b/x-pack/plugins/transform/public/app/common/pivot_aggs.ts similarity index 97% rename from x-pack/legacy/plugins/transform/public/app/common/pivot_aggs.ts rename to x-pack/plugins/transform/public/app/common/pivot_aggs.ts index af55732691bb0e..3ea614aaf5c9ad 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/pivot_aggs.ts +++ b/x-pack/plugins/transform/public/app/common/pivot_aggs.ts @@ -5,7 +5,7 @@ */ import { Dictionary } from '../../../common/types/common'; -import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/common'; +import { KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/common'; import { AggName } from './aggregations'; import { EsFieldName } from './fields'; diff --git a/x-pack/legacy/plugins/transform/public/app/common/pivot_group_by.ts b/x-pack/plugins/transform/public/app/common/pivot_group_by.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/common/pivot_group_by.ts rename to x-pack/plugins/transform/public/app/common/pivot_group_by.ts index e6792958ab5d2f..bd5a5a26d9019a 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/pivot_group_by.ts +++ b/x-pack/plugins/transform/public/app/common/pivot_group_by.ts @@ -5,7 +5,7 @@ */ import { Dictionary } from '../../../common/types/common'; -import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/common'; +import { KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/common'; import { AggName } from './aggregations'; import { EsFieldName } from './fields'; diff --git a/x-pack/legacy/plugins/transform/public/app/common/request.test.ts b/x-pack/plugins/transform/public/app/common/request.test.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/request.test.ts rename to x-pack/plugins/transform/public/app/common/request.test.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/request.ts b/x-pack/plugins/transform/public/app/common/request.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/common/request.ts rename to x-pack/plugins/transform/public/app/common/request.ts index 31089b86a2c2d6..79fb3acb9fcaf1 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/request.ts +++ b/x-pack/plugins/transform/public/app/common/request.ts @@ -12,7 +12,7 @@ import { SavedSearchQuery } from '../hooks/use_search_items'; import { StepDefineExposedState } from '../sections/create_transform/components/step_define/step_define_form'; import { StepDetailsExposedState } from '../sections/create_transform/components/step_details/step_details_form'; -import { IndexPattern } from '../../../../../../../src/plugins/data/public'; +import { IndexPattern } from '../../../../../../src/plugins/data/public'; import { getEsAggFromAggConfig, diff --git a/x-pack/legacy/plugins/transform/public/app/common/transform.test.ts b/x-pack/plugins/transform/public/app/common/transform.test.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/transform.test.ts rename to x-pack/plugins/transform/public/app/common/transform.test.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/transform.ts b/x-pack/plugins/transform/public/app/common/transform.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/common/transform.ts rename to x-pack/plugins/transform/public/app/common/transform.ts index 481ad3c6d74ffc..7cf7412283201a 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/transform.ts +++ b/x-pack/plugins/transform/public/app/common/transform.ts @@ -9,12 +9,13 @@ import { BehaviorSubject } from 'rxjs'; import { filter, distinctUntilChanged } from 'rxjs/operators'; import { Subscription } from 'rxjs'; +import { TransformId } from '../../../common'; + import { PivotAggDict } from './pivot_aggs'; import { PivotGroupByDict } from './pivot_group_by'; export type IndexName = string; export type IndexPattern = string; -export type TransformId = string; // Transform name must contain lowercase alphanumeric (a-z and 0-9), hyphens or underscores; // It must also start and end with an alphanumeric character. diff --git a/x-pack/legacy/plugins/transform/public/app/common/transform_list.ts b/x-pack/plugins/transform/public/app/common/transform_list.ts similarity index 87% rename from x-pack/legacy/plugins/transform/public/app/common/transform_list.ts rename to x-pack/plugins/transform/public/app/common/transform_list.ts index 8925923ed9d8f1..17d729a453a05d 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/transform_list.ts +++ b/x-pack/plugins/transform/public/app/common/transform_list.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TransformId, TransformPivotConfig } from './transform'; +import { TransformId } from '../../../common'; +import { TransformPivotConfig } from './transform'; import { TransformStats } from './transform_stats'; // Used to pass on attribute names to table columns diff --git a/x-pack/legacy/plugins/transform/public/app/common/transform_stats.test.ts b/x-pack/plugins/transform/public/app/common/transform_stats.test.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/transform_stats.test.ts rename to x-pack/plugins/transform/public/app/common/transform_stats.test.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/transform_stats.ts b/x-pack/plugins/transform/public/app/common/transform_stats.ts similarity index 84% rename from x-pack/legacy/plugins/transform/public/app/common/transform_stats.ts rename to x-pack/plugins/transform/public/app/common/transform_stats.ts index 433616e4228021..72df6d3985e23f 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/transform_stats.ts +++ b/x-pack/plugins/transform/public/app/common/transform_stats.ts @@ -4,18 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TransformId } from './transform'; -import { TransformListRow } from './transform_list'; +import { TransformId, TRANSFORM_STATE } from '../../../common'; -// reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/transforms/DataFrameTransformStats.java#L243 -export enum TRANSFORM_STATE { - ABORTING = 'aborting', - FAILED = 'failed', - INDEXING = 'indexing', - STARTED = 'started', - STOPPED = 'stopped', - STOPPING = 'stopping', -} +import { TransformListRow } from './transform_list'; export enum TRANSFORM_MODE { BATCH = 'batch', diff --git a/x-pack/legacy/plugins/transform/public/app/common/validators.test.ts b/x-pack/plugins/transform/public/app/common/validators.test.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/validators.test.ts rename to x-pack/plugins/transform/public/app/common/validators.test.ts diff --git a/x-pack/legacy/plugins/transform/public/app/common/validators.ts b/x-pack/plugins/transform/public/app/common/validators.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/common/validators.ts rename to x-pack/plugins/transform/public/app/common/validators.ts diff --git a/x-pack/legacy/plugins/transform/public/app/components/index.ts b/x-pack/plugins/transform/public/app/components/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/components/index.ts rename to x-pack/plugins/transform/public/app/components/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/components/job_icon.tsx b/x-pack/plugins/transform/public/app/components/job_icon.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/components/job_icon.tsx rename to x-pack/plugins/transform/public/app/components/job_icon.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/components/section_error.tsx b/x-pack/plugins/transform/public/app/components/section_error.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/components/section_error.tsx rename to x-pack/plugins/transform/public/app/components/section_error.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/components/section_loading.tsx b/x-pack/plugins/transform/public/app/components/section_loading.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/components/section_loading.tsx rename to x-pack/plugins/transform/public/app/components/section_loading.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/components/toast_notification_text.test.tsx b/x-pack/plugins/transform/public/app/components/toast_notification_text.test.tsx similarity index 86% rename from x-pack/legacy/plugins/transform/public/app/components/toast_notification_text.test.tsx rename to x-pack/plugins/transform/public/app/components/toast_notification_text.test.tsx index 095b57de97d9a9..5b8721cb0fe8c0 100644 --- a/x-pack/legacy/plugins/transform/public/app/components/toast_notification_text.test.tsx +++ b/x-pack/plugins/transform/public/app/components/toast_notification_text.test.tsx @@ -7,8 +7,7 @@ import React from 'react'; import { render } from '@testing-library/react'; -import { createPublicShim } from '../../shim'; -import { getAppProviders } from '../app_dependencies'; +import { Providers } from '../app_dependencies.mock'; import { ToastNotificationText } from './toast_notification_text'; @@ -17,7 +16,6 @@ jest.mock('ui/new_platform'); describe('ToastNotificationText', () => { test('should render the text as plain text', () => { - const Providers = getAppProviders(createPublicShim()); const props = { text: 'a short text message', }; @@ -30,7 +28,6 @@ describe('ToastNotificationText', () => { }); test('should render the text within a modal', () => { - const Providers = getAppProviders(createPublicShim()); const props = { text: 'a text message that is longer than 140 characters. a text message that is longer than 140 characters. a text message that is longer than 140 characters. ', diff --git a/x-pack/legacy/plugins/transform/public/app/components/toast_notification_text.tsx b/x-pack/plugins/transform/public/app/components/toast_notification_text.tsx similarity index 94% rename from x-pack/legacy/plugins/transform/public/app/components/toast_notification_text.tsx rename to x-pack/plugins/transform/public/app/components/toast_notification_text.tsx index 4e0a0a12558d82..44927e61a42c4b 100644 --- a/x-pack/legacy/plugins/transform/public/app/components/toast_notification_text.tsx +++ b/x-pack/plugins/transform/public/app/components/toast_notification_text.tsx @@ -18,16 +18,14 @@ import { import { i18n } from '@kbn/i18n'; -import { toMountPoint } from '../../../../../../../src/plugins/kibana_react/public'; +import { toMountPoint } from '../../../../../../src/plugins/kibana_react/public'; import { useAppDependencies } from '../app_dependencies'; const MAX_SIMPLE_MESSAGE_LENGTH = 140; export const ToastNotificationText: FC<{ text: any }> = ({ text }) => { - const { - core: { overlays }, - } = useAppDependencies(); + const { overlays } = useAppDependencies(); if (typeof text === 'string' && text.length <= MAX_SIMPLE_MESSAGE_LENGTH) { return text; diff --git a/x-pack/legacy/plugins/transform/public/app/constants/index.ts b/x-pack/plugins/transform/public/app/constants/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/constants/index.ts rename to x-pack/plugins/transform/public/app/constants/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/__mocks__/use_api.ts b/x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts similarity index 93% rename from x-pack/legacy/plugins/transform/public/app/hooks/__mocks__/use_api.ts rename to x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts index d3f80574922018..a5cccd58211c5d 100644 --- a/x-pack/legacy/plugins/transform/public/app/hooks/__mocks__/use_api.ts +++ b/x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PreviewRequestBody, TransformId } from '../../common'; +import { TransformId, TransformEndpointRequest } from '../../../../common'; -import { TransformEndpointRequest } from '../use_api_types'; +import { PreviewRequestBody } from '../../common'; const apiFactory = () => ({ getTransforms(transformId?: TransformId): Promise { diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/index.ts b/x-pack/plugins/transform/public/app/hooks/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/hooks/index.ts rename to x-pack/plugins/transform/public/app/hooks/index.ts diff --git a/x-pack/plugins/transform/public/app/hooks/use_api.ts b/x-pack/plugins/transform/public/app/hooks/use_api.ts new file mode 100644 index 00000000000000..c503051ed90afb --- /dev/null +++ b/x-pack/plugins/transform/public/app/hooks/use_api.ts @@ -0,0 +1,63 @@ +/* + * 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 { TransformId, TransformEndpointRequest, TransformEndpointResult } from '../../../common'; +import { API_BASE_PATH } from '../../../common/constants'; + +import { useAppDependencies } from '../app_dependencies'; +import { PreviewRequestBody } from '../common'; + +import { EsIndex } from './use_api_types'; + +export const useApi = () => { + const { http } = useAppDependencies(); + + return { + getTransforms(transformId?: TransformId): Promise { + const transformIdString = transformId !== undefined ? `/${transformId}` : ''; + return http.get(`${API_BASE_PATH}transforms${transformIdString}`); + }, + getTransformsStats(transformId?: TransformId): Promise { + if (transformId !== undefined) { + return http.get(`${API_BASE_PATH}transforms/${transformId}/_stats`); + } + + return http.get(`${API_BASE_PATH}transforms/_stats`); + }, + createTransform(transformId: TransformId, transformConfig: any): Promise { + return http.put(`${API_BASE_PATH}transforms/${transformId}`, { + body: JSON.stringify(transformConfig), + }); + }, + deleteTransforms(transformsInfo: TransformEndpointRequest[]): Promise { + return http.post(`${API_BASE_PATH}delete_transforms`, { + body: JSON.stringify(transformsInfo), + }); + }, + getTransformsPreview(obj: PreviewRequestBody): Promise { + return http.post(`${API_BASE_PATH}transforms/_preview`, { body: JSON.stringify(obj) }); + }, + startTransforms(transformsInfo: TransformEndpointRequest[]): Promise { + return http.post(`${API_BASE_PATH}start_transforms`, { + body: JSON.stringify(transformsInfo), + }); + }, + stopTransforms(transformsInfo: TransformEndpointRequest[]): Promise { + return http.post(`${API_BASE_PATH}stop_transforms`, { + body: JSON.stringify(transformsInfo), + }); + }, + getTransformAuditMessages(transformId: TransformId): Promise { + return http.get(`${API_BASE_PATH}transforms/${transformId}/messages`); + }, + esSearch(payload: any): Promise { + return http.post(`${API_BASE_PATH}es_search`, { body: JSON.stringify(payload) }); + }, + getIndices(): Promise { + return http.get(`/api/index_management/indices`); + }, + }; +}; diff --git a/x-pack/legacy/plugins/transform/public/app/services/ui_metric/index.ts b/x-pack/plugins/transform/public/app/hooks/use_api_types.ts similarity index 83% rename from x-pack/legacy/plugins/transform/public/app/services/ui_metric/index.ts rename to x-pack/plugins/transform/public/app/hooks/use_api_types.ts index e7c3f961824e33..1ab320692bd5e8 100644 --- a/x-pack/legacy/plugins/transform/public/app/services/ui_metric/index.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_api_types.ts @@ -3,4 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -export { uiMetricService } from './ui_metric'; + +export interface EsIndex { + name: string; +} diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_delete_transform.tsx b/x-pack/plugins/transform/public/app/hooks/use_delete_transform.tsx similarity index 95% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_delete_transform.tsx rename to x-pack/plugins/transform/public/app/hooks/use_delete_transform.tsx index 83f456231cb856..6210c72ef9d050 100644 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_delete_transform.tsx +++ b/x-pack/plugins/transform/public/app/hooks/use_delete_transform.tsx @@ -7,14 +7,15 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { toMountPoint } from '../../../../../../../src/plugins/kibana_react/public'; +import { toMountPoint } from '../../../../../../src/plugins/kibana_react/public'; + +import { TransformEndpointRequest, TransformEndpointResult } from '../../../common'; import { useToastNotifications } from '../app_dependencies'; import { TransformListRow, refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../common'; import { ToastNotificationText } from '../components'; import { useApi } from './use_api'; -import { TransformEndpointRequest, TransformEndpointResult } from './use_api_types'; export const useDeleteTransforms = () => { const toastNotifications = useToastNotifications(); diff --git a/x-pack/plugins/transform/public/app/hooks/use_documentation_links.ts b/x-pack/plugins/transform/public/app/hooks/use_documentation_links.ts new file mode 100644 index 00000000000000..7589ee0a3e935f --- /dev/null +++ b/x-pack/plugins/transform/public/app/hooks/use_documentation_links.ts @@ -0,0 +1,24 @@ +/* + * 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 { useAppDependencies } from '../app_dependencies'; + +import { TRANSFORM_DOC_PATHS } from '../constants'; + +export const useDocumentationLinks = () => { + const deps = useAppDependencies(); + const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = deps.docLinks; + return { + esDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`, + esIndicesCreateIndex: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/indices-create-index.html#indices-create-index`, + esPluginDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/plugins/${DOC_LINK_VERSION}/`, + esQueryDsl: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/query-dsl.html`, + esStackOverviewDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/elastic-stack-overview/${DOC_LINK_VERSION}/`, + esTransform: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/${TRANSFORM_DOC_PATHS.transforms}`, + esTransformPivot: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/put-transform.html#put-transform-request-body`, + mlDocBasePath: `${ELASTIC_WEBSITE_URL}guide/en/machine-learning/${DOC_LINK_VERSION}/`, + }; +}; diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_get_transforms.ts b/x-pack/plugins/transform/public/app/hooks/use_get_transforms.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_get_transforms.ts rename to x-pack/plugins/transform/public/app/hooks/use_get_transforms.ts diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_request.ts b/x-pack/plugins/transform/public/app/hooks/use_request.ts similarity index 89% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_request.ts rename to x-pack/plugins/transform/public/app/hooks/use_request.ts index 8c489048a77ef8..e1bdbce941eb00 100644 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_request.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_request.ts @@ -9,8 +9,6 @@ import { UseRequestConfig, useRequest as _useRequest } from '../../shared_import import { useAppDependencies } from '../app_dependencies'; export const useRequest = (config: UseRequestConfig) => { - const { - core: { http }, - } = useAppDependencies(); + const { http } = useAppDependencies(); return _useRequest(http, config); }; diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/common.ts b/x-pack/plugins/transform/public/app/hooks/use_search_items/common.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/common.ts rename to x-pack/plugins/transform/public/app/hooks/use_search_items/common.ts index 2258f8f33f01dd..c536e70fd292f6 100644 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/common.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_search_items/common.ts @@ -10,7 +10,7 @@ import { esQuery, IndexPatternsContract, IndexPatternAttributes, -} from '../../../../../../../../src/plugins/data/public'; +} from '../../../../../../../src/plugins/data/public'; import { matchAllQuery } from '../../common'; diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/index.ts b/x-pack/plugins/transform/public/app/hooks/use_search_items/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/index.ts rename to x-pack/plugins/transform/public/app/hooks/use_search_items/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/use_search_items.ts b/x-pack/plugins/transform/public/app/hooks/use_search_items/use_search_items.ts similarity index 89% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/use_search_items.ts rename to x-pack/plugins/transform/public/app/hooks/use_search_items/use_search_items.ts index 12fc75c20ffa48..f5f9e98fe659c1 100644 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_search_items/use_search_items.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_search_items/use_search_items.ts @@ -23,14 +23,14 @@ export const useSearchItems = (defaultSavedObjectId: string | undefined) => { const [savedObjectId, setSavedObjectId] = useState(defaultSavedObjectId); const appDeps = useAppDependencies(); - const indexPatterns = appDeps.plugins.data.indexPatterns; - const uiSettings = appDeps.core.uiSettings; - const savedObjectsClient = appDeps.core.savedObjects.client; + const indexPatterns = appDeps.data.indexPatterns; + const uiSettings = appDeps.uiSettings; + const savedObjectsClient = appDeps.savedObjects.client; const savedSearches = createSavedSearchesLoader({ savedObjectsClient, indexPatterns, - chrome: appDeps.core.chrome, - overlays: appDeps.core.overlays, + chrome: appDeps.chrome, + overlays: appDeps.overlays, }); const [searchItems, setSearchItems] = useState(undefined); diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_start_transform.ts b/x-pack/plugins/transform/public/app/hooks/use_start_transform.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_start_transform.ts rename to x-pack/plugins/transform/public/app/hooks/use_start_transform.ts index f460d8200c6e44..8e966918e4502a 100644 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_start_transform.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_start_transform.ts @@ -6,11 +6,12 @@ import { i18n } from '@kbn/i18n'; +import { TransformEndpointRequest, TransformEndpointResult } from '../../../common'; + import { useToastNotifications } from '../app_dependencies'; import { TransformListRow, refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../common'; import { useApi } from './use_api'; -import { TransformEndpointRequest, TransformEndpointResult } from './use_api_types'; export const useStartTransforms = () => { const toastNotifications = useToastNotifications(); diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_stop_transform.ts b/x-pack/plugins/transform/public/app/hooks/use_stop_transform.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_stop_transform.ts rename to x-pack/plugins/transform/public/app/hooks/use_stop_transform.ts index 758c574a3f7cdc..03bc9b1ea39980 100644 --- a/x-pack/legacy/plugins/transform/public/app/hooks/use_stop_transform.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_stop_transform.ts @@ -6,11 +6,12 @@ import { i18n } from '@kbn/i18n'; +import { TransformEndpointRequest, TransformEndpointResult } from '../../../common'; + import { useToastNotifications } from '../app_dependencies'; import { TransformListRow, refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../common'; import { useApi } from './use_api'; -import { TransformEndpointRequest, TransformEndpointResult } from './use_api_types'; export const useStopTransforms = () => { const toastNotifications = useToastNotifications(); diff --git a/x-pack/legacy/plugins/transform/public/app/hooks/use_x_json_mode.ts b/x-pack/plugins/transform/public/app/hooks/use_x_json_mode.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/hooks/use_x_json_mode.ts rename to x-pack/plugins/transform/public/app/hooks/use_x_json_mode.ts diff --git a/x-pack/legacy/plugins/transform/public/app/index.scss b/x-pack/plugins/transform/public/app/index.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/index.scss rename to x-pack/plugins/transform/public/app/index.scss diff --git a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/authorization_provider.tsx b/x-pack/plugins/transform/public/app/lib/authorization/components/authorization_provider.tsx similarity index 95% rename from x-pack/legacy/plugins/transform/public/app/lib/authorization/components/authorization_provider.tsx rename to x-pack/plugins/transform/public/app/lib/authorization/components/authorization_provider.tsx index dde63710f56aae..6553d4474d3928 100644 --- a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/authorization_provider.tsx +++ b/x-pack/plugins/transform/public/app/lib/authorization/components/authorization_provider.tsx @@ -5,8 +5,12 @@ */ import React, { createContext } from 'react'; + +import { Privileges } from '../../../../../common'; + import { useRequest } from '../../../hooks'; -import { hasPrivilegeFactory, Capabilities, Privileges } from './common'; + +import { hasPrivilegeFactory, Capabilities } from './common'; interface Authorization { isLoading: boolean; diff --git a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/common.ts b/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts similarity index 94% rename from x-pack/legacy/plugins/transform/public/app/lib/authorization/components/common.ts rename to x-pack/plugins/transform/public/app/lib/authorization/components/common.ts index 27556e0d673a8e..282a737d0bf1e7 100644 --- a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/common.ts +++ b/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts @@ -6,6 +6,8 @@ import { i18n } from '@kbn/i18n'; +import { Privileges } from '../../../../../common'; + export interface Capabilities { canGetTransform: boolean; canDeleteTransform: boolean; @@ -16,11 +18,6 @@ export interface Capabilities { export type Privilege = [string, string]; -export interface Privileges { - hasAllPrivileges: boolean; - missingPrivileges: MissingPrivileges; -} - function isPrivileges(arg: any): arg is Privileges { return ( typeof arg === 'object' && @@ -33,9 +30,6 @@ function isPrivileges(arg: any): arg is Privileges { ); } -export interface MissingPrivileges { - [key: string]: string[] | undefined; -} export const toArray = (value: string | string[]): string[] => Array.isArray(value) ? value : [value]; diff --git a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/index.ts b/x-pack/plugins/transform/public/app/lib/authorization/components/index.ts similarity index 86% rename from x-pack/legacy/plugins/transform/public/app/lib/authorization/components/index.ts rename to x-pack/plugins/transform/public/app/lib/authorization/components/index.ts index 9b37fa1b4393d9..29390ab34ea798 100644 --- a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/index.ts +++ b/x-pack/plugins/transform/public/app/lib/authorization/components/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -export { createCapabilityFailureMessage, Privileges } from './common'; +export { createCapabilityFailureMessage } from './common'; export { AuthorizationProvider, AuthorizationContext } from './authorization_provider'; export { PrivilegesWrapper } from './with_privileges'; export { NotAuthorizedSection } from './not_authorized_section'; diff --git a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/not_authorized_section.tsx b/x-pack/plugins/transform/public/app/lib/authorization/components/not_authorized_section.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/lib/authorization/components/not_authorized_section.tsx rename to x-pack/plugins/transform/public/app/lib/authorization/components/not_authorized_section.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/with_privileges.tsx b/x-pack/plugins/transform/public/app/lib/authorization/components/with_privileges.tsx similarity index 96% rename from x-pack/legacy/plugins/transform/public/app/lib/authorization/components/with_privileges.tsx rename to x-pack/plugins/transform/public/app/lib/authorization/components/with_privileges.tsx index 91e5be53312037..1469e2a471cc6d 100644 --- a/x-pack/legacy/plugins/transform/public/app/lib/authorization/components/with_privileges.tsx +++ b/x-pack/plugins/transform/public/app/lib/authorization/components/with_privileges.tsx @@ -10,11 +10,13 @@ import { EuiPageContent } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import { MissingPrivileges } from '../../../../../common'; + import { SectionLoading } from '../../../components'; import { AuthorizationContext } from './authorization_provider'; import { NotAuthorizedSection } from './not_authorized_section'; -import { hasPrivilegeFactory, toArray, MissingPrivileges, Privilege } from './common'; +import { hasPrivilegeFactory, toArray, Privilege } from './common'; interface Props { /** diff --git a/x-pack/legacy/plugins/transform/public/app/lib/authorization/index.ts b/x-pack/plugins/transform/public/app/lib/authorization/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/lib/authorization/index.ts rename to x-pack/plugins/transform/public/app/lib/authorization/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/clone_transform/clone_transform_section.tsx b/x-pack/plugins/transform/public/app/sections/clone_transform/clone_transform_section.tsx similarity index 95% rename from x-pack/legacy/plugins/transform/public/app/sections/clone_transform/clone_transform_section.tsx rename to x-pack/plugins/transform/public/app/sections/clone_transform/clone_transform_section.tsx index 4618e96cbfd6eb..373faee3b46ed3 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/clone_transform/clone_transform_section.tsx +++ b/x-pack/plugins/transform/public/app/sections/clone_transform/clone_transform_section.tsx @@ -22,11 +22,12 @@ import { } from '@elastic/eui'; import { useApi } from '../../hooks/use_api'; +import { useDocumentationLinks } from '../../hooks/use_documentation_links'; import { useSearchItems } from '../../hooks/use_search_items'; import { APP_CREATE_TRANSFORM_CLUSTER_PRIVILEGES } from '../../../../common/constants'; -import { useAppDependencies, useDocumentationLinks } from '../../app_dependencies'; +import { useAppDependencies } from '../../app_dependencies'; import { TransformPivotConfig } from '../../common'; import { breadcrumbService, docTitleService, BREADCRUMB_SECTION } from '../../services/navigation'; import { PrivilegesWrapper } from '../../lib/authorization'; @@ -65,8 +66,8 @@ export const CloneTransformSection: FC = ({ match }) => { const api = useApi(); const appDeps = useAppDependencies(); - const savedObjectsClient = appDeps.core.savedObjects.client; - const indexPatterns = appDeps.plugins.data.indexPatterns; + const savedObjectsClient = appDeps.savedObjects.client; + const indexPatterns = appDeps.data.indexPatterns; const { esTransform } = useDocumentationLinks(); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/clone_transform/index.ts b/x-pack/plugins/transform/public/app/sections/clone_transform/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/clone_transform/index.ts rename to x-pack/plugins/transform/public/app/sections/clone_transform/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/dropdown.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/dropdown.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/dropdown.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/dropdown.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/agg_label_form.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/agg_label_form.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/agg_label_form.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/agg_label_form.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_form.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_form.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_form.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_form.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_summary.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_summary.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_summary.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_summary.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/popover_form.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/popover_form.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/popover_form.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/popover_form.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_aggregation_label_form.scss b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_aggregation_label_form.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_aggregation_label_form.scss rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_aggregation_label_form.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_index.scss b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_index.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_index.scss rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/_index.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_summary.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/aggregation_list/popover_form.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_form.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_form.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_form.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_form.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_summary.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_summary.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_summary.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_summary.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_form.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_form.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_form.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_form.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_summary.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_summary.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_summary.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_summary.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/popover_form.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/popover_form.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/popover_form.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/popover_form.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/_group_by_label_form.scss b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/_group_by_label_form.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/_group_by_label_form.scss rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/_group_by_label_form.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/_index.scss b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/_index.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/_index.scss rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/_index.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_form.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/group_by_label_summary.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_form.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/list_summary.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/group_by_list/popover_form.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/__snapshots__/expanded_row.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/__snapshots__/expanded_row.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/__snapshots__/expanded_row.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/__snapshots__/expanded_row.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.test.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.test.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.test.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.test.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/common.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/expanded_row.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.test.tsx similarity index 80% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.test.tsx index 48eff132cd7532..7a1532705916f2 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.test.tsx @@ -5,11 +5,10 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, wait } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { getPivotQuery } from '../../../../common'; import { SearchItems } from '../../../../hooks/use_search_items'; @@ -19,7 +18,8 @@ jest.mock('ui/new_platform'); jest.mock('../../../../../shared_imports'); describe('Transform: ', () => { - test('Minimal initialization', () => { + // Using the async/await wait()/done() pattern to avoid act() errors. + test('Minimal initialization', async done => { // Arrange const props = { indexPattern: { @@ -28,7 +28,6 @@ describe('Transform: ', () => { } as SearchItems['indexPattern'], query: getPivotQuery('the-query'), }; - const Providers = getAppProviders(createPublicShim()); const { getByText } = render( @@ -38,5 +37,7 @@ describe('Transform: ', () => { // Act // Assert expect(getByText(`Source index ${props.indexPattern.title}`)).toBeInTheDocument(); + await wait(); + done(); }); }); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/source_index_preview.tsx diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.test.tsx new file mode 100644 index 00000000000000..9992f153f3b864 --- /dev/null +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.test.tsx @@ -0,0 +1,46 @@ +/* + * 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 { renderHook } from '@testing-library/react-hooks'; +import '@testing-library/jest-dom/extend-expect'; + +import { SimpleQuery } from '../../../../common'; +import { + SOURCE_INDEX_STATUS, + useSourceIndexData, + UseSourceIndexDataReturnType, +} from './use_source_index_data'; + +jest.mock('../../../../hooks/use_api'); + +const query: SimpleQuery = { + query_string: { + query: '*', + default_operator: 'AND', + }, +}; + +describe('useSourceIndexData', () => { + test('indexPattern set triggers loading', async done => { + const { result, waitForNextUpdate } = renderHook(() => + useSourceIndexData({ id: 'the-id', title: 'the-title', fields: [] }, query, { + pageIndex: 0, + pageSize: 10, + }) + ); + const sourceIndexObj: UseSourceIndexDataReturnType = result.current; + + await waitForNextUpdate(); + + expect(sourceIndexObj.errorMessage).toBe(''); + expect(sourceIndexObj.status).toBe(SOURCE_INDEX_STATUS.LOADING); + expect(sourceIndexObj.tableItems).toEqual([]); + done(); + }); + + // TODO add more tests to check data retrieved via `api.esSearch()`. + // This needs more investigation in regards to jest's React Hooks support. +}); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.test.tsx similarity index 85% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.test.tsx index 7a22af492e36eb..6223dfc5623b7b 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.test.tsx @@ -8,8 +8,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { StepCreateForm } from './step_create_form'; @@ -27,7 +26,6 @@ describe('Transform: ', () => { onChange() {}, }; - const Providers = getAppProviders(createPublicShim()); const { getByText } = render( diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx index 4198c2ea0260d7..49be2e67ce552d 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx @@ -28,7 +28,7 @@ import { EuiText, } from '@elastic/eui'; -import { toMountPoint } from '../../../../../../../../../../src/plugins/kibana_react/public'; +import { toMountPoint } from '../../../../../../../../../src/plugins/kibana_react/public'; import { PROGRESS_REFRESH_INTERVAL_MS } from '../../../../../../common/constants'; @@ -75,8 +75,8 @@ export const StepCreateForm: FC = React.memo( ); const deps = useAppDependencies(); - const indexPatterns = deps.plugins.data.indexPatterns; - const uiSettings = deps.core.uiSettings; + const indexPatterns = deps.data.indexPatterns; + const uiSettings = deps.uiSettings; const toastNotifications = useToastNotifications(); useEffect(() => { @@ -464,7 +464,7 @@ export const StepCreateForm: FC = React.memo( defaultMessage: 'Use Discover to explore the transform.', } )} - href={getDiscoverUrl(indexPatternId, deps.core.http.basePath.get())} + href={getDiscoverUrl(indexPatternId, deps.http.basePath.get())} data-test-subj="transformWizardCardDiscover" /> diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_summary.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_summary.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_summary.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts index 88e009c63339aa..c9a52304578ee1 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts @@ -20,7 +20,7 @@ import { getPivotPreviewDevConsoleStatement, getPivotDropdownOptions, } from './common'; -import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; +import { IndexPattern } from '../../../../../../../../../src/plugins/data/public'; describe('Transform: Define Pivot Common', () => { test('customSortFactory()', () => { diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts index 35e1ea02a5cefe..0779cb1339af69 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts @@ -5,10 +5,7 @@ */ import { get } from 'lodash'; import { EuiComboBoxOptionOption, EuiDataGridSorting } from '@elastic/eui'; -import { - IndexPattern, - KBN_FIELD_TYPES, -} from '../../../../../../../../../../src/plugins/data/public'; +import { IndexPattern, KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; import { getNestedProperty } from '../../../../../../common/utils/object_utils'; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.test.tsx similarity index 86% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.test.tsx index 464b6e1fd9fe39..f39885f520995b 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.test.tsx @@ -5,11 +5,10 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, wait } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { getPivotQuery, PivotAggsConfig, @@ -25,7 +24,8 @@ jest.mock('ui/new_platform'); jest.mock('../../../../../shared_imports'); describe('Transform: ', () => { - test('Minimal initialization', () => { + // Using the async/await wait()/done() pattern to avoid act() errors. + test('Minimal initialization', async done => { // Arrange const groupBy: PivotGroupByConfig = { agg: PIVOT_SUPPORTED_GROUP_BY_AGGS.TERMS, @@ -49,7 +49,6 @@ describe('Transform: ', () => { query: getPivotQuery('the-query'), }; - const Providers = getAppProviders(createPublicShim()); const { getByText } = render( @@ -59,5 +58,7 @@ describe('Transform: ', () => { // Act // Assert expect(getByText('Transform pivot preview')).toBeInTheDocument(); + await wait(); + done(); }); }); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.test.tsx similarity index 95% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.test.tsx index f45ef7cfddbf9d..d5cffad1668311 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.test.tsx @@ -5,11 +5,10 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, wait } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { PivotAggsConfigDict, PivotGroupByConfigDict, @@ -24,7 +23,8 @@ jest.mock('ui/new_platform'); jest.mock('../../../../../shared_imports'); describe('Transform: ', () => { - test('Minimal initialization', () => { + // Using the async/await wait()/done() pattern to avoid act() errors. + test('Minimal initialization', async done => { // Arrange const searchItems = { indexPattern: { @@ -32,7 +32,6 @@ describe('Transform: ', () => { fields: [] as any[], } as SearchItems['indexPattern'], }; - const Providers = getAppProviders(createPublicShim()); const { getByLabelText } = render( @@ -42,6 +41,8 @@ describe('Transform: ', () => { // Act // Assert expect(getByLabelText('Index pattern')).toBeInTheDocument(); + await wait(); + done(); }); }); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx similarity index 99% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index f61f54c38680ef..254d867165ae69 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -26,9 +26,10 @@ import { EuiSwitch, } from '@elastic/eui'; +import { useDocumentationLinks } from '../../../../hooks/use_documentation_links'; import { SavedSearchQuery, SearchItems } from '../../../../hooks/use_search_items'; import { useXJsonMode, xJsonMode } from '../../../../hooks/use_x_json_mode'; -import { useDocumentationLinks, useToastNotifications } from '../../../../app_dependencies'; +import { useToastNotifications } from '../../../../app_dependencies'; import { TransformPivotConfig } from '../../../../common'; import { dictionaryToArray, Dictionary } from '../../../../../../common/types/common'; import { DropDown } from '../aggregation_dropdown'; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.test.tsx similarity index 88% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.test.tsx index 0f7da50bbbadee..36a662e0cb7e64 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.test.tsx @@ -5,11 +5,10 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, wait } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { PivotAggsConfig, PivotGroupByConfig, @@ -25,7 +24,8 @@ jest.mock('ui/new_platform'); jest.mock('../../../../../shared_imports'); describe('Transform: ', () => { - test('Minimal initialization', () => { + // Using the async/await wait()/done() pattern to avoid act() errors. + test('Minimal initialization', async done => { // Arrange const searchItems = { indexPattern: { @@ -56,7 +56,6 @@ describe('Transform: ', () => { valid: true, }; - const Providers = getAppProviders(createPublicShim()); const { getByText } = render( @@ -67,5 +66,7 @@ describe('Transform: ', () => { // Assert expect(getByText('Group by')).toBeInTheDocument(); expect(getByText('Aggregations')).toBeInTheDocument(); + await wait(); + done(); }); }); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/switch_modal.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/switch_modal.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/switch_modal.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/switch_modal.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx similarity index 96% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx index 1ad8ed099b2414..3e972e9f92e72b 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx @@ -14,7 +14,7 @@ import { UsePivotPreviewDataReturnType, } from './use_pivot_preview_data'; -import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; +import { IndexPattern } from '../../../../../../../../../src/plugins/data/public'; jest.mock('../../../../hooks/use_api'); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts similarity index 96% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts index 84fafcad8151e9..215435027d5b85 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts @@ -10,10 +10,7 @@ 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, ES_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; import { getPreviewRequestBody, diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/common.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/common.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/common.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/common.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx similarity index 97% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx index ea9483af49302f..e56a519f808035 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx @@ -10,19 +10,17 @@ import { i18n } from '@kbn/i18n'; import { EuiLink, EuiSwitch, EuiFieldText, EuiForm, EuiFormRow, EuiSelect } from '@elastic/eui'; -import { toMountPoint } from '../../../../../../../../../../src/plugins/kibana_react/public'; +import { toMountPoint } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { TransformId } from '../../../../../../common'; import { isValidIndexName } from '../../../../../../common/utils/es_utils'; -import { - useAppDependencies, - useDocumentationLinks, - useToastNotifications, -} from '../../../../app_dependencies'; +import { useAppDependencies, useToastNotifications } from '../../../../app_dependencies'; import { ToastNotificationText } from '../../../../components'; +import { useDocumentationLinks } from '../../../../hooks/use_documentation_links'; import { SearchItems } from '../../../../hooks/use_search_items'; import { useApi } from '../../../../hooks/use_api'; -import { isTransformIdValid, TransformId, TransformPivotConfig } from '../../../../common'; +import { isTransformIdValid, TransformPivotConfig } from '../../../../common'; import { EsIndexName, IndexPatternTitle } from './common'; import { delayValidator } from '../../../../common/validators'; @@ -132,7 +130,7 @@ export const StepDetailsForm: FC = React.memo( } try { - setIndexPatternTitles(await deps.plugins.data.indexPatterns.getTitles()); + setIndexPatternTitles(await deps.data.indexPatterns.getTitles()); } catch (e) { toastNotifications.addDanger({ title: i18n.translate( diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/_index.scss b/x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/_index.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/_index.scss rename to x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/_index.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/_wizard.scss b/x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/_wizard.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/_wizard.scss rename to x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/_wizard.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/wizard.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/wizard.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard/wizard.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/wizard/wizard.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard_nav/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/wizard_nav/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard_nav/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/components/wizard_nav/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard_nav/wizard_nav.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/wizard_nav/wizard_nav.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/wizard_nav/wizard_nav.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/components/wizard_nav/wizard_nav.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/create_transform_section.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/create_transform_section.tsx similarity index 97% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/create_transform_section.tsx rename to x-pack/plugins/transform/public/app/sections/create_transform/create_transform_section.tsx index d09fc0913590e9..eaf1e09df47546 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/create_transform_section.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/create_transform_section.tsx @@ -21,7 +21,7 @@ import { import { APP_CREATE_TRANSFORM_CLUSTER_PRIVILEGES } from '../../../../common/constants'; -import { useDocumentationLinks } from '../../app_dependencies'; +import { useDocumentationLinks } from '../../hooks/use_documentation_links'; import { useSearchItems } from '../../hooks/use_search_items'; import { breadcrumbService, docTitleService, BREADCRUMB_SECTION } from '../../services/navigation'; import { PrivilegesWrapper } from '../../lib/authorization'; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/index.ts b/x-pack/plugins/transform/public/app/sections/create_transform/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/create_transform/index.ts rename to x-pack/plugins/transform/public/app/sections/create_transform/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/__snapshots__/transform_management_section.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/__snapshots__/transform_management_section.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/__snapshots__/transform_management_section.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/__snapshots__/transform_management_section.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/__snapshots__/create_transform_button.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/__snapshots__/create_transform_button.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/__snapshots__/create_transform_button.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/__snapshots__/create_transform_button.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_index.scss b/x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_index.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_index.scss rename to x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_index.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_transform_search_dialog.scss b/x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_transform_search_dialog.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_transform_search_dialog.scss rename to x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/_transform_search_dialog.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/create_transform_button.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/index.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/create_transform_button/index.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/create_transform_button/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/index.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/index.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/refresh_transform_list_button.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/refresh_transform_list_button.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/refresh_transform_list_button.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/refresh_transform_list_button/refresh_transform_list_button.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/index.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/search_selection/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/index.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/search_selection/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx similarity index 95% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx index ff8bb7e2f432d7..7d6b178e4bfe46 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx @@ -8,7 +8,7 @@ import { EuiModalBody, EuiModalHeader, EuiModalHeaderTitle } from '@elastic/eui' import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; -import { SavedObjectFinderUi } from '../../../../../../../../../../src/plugins/saved_objects/public'; +import { SavedObjectFinderUi } from '../../../../../../../../../src/plugins/saved_objects/public'; import { useAppDependencies } from '../../../../app_dependencies'; interface SearchSelectionProps { @@ -18,9 +18,8 @@ interface SearchSelectionProps { const fixedPageSize: number = 8; export const SearchSelection: FC = ({ onSearchSelected }) => { - const { - core: { uiSettings, savedObjects }, - } = useAppDependencies(); + const { uiSettings, savedObjects } = useAppDependencies(); + return ( <> diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/_index.scss b/x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/_index.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/_index.scss rename to x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/_index.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stat.scss b/x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stat.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stat.scss rename to x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stat.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stats_bar.scss b/x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stats_bar.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stats_bar.scss rename to x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/_stats_bar.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/index.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/index.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/stat.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/stat.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/stat.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/stat.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/stats_bar.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/stats_bar.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/stats_bar/stats_bar.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/stats_bar/stats_bar.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_delete.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_start.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_start.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_start.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_start.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_stop.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_stop.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_stop.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/action_stop.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_details_pane.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_details_pane.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_details_pane.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_details_pane.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/transform_list.test.tsx.snap b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/transform_list.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/transform_list.test.tsx.snap rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/__snapshots__/transform_list.test.tsx.snap diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/_index.scss b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/_index.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/_index.scss rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/_index.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/_transform_table.scss b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/_transform_table.scss similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/_transform_table.scss rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/_transform_table.scss diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_clone.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_clone.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_clone.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_clone.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.test.tsx similarity index 85% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.test.tsx index 82b9f0a292bb97..17cca6afae4833 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.test.tsx @@ -7,8 +7,7 @@ import { shallow } from 'enzyme'; import React from 'react'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { TransformListRow } from '../../../../common'; import { DeleteAction } from './action_delete'; @@ -20,8 +19,6 @@ jest.mock('../../../../../shared_imports'); describe('Transform: Transform List Actions ', () => { test('Minimal initialization', () => { - const Providers = getAppProviders(createPublicShim()); - const item: TransformListRow = transformListRow; const props = { disabled: false, diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.tsx similarity index 97% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.tsx index 08db7a608be2cf..c20feba29f5822 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_delete.tsx @@ -14,14 +14,14 @@ import { EUI_MODAL_CONFIRM_BUTTON, } from '@elastic/eui'; -import { useDeleteTransforms } from '../../../../hooks'; +import { TRANSFORM_STATE } from '../../../../../../common'; +import { useDeleteTransforms } from '../../../../hooks'; import { createCapabilityFailureMessage, AuthorizationContext, } from '../../../../lib/authorization'; - -import { TransformListRow, TRANSFORM_STATE } from '../../../../common'; +import { TransformListRow } from '../../../../common'; interface DeleteActionProps { items: TransformListRow[]; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.test.tsx similarity index 85% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.test.tsx index 002b4ea19f9678..bbdfdbbc3c121f 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.test.tsx @@ -7,8 +7,7 @@ import { shallow } from 'enzyme'; import React from 'react'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { TransformListRow } from '../../../../common'; import { StartAction } from './action_start'; @@ -20,8 +19,6 @@ jest.mock('../../../../../shared_imports'); describe('Transform: Transform List Actions ', () => { test('Minimal initialization', () => { - const Providers = getAppProviders(createPublicShim()); - const item: TransformListRow = transformListRow; const props = { disabled: false, diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.tsx similarity index 97% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.tsx index c81661f2184431..b6b8a75b4b735b 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_start.tsx @@ -14,14 +14,14 @@ import { EUI_MODAL_CONFIRM_BUTTON, } from '@elastic/eui'; -import { useStartTransforms } from '../../../../hooks'; +import { TRANSFORM_STATE } from '../../../../../../common'; +import { useStartTransforms } from '../../../../hooks'; import { createCapabilityFailureMessage, AuthorizationContext, } from '../../../../lib/authorization'; - -import { TransformListRow, isCompletedBatchTransform, TRANSFORM_STATE } from '../../../../common'; +import { TransformListRow, isCompletedBatchTransform } from '../../../../common'; interface StartActionProps { items: TransformListRow[]; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.test.tsx similarity index 85% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.test.tsx index e2a22765dfb981..840fbc4b9034b0 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.test.tsx @@ -7,8 +7,7 @@ import { shallow } from 'enzyme'; import React from 'react'; -import { createPublicShim } from '../../../../../shim'; -import { getAppProviders } from '../../../../app_dependencies'; +import { Providers } from '../../../../app_dependencies.mock'; import { TransformListRow } from '../../../../common'; import { StopAction } from './action_stop'; @@ -20,8 +19,6 @@ jest.mock('../../../../../shared_imports'); describe('Transform: Transform List Actions ', () => { test('Minimal initialization', () => { - const Providers = getAppProviders(createPublicShim()); - const item: TransformListRow = transformListRow; const props = { disabled: false, diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.tsx similarity index 95% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.tsx index 98aec0acf0bf68..f6b63191b538d6 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/action_stop.tsx @@ -8,7 +8,9 @@ import React, { FC, useContext } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiButtonEmpty, EuiToolTip } from '@elastic/eui'; -import { TransformListRow, TRANSFORM_STATE } from '../../../../common'; +import { TRANSFORM_STATE } from '../../../../../../common'; + +import { TransformListRow } from '../../../../common'; import { createCapabilityFailureMessage, AuthorizationContext, diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.tsx similarity index 90% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.tsx index 3e3829973e328e..6a55b419e74a93 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/actions.tsx @@ -5,7 +5,11 @@ */ import React from 'react'; -import { TransformListRow, TRANSFORM_STATE } from '../../../../common'; + +import { TRANSFORM_STATE } from '../../../../../../common'; + +import { TransformListRow } from '../../../../common'; + import { CloneAction } from './action_clone'; import { StartAction } from './action_start'; import { StopAction } from './action_stop'; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.tsx similarity index 99% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.tsx index 53627d1cf2f6b3..fb24ff2a12e022 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/columns.tsx @@ -19,6 +19,8 @@ import { RIGHT_ALIGNMENT, } from '@elastic/eui'; +import { TransformId, TRANSFORM_STATE } from '../../../../../../common'; + import { ActionsColumnType, ComputedColumnType, @@ -28,11 +30,9 @@ import { import { getTransformProgress, - TransformId, TransformListRow, TransformStats, TRANSFORM_LIST_COLUMN, - TRANSFORM_STATE, } from '../../../../common'; import { getActions } from './actions'; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/common.test.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.test.ts similarity index 88% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/common.test.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.test.ts index c2030e814aa95a..11e4dc3dfa2b8d 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/common.test.ts +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.test.ts @@ -4,9 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ +import { TRANSFORM_STATE } from '../../../../../../common'; + import mockTransformListRow from '../../../../common/__mocks__/transform_list_row.json'; -import { TransformListRow, isCompletedBatchTransform, TRANSFORM_STATE } from '../../../../common'; +import { TransformListRow, isCompletedBatchTransform } from '../../../../common'; describe('Transform: isCompletedBatchTransform()', () => { test('isCompletedBatchTransform()', () => { diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_details_pane.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_json_pane.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_messages_pane.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_messages_pane.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_messages_pane.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_messages_pane.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx index e480381d6fb8e6..0e9b531e1feafe 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx @@ -19,7 +19,7 @@ import { PreviewRequestBody, TransformPivotConfig, } from '../../../../common'; -import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; +import { ES_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; import { formatHumanReadableDateTimeSeconds } from '../../../../../../common/utils/date_utils'; import { transformTableFactory } from './transform_table'; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/index.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/index.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx similarity index 99% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx index 6bea4e5750d2de..9c2da53c36d6bf 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx @@ -21,15 +21,15 @@ import { Direction, } from '@elastic/eui'; +import { TransformId, TRANSFORM_STATE } from '../../../../../../common'; + import { OnTableChangeArg, SortDirection, SORT_DIRECTION } from '../../../../../shared_imports'; import { useRefreshTransformList, - TransformId, TransformListRow, TRANSFORM_MODE, TRANSFORM_LIST_COLUMN, - TRANSFORM_STATE, } from '../../../../common'; import { AuthorizationContext } from '../../../../lib/authorization'; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_table.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_table.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_table.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_table.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transforms_stats_bar.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transforms_stats_bar.tsx similarity index 95% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transforms_stats_bar.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transforms_stats_bar.tsx index dd2369e199d0dc..5f05d08734efe1 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/transforms_stats_bar.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transforms_stats_bar.tsx @@ -6,8 +6,12 @@ import React, { FC } from 'react'; import { i18n } from '@kbn/i18n'; + +import { TRANSFORM_STATE } from '../../../../../../common'; + +import { TRANSFORM_MODE, TransformListRow } from '../../../../common'; + import { StatsBar, TransformStatsBarStats } from '../stats_bar'; -import { TRANSFORM_STATE, TRANSFORM_MODE, TransformListRow } from '../../../../common'; function createTranformStats(transformsList: TransformListRow[]) { const transformStats = { diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/index.ts b/x-pack/plugins/transform/public/app/sections/transform_management/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/index.ts rename to x-pack/plugins/transform/public/app/sections/transform_management/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/transform_management_section.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/transform_management_section.test.tsx similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/transform_management_section.test.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/transform_management_section.test.tsx diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/transform_management_section.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/transform_management_section.tsx similarity index 98% rename from x-pack/legacy/plugins/transform/public/app/sections/transform_management/transform_management_section.tsx rename to x-pack/plugins/transform/public/app/sections/transform_management/transform_management_section.tsx index 8c174098fb623d..002c418b3d2e36 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/transform_management_section.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/transform_management_section.tsx @@ -22,8 +22,9 @@ import { } from '@elastic/eui'; import { APP_GET_TRANSFORM_CLUSTER_PRIVILEGES } from '../../../../common/constants'; -import { useDocumentationLinks } from '../../app_dependencies'; + import { useRefreshTransformList, TransformListRow } from '../../common'; +import { useDocumentationLinks } from '../../hooks/use_documentation_links'; import { useGetTransforms } from '../../hooks'; import { RedirectToCreateTransform } from '../../common/navigation'; import { PrivilegesWrapper } from '../../lib/authorization'; diff --git a/x-pack/legacy/plugins/transform/public/app/services/navigation/breadcrumb.ts b/x-pack/plugins/transform/public/app/services/navigation/breadcrumb.ts similarity index 91% rename from x-pack/legacy/plugins/transform/public/app/services/navigation/breadcrumb.ts rename to x-pack/plugins/transform/public/app/services/navigation/breadcrumb.ts index aa8041a1cbe239..6637b8a39cd567 100644 --- a/x-pack/legacy/plugins/transform/public/app/services/navigation/breadcrumb.ts +++ b/x-pack/plugins/transform/public/app/services/navigation/breadcrumb.ts @@ -7,12 +7,11 @@ import { textService } from '../text'; import { linkToHome } from './links'; -import { ManagementAppMountParams } from '../../../../../../../../src/plugins/management/public'; +import { ManagementAppMountParams } from '../../../../../../../src/plugins/management/public'; type SetBreadcrumbs = ManagementAppMountParams['setBreadcrumbs']; export enum BREADCRUMB_SECTION { - MANAGEMENT = 'management', HOME = 'home', CLONE_TRANSFORM = 'cloneTransform', CREATE_TRANSFORM = 'createTransform', @@ -29,7 +28,6 @@ type Breadcrumbs = { class BreadcrumbService { private breadcrumbs: Breadcrumbs = { - management: [], home: [], cloneTransform: [], createTransform: [], @@ -41,7 +39,6 @@ class BreadcrumbService { // Home and sections this.breadcrumbs.home = [ - ...this.breadcrumbs.management, { text: textService.breadcrumbs.home, href: linkToHome(), diff --git a/x-pack/legacy/plugins/transform/public/app/services/navigation/doc_title.ts b/x-pack/plugins/transform/public/app/services/navigation/doc_title.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/services/navigation/doc_title.ts rename to x-pack/plugins/transform/public/app/services/navigation/doc_title.ts diff --git a/x-pack/legacy/plugins/transform/public/app/services/navigation/index.ts b/x-pack/plugins/transform/public/app/services/navigation/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/services/navigation/index.ts rename to x-pack/plugins/transform/public/app/services/navigation/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/services/navigation/links.ts b/x-pack/plugins/transform/public/app/services/navigation/links.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/services/navigation/links.ts rename to x-pack/plugins/transform/public/app/services/navigation/links.ts diff --git a/x-pack/legacy/plugins/transform/public/app/services/text/index.ts b/x-pack/plugins/transform/public/app/services/text/index.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/services/text/index.ts rename to x-pack/plugins/transform/public/app/services/text/index.ts diff --git a/x-pack/legacy/plugins/transform/public/app/services/text/text.ts b/x-pack/plugins/transform/public/app/services/text/text.ts similarity index 100% rename from x-pack/legacy/plugins/transform/public/app/services/text/text.ts rename to x-pack/plugins/transform/public/app/services/text/text.ts diff --git a/x-pack/legacy/plugins/transform/public/index.ts b/x-pack/plugins/transform/public/index.ts similarity index 51% rename from x-pack/legacy/plugins/transform/public/index.ts rename to x-pack/plugins/transform/public/index.ts index 28c9c06f86e241..83b5addbc5b2c3 100644 --- a/x-pack/legacy/plugins/transform/public/index.ts +++ b/x-pack/plugins/transform/public/index.ts @@ -3,9 +3,10 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Plugin as TransformPlugin } from './plugin'; -import { createPublicShim } from './shim'; +import './app/index.scss'; +import { TransformUiPlugin } from './plugin'; -const { core, plugins } = createPublicShim(); -const transformPlugin = new TransformPlugin(); -transformPlugin.start(core, plugins); +/** @public */ +export const plugin = () => { + return new TransformUiPlugin(); +}; diff --git a/x-pack/plugins/transform/public/plugin.ts b/x-pack/plugins/transform/public/plugin.ts new file mode 100644 index 00000000000000..1a34e7a6413657 --- /dev/null +++ b/x-pack/plugins/transform/public/plugin.ts @@ -0,0 +1,70 @@ +/* + * 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 { i18n as kbnI18n } from '@kbn/i18n'; + +import { CoreSetup } from 'src/core/public'; +import { DataPublicPluginStart } from 'src/plugins/data/public'; +import { ManagementSetup } from 'src/plugins/management/public'; + +import { renderApp } from './app/app'; +import { AppDependencies } from './app/app_dependencies'; +import { breadcrumbService } from './app/services/navigation'; +import { docTitleService } from './app/services/navigation'; +import { textService } from './app/services/text'; + +export interface PluginsDependencies { + data: DataPublicPluginStart; + management: ManagementSetup; +} + +export class TransformUiPlugin { + public setup(coreSetup: CoreSetup, pluginsSetup: PluginsDependencies): void { + const { management } = pluginsSetup; + + // Register management section + const esSection = management.sections.getSection('elasticsearch'); + if (esSection !== undefined) { + esSection.registerApp({ + id: 'transform', + title: kbnI18n.translate('xpack.transform.appTitle', { + defaultMessage: 'Transforms', + }), + order: 3, + mount: async ({ element, setBreadcrumbs }) => { + const { http, notifications, getStartServices } = coreSetup; + const startServices = await getStartServices(); + const [core, plugins] = startServices; + const { chrome, docLinks, i18n, overlays, savedObjects, uiSettings } = core; + const { data } = plugins; + const { docTitle } = chrome; + + // Initialize services + textService.init(); + docTitleService.init(docTitle.change); + breadcrumbService.setup(setBreadcrumbs); + + // AppCore/AppPlugins to be passed on as React context + const appDependencies: AppDependencies = { + chrome, + data, + docLinks, + http, + i18n, + notifications, + overlays, + savedObjects, + uiSettings, + }; + + return renderApp(element, appDependencies); + }, + }); + } + } + + public start() {} + public stop() {} +} diff --git a/x-pack/legacy/plugins/transform/public/shared_imports.ts b/x-pack/plugins/transform/public/shared_imports.ts similarity index 56% rename from x-pack/legacy/plugins/transform/public/shared_imports.ts rename to x-pack/plugins/transform/public/shared_imports.ts index 1ca71f8c4aa773..3582dd5d266e2f 100644 --- a/x-pack/legacy/plugins/transform/public/shared_imports.ts +++ b/x-pack/plugins/transform/public/shared_imports.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -export { createSavedSearchesLoader } from '../../../../../src/plugins/discover/public'; -export { XJsonMode } from '../../../../plugins/es_ui_shared/console_lang/ace/modes/x_json'; +export { createSavedSearchesLoader } from '../../../../src/plugins/discover/public'; +export { XJsonMode } from '../../es_ui_shared/console_lang/ace/modes/x_json'; export { collapseLiteralStrings, expandLiteralStrings, -} from '../../../../../src/plugins/es_ui_shared/console_lang/lib'; +} from '../../../../src/plugins/es_ui_shared/console_lang/lib'; export { SendRequestConfig, @@ -17,12 +17,12 @@ export { UseRequestConfig, sendRequest, useRequest, -} from '../../../../../src/plugins/es_ui_shared/public/request/np_ready_request'; +} from '../../../../src/plugins/es_ui_shared/public/request/np_ready_request'; export { CronEditor, DAY, -} from '../../../../../src/plugins/es_ui_shared/public/components/cron_editor'; +} from '../../../../src/plugins/es_ui_shared/public/components/cron_editor'; // Custom version of EuiInMemoryTable with TypeScript // support and a fix for updating sorting props. @@ -37,10 +37,10 @@ export { SortingPropType, SortDirection, SORT_DIRECTION, -} from '../../ml/public/application/components/ml_in_memory_table'; +} from '../../../legacy/plugins/ml/public/application/components/ml_in_memory_table'; // Needs to be imported because we're reusing KqlFilterBar which depends on it. -export { setDependencyCache } from '../../ml/public/application/util/dependency_cache'; +export { setDependencyCache } from '../../../legacy/plugins/ml/public/application/util/dependency_cache'; // @ts-ignore: could not find declaration file for module -export { KqlFilterBar } from '../../ml/public/application/components/kql_filter_bar'; +export { KqlFilterBar } from '../../../legacy/plugins/ml/public/application/components/kql_filter_bar'; diff --git a/x-pack/plugins/transform/server/routes/api/error_utils.ts b/x-pack/plugins/transform/server/routes/api/error_utils.ts index d09152bf1a6031..295375794c04ef 100644 --- a/x-pack/plugins/transform/server/routes/api/error_utils.ts +++ b/x-pack/plugins/transform/server/routes/api/error_utils.ts @@ -10,10 +10,7 @@ import { i18n } from '@kbn/i18n'; import { ResponseError, CustomHttpResponseOptions } from 'src/core/server'; -import { - TransformEndpointRequest, - TransformEndpointResult, -} from '../../../../../legacy/plugins/transform/public/app/hooks/use_api_types'; +import { TransformEndpointRequest, TransformEndpointResult } from '../../../common'; const REQUEST_TIMEOUT = 'RequestTimeout'; diff --git a/x-pack/plugins/transform/server/routes/api/privileges.ts b/x-pack/plugins/transform/server/routes/api/privileges.ts index 6003a88ffa40c2..9d7fb16ecc19aa 100644 --- a/x-pack/plugins/transform/server/routes/api/privileges.ts +++ b/x-pack/plugins/transform/server/routes/api/privileges.ts @@ -3,13 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { - APP_CLUSTER_PRIVILEGES, - APP_INDEX_PRIVILEGES, -} from '../../../../../legacy/plugins/transform/common/constants'; -// NOTE: now we import it from our "public" folder, but when the Authorisation lib -// will move to the "es_ui_shared" plugin, it will be imported from its "static" folder -import { Privileges } from '../../../../../legacy/plugins/transform/public/app/lib/authorization'; +import { APP_CLUSTER_PRIVILEGES, APP_INDEX_PRIVILEGES } from '../../../common/constants'; +import { Privileges } from '../../../common'; import { RouteDependencies } from '../../types'; import { addBasePath } from '../index'; diff --git a/x-pack/plugins/transform/server/routes/api/transforms.ts b/x-pack/plugins/transform/server/routes/api/transforms.ts index 7aaae1f1c70397..bf201323a3c2f4 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms.ts @@ -9,12 +9,12 @@ import { RequestHandler } from 'kibana/server'; import { CallCluster } from 'src/legacy/core_plugins/elasticsearch'; import { wrapEsError } from '../../../../../legacy/server/lib/create_router/error_wrappers'; -import { TRANSFORM_STATE } from '../../../../../legacy/plugins/transform/public/app/common'; import { TransformEndpointRequest, TransformEndpointResult, -} from '../../../../../legacy/plugins/transform/public/app/hooks/use_api_types'; -import { TransformId } from '../../../../../legacy/plugins/transform/public/app/common/transform'; + TransformId, + TRANSFORM_STATE, +} from '../../../common'; import { RouteDependencies } from '../../types'; @@ -273,9 +273,7 @@ const previewTransformHandler: RequestHandler = async (ctx, req, res) => { }; const startTransformsHandler: RequestHandler = async (ctx, req, res) => { - const { transformsInfo } = req.body as { - transformsInfo: TransformEndpointRequest[]; - }; + const transformsInfo = req.body as TransformEndpointRequest[]; try { return res.ok({ @@ -313,9 +311,7 @@ async function startTransforms( } const stopTransformsHandler: RequestHandler = async (ctx, req, res) => { - const { transformsInfo } = req.body as { - transformsInfo: TransformEndpointRequest[]; - }; + const transformsInfo = req.body as TransformEndpointRequest[]; try { return res.ok({ diff --git a/x-pack/plugins/transform/server/routes/api/transforms_audit_messages.ts b/x-pack/plugins/transform/server/routes/api/transforms_audit_messages.ts index 422fdec7ab77e0..722a3f52376b4b 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms_audit_messages.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms_audit_messages.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AuditMessage } from '../../../../../legacy/plugins/transform/common/types/messages'; +import { AuditMessage } from '../../../common/types/messages'; import { wrapEsError } from '../../../../../legacy/server/lib/create_router/error_wrappers'; import { RouteDependencies } from '../../types'; diff --git a/x-pack/plugins/transform/server/routes/index.ts b/x-pack/plugins/transform/server/routes/index.ts index 953490920cbcb1..07c21e58e64e44 100644 --- a/x-pack/plugins/transform/server/routes/index.ts +++ b/x-pack/plugins/transform/server/routes/index.ts @@ -9,7 +9,7 @@ import { RouteDependencies } from '../types'; import { registerPrivilegesRoute } from './api/privileges'; import { registerTransformsRoutes } from './api/transforms'; -import { API_BASE_PATH } from '../../../../legacy/plugins/transform/common/constants'; +import { API_BASE_PATH } from '../../common/constants'; export const addBasePath = (uri: string): string => `${API_BASE_PATH}${uri}`; diff --git a/x-pack/test/functional/apps/transform/cloning.ts b/x-pack/test/functional/apps/transform/cloning.ts index f06dc0a14a383d..5f05fdb093d101 100644 --- a/x-pack/test/functional/apps/transform/cloning.ts +++ b/x-pack/test/functional/apps/transform/cloning.ts @@ -5,7 +5,7 @@ */ import { FtrProviderContext } from '../../ftr_provider_context'; -import { TransformPivotConfig } from '../../../../legacy/plugins/transform/public/app/common'; +import { TransformPivotConfig } from '../../../../plugins/transform/public/app/common'; function getTransformConfig(): TransformPivotConfig { const date = Date.now(); diff --git a/x-pack/test/functional/services/transform_ui/api.ts b/x-pack/test/functional/services/transform_ui/api.ts index 6a4a1dfff6ea16..94792d6590caac 100644 --- a/x-pack/test/functional/services/transform_ui/api.ts +++ b/x-pack/test/functional/services/transform_ui/api.ts @@ -7,11 +7,11 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; +import { TRANSFORM_STATE } from '../../../../plugins/transform/common'; import { - TRANSFORM_STATE, TransformPivotConfig, TransformStats, -} from '../../../../legacy/plugins/transform/public/app/common'; +} from '../../../../plugins/transform/public/app/common'; export function TransformAPIProvider({ getService }: FtrProviderContext) { const es = getService('legacyEs');