diff --git a/src/plugins/es_ui_shared/public/request/np_ready_request.ts b/src/plugins/es_ui_shared/public/request/np_ready_request.ts new file mode 100644 index 00000000000000..48c7904661e515 --- /dev/null +++ b/src/plugins/es_ui_shared/public/request/np_ready_request.ts @@ -0,0 +1,166 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { useEffect, useState, useRef } from 'react'; + +import { HttpServiceBase } from '../../../../../src/core/public'; + +export interface SendRequestConfig { + path: string; + method: 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head'; + body?: any; +} + +export interface SendRequestResponse { + data: any; + error: Error | null; +} + +export interface UseRequestConfig extends SendRequestConfig { + pollIntervalMs?: number; + initialData?: any; + deserializer?: (data: any) => any; +} + +export interface UseRequestResponse { + isInitialRequest: boolean; + isLoading: boolean; + error: null | unknown; + data: any; + sendRequest: (...args: any[]) => Promise; +} + +export const sendRequest = async ( + httpClient: HttpServiceBase, + { path, method, body }: SendRequestConfig +): Promise => { + try { + const response = await httpClient[method](path, { body }); + + return { + data: response.data ? response.data : response, + error: null, + }; + } catch (e) { + return { + data: null, + error: e.response && e.response.data ? e.response.data : e.body, + }; + } +}; + +export const useRequest = ( + httpClient: HttpServiceBase, + { + path, + method, + body, + pollIntervalMs, + initialData, + deserializer = (data: any): any => data, + }: UseRequestConfig +): UseRequestResponse => { + // Main states for tracking request status and data + const [error, setError] = useState(null); + const [isLoading, setIsLoading] = useState(true); + const [data, setData] = useState(initialData); + + // Consumers can use isInitialRequest to implement a polling UX. + const [isInitialRequest, setIsInitialRequest] = useState(true); + const pollInterval = useRef(null); + const pollIntervalId = useRef(null); + + // We always want to use the most recently-set interval in scheduleRequest. + pollInterval.current = pollIntervalMs; + + // Tied to every render and bound to each request. + let isOutdatedRequest = false; + + const scheduleRequest = () => { + // Clear current interval + if (pollIntervalId.current) { + clearTimeout(pollIntervalId.current); + } + + // Set new interval + if (pollInterval.current) { + pollIntervalId.current = setTimeout(_sendRequest, pollInterval.current); + } + }; + + const _sendRequest = async () => { + // We don't clear error or data, so it's up to the consumer to decide whether to display the + // "old" error/data or loading state when a new request is in-flight. + setIsLoading(true); + + const requestBody = { + path, + method, + body, + }; + + const response = await sendRequest(httpClient, requestBody); + const { data: serializedResponseData, error: responseError } = response; + const responseData = deserializer(serializedResponseData); + + // If an outdated request has resolved, DON'T update state, but DO allow the processData handler + // to execute side effects like update telemetry. + if (isOutdatedRequest) { + return { data: null, error: null }; + } + + setError(responseError); + setData(responseData); + setIsLoading(false); + setIsInitialRequest(false); + + // If we're on an interval, we need to schedule the next request. This also allows us to reset + // the interval if the user has manually requested the data, to avoid doubled-up requests. + scheduleRequest(); + + return { data: serializedResponseData, error: responseError }; + }; + + useEffect(() => { + _sendRequest(); + // To be functionally correct we'd send a new request if the method, path, or body changes. + // But it doesn't seem likely that the method will change and body is likely to be a new + // object even if its shape hasn't changed, so for now we're just watching the path. + }, [path]); + + useEffect(() => { + scheduleRequest(); + + // Clean up intervals and inflight requests and corresponding state changes + return () => { + isOutdatedRequest = true; + if (pollIntervalId.current) { + clearTimeout(pollIntervalId.current); + } + }; + }, [pollIntervalMs]); + + return { + isInitialRequest, + isLoading, + error, + data, + sendRequest: _sendRequest, // Gives the user the ability to manually request data + }; +}; diff --git a/x-pack/legacy/plugins/cross_cluster_replication/index.js b/x-pack/legacy/plugins/cross_cluster_replication/index.js index 4b2d513a43f22d..aef86a4f4ce21a 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/index.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/index.js @@ -9,7 +9,7 @@ import { PLUGIN } from './common/constants'; import { registerLicenseChecker } from './server/lib/register_license_checker'; import { registerRoutes } from './server/routes/register_routes'; import { ccrDataEnricher } from './cross_cluster_replication_data'; -import { addIndexManagementDataEnricher } from '../index_management/index_management_data'; +import { addIndexManagementDataEnricher } from '../index_management/server/index_management_data'; export function crossClusterReplication(kibana) { return new kibana.Plugin({ id: PLUGIN.ID, diff --git a/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/auto_follow_pattern_list/components/detail_panel/detail_panel.js b/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/auto_follow_pattern_list/components/detail_panel/detail_panel.js index 45864b43dba586..bf1a13bf8e567b 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/auto_follow_pattern_list/components/detail_panel/detail_panel.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/auto_follow_pattern_list/components/detail_panel/detail_panel.js @@ -7,7 +7,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from '@kbn/i18n/react'; -import { getIndexListUri } from '../../../../../../../../index_management/public/services/navigation'; +import { getIndexListUri } from '../../../../../../../../index_management/public/app/services/navigation'; import { EuiButton, diff --git a/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js b/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js index d43db5b2405858..9cd044de8b7ccf 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js @@ -7,7 +7,7 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from '@kbn/i18n/react'; -import { getIndexListUri } from '../../../../../../../../index_management/public/services/navigation'; +import { getIndexListUri } from '../../../../../../../../index_management/public/app/services/navigation'; import { EuiButton, diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/sections/policy_table/components/policy_table/policy_table.js b/x-pack/legacy/plugins/index_lifecycle_management/public/sections/policy_table/components/policy_table/policy_table.js index ba2a4b18463307..c03b7cb8b56f98 100644 --- a/x-pack/legacy/plugins/index_lifecycle_management/public/sections/policy_table/components/policy_table/policy_table.js +++ b/x-pack/legacy/plugins/index_lifecycle_management/public/sections/policy_table/components/policy_table/policy_table.js @@ -36,7 +36,7 @@ import { } from '@elastic/eui'; import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services'; -import { getIndexListUri } from '../../../../../../index_management/public/services/navigation'; +import { getIndexListUri } from '../../../../../../index_management/public/app/services/navigation'; import { BASE_PATH, UIM_EDIT_CLICK } from '../../../../../common/constants'; import { getPolicyPath } from '../../../../services/navigation'; import { flattenPanelTree } from '../../../../services/flatten_panel_tree'; diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts index eed13fb2984657..50dd8215102ffe 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts @@ -13,9 +13,9 @@ import { findTestSubject, nextTick, } from '../../../../../../test_utils'; -import { IndexManagementHome } from '../../../public/sections/home'; +import { IndexManagementHome } from '../../../public/app/sections/home'; import { BASE_PATH } from '../../../common/constants'; -import { indexManagementStore } from '../../../public/store'; +import { indexManagementStore } from '../../../public/app/store'; import { Template } from '../../../common/types'; const testBedConfig: TestBedConfig = { diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts index b49736cb1e9ba6..e5bce31ee6de13 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts @@ -5,15 +5,14 @@ */ import sinon, { SinonFakeServer } from 'sinon'; - -const API_PATH = '/api/index_management'; +import { API_BASE_PATH } from '../../../common/constants'; type HttpResponse = Record | any[]; // Register helpers to mock HTTP Requests const registerHttpRequestMockHelpers = (server: SinonFakeServer) => { const setLoadTemplatesResponse = (response: HttpResponse = []) => { - server.respondWith('GET', `${API_PATH}/templates`, [ + server.respondWith('GET', `${API_BASE_PATH}/templates`, [ 200, { 'Content-Type': 'application/json' }, JSON.stringify(response), @@ -21,7 +20,7 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => { }; const setLoadIndicesResponse = (response: HttpResponse = []) => { - server.respondWith('GET', `${API_PATH}/indices`, [ + server.respondWith('GET', `${API_BASE_PATH}/indices`, [ 200, { 'Content-Type': 'application/json' }, JSON.stringify(response), @@ -29,7 +28,7 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => { }; const setDeleteTemplateResponse = (response: HttpResponse = []) => { - server.respondWith('DELETE', `${API_PATH}/templates`, [ + server.respondWith('DELETE', `${API_BASE_PATH}/templates`, [ 200, { 'Content-Type': 'application/json' }, JSON.stringify(response), @@ -40,7 +39,7 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => { const status = error ? error.status || 400 : 200; const body = error ? error.body : response; - server.respondWith('GET', `${API_PATH}/templates/:id`, [ + server.respondWith('GET', `${API_BASE_PATH}/templates/:id`, [ status, { 'Content-Type': 'application/json' }, JSON.stringify(body), @@ -48,10 +47,10 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => { }; const setCreateTemplateResponse = (response?: HttpResponse, error?: any) => { - const status = error ? error.status || 400 : 200; + const status = error ? error.body.status || 400 : 200; const body = error ? JSON.stringify(error.body) : JSON.stringify(response); - server.respondWith('PUT', `${API_PATH}/templates`, [ + server.respondWith('PUT', `${API_BASE_PATH}/templates`, [ status, { 'Content-Type': 'application/json' }, body, @@ -62,7 +61,7 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => { const status = error ? error.status || 400 : 200; const body = error ? JSON.stringify(error.body) : JSON.stringify(response); - server.respondWith('PUT', `${API_PATH}/templates/:name`, [ + server.respondWith('PUT', `${API_BASE_PATH}/templates/:name`, [ status, { 'Content-Type': 'application/json' }, body, diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/setup_environment.ts b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/setup_environment.ts index 21188e7f58c658..d5ac185a63ccd7 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/setup_environment.ts +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/setup_environment.ts @@ -7,15 +7,30 @@ import axios from 'axios'; import axiosXhrAdapter from 'axios/lib/adapters/xhr'; import { init as initHttpRequests } from './http_requests'; -import { setHttpClient } from '../../../public/services/api'; +import { httpService } from '../../../public/app/services/http'; +import { breadcrumbService } from '../../../public/app/services/breadcrumbs'; +import { documentationService } from '../../../public/app/services/documentation'; +import { notificationService } from '../../../public/app/services/notification'; +import { uiMetricService } from '../../../public/app/services/ui_metric'; +import { createUiStatsReporter } from '../../../../../../../src/legacy/core_plugins/ui_metric/public'; + +/* eslint-disable @kbn/eslint/no-restricted-paths */ +import { notificationServiceMock } from '../../../../../../../src/core/public/notifications/notifications_service.mock'; +import { chromeServiceMock } from '../../../../../../../src/core/public/chrome/chrome_service.mock'; +import { docLinksServiceMock } from '../../../../../../../src/core/public/doc_links/doc_links_service.mock'; const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); export const setupEnvironment = () => { - const { server, httpRequestsMockHelpers } = initHttpRequests(); - + // Mock initialization of services // @ts-ignore - setHttpClient(mockHttpClient); + httpService.init(mockHttpClient); + breadcrumbService.init(chromeServiceMock.createStartContract(), ''); + documentationService.init(docLinksServiceMock.createStartContract()); + notificationService.init(notificationServiceMock.createStartContract()); + uiMetricService.init(createUiStatsReporter); + + const { server, httpRequestsMockHelpers } = initHttpRequests(); return { server, diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts index 1401ea7c049063..286e56b4349e4c 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts @@ -6,7 +6,7 @@ import { registerTestBed, TestBedConfig } from '../../../../../../test_utils'; import { BASE_PATH } from '../../../common/constants'; -import { TemplateClone } from '../../../public/sections/template_clone'; +import { TemplateClone } from '../../../public/app/sections/template_clone'; import { formSetup } from './template_form.helpers'; import { TEMPLATE_NAME } from './constants'; diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts index a08b416186d2ef..b1b5d51ef6a9d2 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts @@ -6,7 +6,7 @@ import { registerTestBed, TestBedConfig } from '../../../../../../test_utils'; import { BASE_PATH } from '../../../common/constants'; -import { TemplateCreate } from '../../../public/sections/template_create'; +import { TemplateCreate } from '../../../public/app/sections/template_create'; import { formSetup, TestSubjects } from './template_form.helpers'; const testBedConfig: TestBedConfig = { diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts index 7c47c3388ab3da..e8e19f637854d3 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts @@ -6,7 +6,7 @@ import { registerTestBed, TestBedConfig } from '../../../../../../test_utils'; import { BASE_PATH } from '../../../common/constants'; -import { TemplateEdit } from '../../../public/sections/template_edit'; +import { TemplateEdit } from '../../../public/app/sections/template_edit'; import { formSetup, TestSubjects } from './template_form.helpers'; import { TEMPLATE_NAME } from './constants'; diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts b/x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts index c9ae711324a99d..a7c0ac41816184 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts @@ -8,8 +8,7 @@ import { act } from 'react-dom/test-utils'; import * as fixtures from '../../test/fixtures'; import { setupEnvironment, pageHelpers, nextTick, getRandomString } from './helpers'; import { IdxMgmtHomeTestBed } from './helpers/home.helpers'; - -const API_PATH = '/api/index_management'; +import { API_BASE_PATH } from '../../common/constants'; const { setup } = pageHelpers.home; @@ -21,16 +20,7 @@ const removeWhiteSpaceOnArrayValues = (array: any[]) => return value.trim(); }); -jest.mock('ui/index_patterns', () => ({ - ILLEGAL_CHARACTERS: '', - CONTAINS_SPACES: '', - validateIndexPattern: () => {}, -})); - -jest.mock('ui/chrome', () => ({ - breadcrumbs: { set: () => {} }, - addBasePath: (path: string) => path || '/api/index_management', -})); +jest.mock('ui/new_platform'); // We need to skip the tests until react 16.9.0 is released // which supports asynchronous code inside act() @@ -204,7 +194,9 @@ describe.skip('', () => { }); expect(server.requests.length).toBe(totalRequests + 1); - expect(server.requests[server.requests.length - 1].url).toBe(`${API_PATH}/templates`); + expect(server.requests[server.requests.length - 1].url).toBe( + `${API_BASE_PATH}/templates` + ); }); test('should have a button to create a new template', () => { @@ -346,7 +338,7 @@ describe.skip('', () => { const latestRequest = server.requests[server.requests.length - 1]; expect(latestRequest.method).toBe('DELETE'); - expect(latestRequest.url).toBe(`${API_PATH}/templates/${template1.name}`); + expect(latestRequest.url).toBe(`${API_BASE_PATH}/templates/${template1.name}`); }); }); diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_clone.test.tsx b/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_clone.test.tsx index 6888db4483571b..bd8d9b8e356754 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_clone.test.tsx +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_clone.test.tsx @@ -5,8 +5,6 @@ */ import React from 'react'; import { act } from 'react-dom/test-utils'; -import axiosXhrAdapter from 'axios/lib/adapters/xhr'; -import axios from 'axios'; import { setupEnvironment, pageHelpers, nextTick } from './helpers'; import { TemplateFormTestBed } from './helpers/template_form.helpers'; @@ -15,27 +13,7 @@ import { TEMPLATE_NAME, INDEX_PATTERNS as DEFAULT_INDEX_PATTERNS } from './helpe const { setup } = pageHelpers.templateClone; -const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); - -jest.mock('ui/index_patterns', () => ({ - ILLEGAL_CHARACTERS: 'ILLEGAL_CHARACTERS', - CONTAINS_SPACES: 'CONTAINS_SPACES', - validateIndexPattern: () => { - return { - errors: {}, - }; - }, -})); - -jest.mock('ui/chrome', () => ({ - breadcrumbs: { set: () => {} }, - addBasePath: (path: string) => path || '/api/index_management', -})); - -jest.mock('../../public/services/api', () => ({ - ...jest.requireActual('../../public/services/api'), - getHttpClient: () => mockHttpClient, -})); +jest.mock('ui/new_platform'); jest.mock('@elastic/eui', () => ({ ...jest.requireActual('@elastic/eui'), @@ -135,16 +113,13 @@ describe.skip('', () => { const latestRequest = server.requests[server.requests.length - 1]; - const body = JSON.parse(latestRequest.requestBody); - const expected = { + const expected = JSON.stringify({ ...templateToClone, name: `${templateToClone.name}-copy`, indexPatterns: DEFAULT_INDEX_PATTERNS, - aliases: {}, - mappings: {}, - settings: {}, - }; - expect(body).toEqual(expected); + }); + + expect(JSON.parse(latestRequest.requestBody).body).toEqual(expected); }); }); }); diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_create.test.tsx b/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_create.test.tsx index 60e44121414945..a391811257a9f3 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_create.test.tsx +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_create.test.tsx @@ -5,8 +5,6 @@ */ import React from 'react'; import { act } from 'react-dom/test-utils'; -import axiosXhrAdapter from 'axios/lib/adapters/xhr'; -import axios from 'axios'; import { setupEnvironment, pageHelpers, nextTick } from './helpers'; import { TemplateFormTestBed } from './helpers/template_form.helpers'; @@ -20,27 +18,7 @@ import { const { setup } = pageHelpers.templateCreate; -const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); - -jest.mock('ui/index_patterns', () => ({ - ILLEGAL_CHARACTERS: 'ILLEGAL_CHARACTERS', - CONTAINS_SPACES: 'CONTAINS_SPACES', - validateIndexPattern: () => { - return { - errors: {}, - }; - }, -})); - -jest.mock('ui/chrome', () => ({ - breadcrumbs: { set: () => {} }, - addBasePath: (path: string) => path || '/api/index_management', -})); - -jest.mock('../../public/services/api', () => ({ - ...jest.requireActual('../../public/services/api'), - getHttpClient: () => mockHttpClient, -})); +jest.mock('ui/new_platform'); jest.mock('@elastic/eui', () => ({ ...jest.requireActual('@elastic/eui'), @@ -332,15 +310,16 @@ describe.skip('', () => { const latestRequest = server.requests[server.requests.length - 1]; - const expected = { + const expected = JSON.stringify({ + isManaged: false, name: TEMPLATE_NAME, indexPatterns: DEFAULT_INDEX_PATTERNS, settings: SETTINGS, mappings: MAPPINGS, aliases: ALIASES, - isManaged: false, - }; - expect(JSON.parse(latestRequest.requestBody)).toEqual(expected); + }); + + expect(JSON.parse(latestRequest.requestBody).body).toEqual(expected); }); it('should surface the API errors from the put HTTP request', async () => { diff --git a/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_edit.test.tsx b/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_edit.test.tsx index 128b84da035d53..4056bd2ad63e7c 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_edit.test.tsx +++ b/x-pack/legacy/plugins/index_management/__jest__/client_integration/template_edit.test.tsx @@ -5,8 +5,6 @@ */ import React from 'react'; import { act } from 'react-dom/test-utils'; -import axiosXhrAdapter from 'axios/lib/adapters/xhr'; -import axios from 'axios'; import { setupEnvironment, pageHelpers, nextTick } from './helpers'; import { TemplateFormTestBed } from './helpers/template_form.helpers'; @@ -17,27 +15,7 @@ const UPDATED_INDEX_PATTERN = ['updatedIndexPattern']; const { setup } = pageHelpers.templateEdit; -const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); - -jest.mock('ui/index_patterns', () => ({ - ILLEGAL_CHARACTERS: 'ILLEGAL_CHARACTERS', - CONTAINS_SPACES: 'CONTAINS_SPACES', - validateIndexPattern: () => { - return { - errors: {}, - }; - }, -})); - -jest.mock('ui/chrome', () => ({ - breadcrumbs: { set: () => {} }, - addBasePath: (path: string) => path || '/api/index_management', -})); - -jest.mock('../../public/services/api', () => ({ - ...jest.requireActual('../../public/services/api'), - getHttpClient: () => mockHttpClient, -})); +jest.mock('ui/new_platform'); jest.mock('@elastic/eui', () => ({ ...jest.requireActual('@elastic/eui'), @@ -140,17 +118,18 @@ describe.skip('', () => { const { version, order } = templateToEdit; - const expected = { + const expected = JSON.stringify({ name: TEMPLATE_NAME, version, order, indexPatterns: UPDATED_INDEX_PATTERN, + isManaged: false, settings: SETTINGS, mappings: MAPPINGS, aliases: ALIASES, - isManaged: false, - }; - expect(JSON.parse(latestRequest.requestBody)).toEqual(expected); + }); + + expect(JSON.parse(latestRequest.requestBody).body).toEqual(expected); }); }); }); diff --git a/x-pack/legacy/plugins/index_management/__jest__/components/index_table.test.js b/x-pack/legacy/plugins/index_management/__jest__/components/index_table.test.js index 5ab1f3552320ba..ffb6ade0e642e6 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/components/index_table.test.js +++ b/x-pack/legacy/plugins/index_management/__jest__/components/index_table.test.js @@ -5,33 +5,31 @@ */ import React from 'react'; +import axios from 'axios'; +import axiosXhrAdapter from 'axios/lib/adapters/xhr'; import { MemoryRouter } from 'react-router-dom'; -import { AppWithoutRouter } from '../../public/app'; +import { AppWithoutRouter } from '../../public/app/app'; import { Provider } from 'react-redux'; -import { loadIndicesSuccess } from '../../public/store/actions'; -import { indexManagementStore } from '../../public/store'; -import { BASE_PATH } from '../../common/constants'; +import { loadIndicesSuccess } from '../../public/app/store/actions'; +import { breadcrumbService } from '../../public/app/services/breadcrumbs'; +import { uiMetricService } from '../../public/app/services/ui_metric'; +import { notificationService } from '../../public/app/services/notification'; +import { httpService } from '../../public/app/services/http'; +import { createUiStatsReporter } from '../../../../../../src/legacy/core_plugins/ui_metric/public'; +import { indexManagementStore } from '../../public/app/store'; +import { BASE_PATH, API_BASE_PATH } from '../../common/constants'; import { mountWithIntl } from '../../../../../test_utils/enzyme_helpers'; -// axios has a $http like interface so using it to simulate $http -import axios from 'axios'; -import axiosXhrAdapter from 'axios/lib/adapters/xhr'; -import { setHttpClient } from '../../public/services/api'; import sinon from 'sinon'; import { findTestSubject } from '@elastic/eui/lib/test'; +/* eslint-disable @kbn/eslint/no-restricted-paths */ +import { notificationServiceMock } from '../../../../../../src/core/public/notifications/notifications_service.mock'; +import { chromeServiceMock } from '../../../../../../src/core/public/chrome/chrome_service.mock'; -jest.mock('ui/chrome', () => ({ - breadcrumbs: { set: () => { } }, - addBasePath: path => path || '/api/index_management', -})); +jest.mock('ui/new_platform'); -jest.mock('ui/index_patterns', () => ({ - ILLEGAL_CHARACTERS: '', - CONTAINS_SPACES: '', - validateIndexPattern: () => { }, -})); +const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); -setHttpClient(axios.create({ adapter: axiosXhrAdapter })); let server = null; let store = null; @@ -114,6 +112,14 @@ const namesText = rendered => { describe('index table', () => { beforeEach(() => { + // Mock initialization of services + // @ts-ignore + httpService.init(mockHttpClient); + breadcrumbService.init(chromeServiceMock.createStartContract(), ''); + uiMetricService.init(createUiStatsReporter); + notificationService.init(notificationServiceMock.createStartContract()); + + store = indexManagementStore(); component = ( @@ -124,7 +130,7 @@ describe('index table', () => { ); store.dispatch(loadIndicesSuccess({ indices })); server = sinon.fakeServer.create(); - server.respondWith('/api/index_management/indices', [ + server.respondWith(`${API_BASE_PATH}/indices`, [ 200, { 'Content-Type': 'application/json' }, JSON.stringify(indices) @@ -134,7 +140,7 @@ describe('index table', () => { { 'Content-Type': 'application/json' }, JSON.stringify({ acknowledged: true }) ]); - server.respondWith('/api/index_management/indices/reload', [ + server.respondWith(`${API_BASE_PATH}/indices/reload`, [ 200, { 'Content-Type': 'application/json' }, JSON.stringify(indices) @@ -347,7 +353,8 @@ describe('index table', () => { status: index.name === 'testy0' ? 'close' : index.status }; }); - server.respondWith('/api/index_management/indices/reload', [ + + server.respondWith(`${API_BASE_PATH}/indices/reload`, [ 200, { 'Content-Type': 'application/json' }, JSON.stringify(modifiedIndices) @@ -361,7 +368,7 @@ describe('index table', () => { status: index.name === 'testy1' ? 'open' : index.status }; }); - server.respondWith('/api/index_management/indices/reload', [ + server.respondWith(`${API_BASE_PATH}/indices/reload`, [ 200, { 'Content-Type': 'application/json' }, JSON.stringify(modifiedIndices) diff --git a/x-pack/legacy/plugins/index_management/__jest__/lib/flatten_object.test.js b/x-pack/legacy/plugins/index_management/__jest__/lib/flatten_object.test.js index 3642de5ffabb18..1a9acd8cb4aafb 100644 --- a/x-pack/legacy/plugins/index_management/__jest__/lib/flatten_object.test.js +++ b/x-pack/legacy/plugins/index_management/__jest__/lib/flatten_object.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { flattenObject } from '../../public/lib/flatten_object'; +import { flattenObject } from '../../public/app/lib/flatten_object'; describe('flatten_object', () => { test('it flattens an object', () => { const obj = { diff --git a/x-pack/legacy/plugins/index_management/public/index.js b/x-pack/legacy/plugins/index_management/common/constants/api_base_path.ts similarity index 69% rename from x-pack/legacy/plugins/index_management/public/index.js rename to x-pack/legacy/plugins/index_management/common/constants/api_base_path.ts index d52bf02b82f651..00b07fadd0c083 100644 --- a/x-pack/legacy/plugins/index_management/public/index.js +++ b/x-pack/legacy/plugins/index_management/common/constants/api_base_path.ts @@ -4,6 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -import './register_management_section'; -import './register_routes'; -import './index_management_extensions'; +export const API_BASE_PATH = '/api/index_management'; diff --git a/x-pack/legacy/plugins/index_management/common/constants/index.ts b/x-pack/legacy/plugins/index_management/common/constants/index.ts index c4b21b85c994d6..d1700f0e611c05 100644 --- a/x-pack/legacy/plugins/index_management/common/constants/index.ts +++ b/x-pack/legacy/plugins/index_management/common/constants/index.ts @@ -6,6 +6,7 @@ export { PLUGIN } from './plugin'; export { BASE_PATH } from './base_path'; +export { API_BASE_PATH } from './api_base_path'; export { INVALID_INDEX_PATTERN_CHARS, INVALID_TEMPLATE_NAME_CHARS } from './invalid_characters'; export * from './index_statuses'; diff --git a/x-pack/legacy/plugins/index_management/common/constants/plugin.ts b/x-pack/legacy/plugins/index_management/common/constants/plugin.ts index a5a8f838ea37b2..1f283464df9a06 100644 --- a/x-pack/legacy/plugins/index_management/common/constants/plugin.ts +++ b/x-pack/legacy/plugins/index_management/common/constants/plugin.ts @@ -4,13 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { i18n } from '@kbn/i18n'; import { LICENSE_TYPE_BASIC } from '../../../../common/constants'; export const PLUGIN = { ID: 'index_management', - NAME: i18n.translate('xpack.idxMgmt.appTitle', { - defaultMessage: 'Index Management', - }), + getI18nName: (i18n: any): string => + i18n.translate('xpack.idxMgmt.appTitle', { + defaultMessage: 'Index Management', + }), MINIMUM_LICENSE_REQUIRED: LICENSE_TYPE_BASIC, }; diff --git a/x-pack/legacy/plugins/index_management/index.js b/x-pack/legacy/plugins/index_management/index.js deleted file mode 100644 index 0449e8daba3993..00000000000000 --- a/x-pack/legacy/plugins/index_management/index.js +++ /dev/null @@ -1,41 +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 { resolve } from 'path'; -import { createRouter } from '../../server/lib/create_router'; -import { registerIndicesRoutes } from './server/routes/api/indices'; -import { registerTemplateRoutes } from './server/routes/api/templates'; -import { registerMappingRoute } from './server/routes/api/mapping'; -import { registerSettingsRoutes } from './server/routes/api/settings'; -import { registerStatsRoute } from './server/routes/api/stats'; -import { registerLicenseChecker } from '../../server/lib/register_license_checker'; -import { PLUGIN } from './common/constants'; -import { addIndexManagementDataEnricher } from './index_management_data'; - -export function indexManagement(kibana) { - return new kibana.Plugin({ - id: PLUGIN.ID, - configPrefix: 'xpack.index_management', - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'xpack_main'], - uiExports: { - styleSheetPaths: resolve(__dirname, 'public/index.scss'), - managementSections: [ - 'plugins/index_management', - ] - }, - init: function (server) { - const router = createRouter(server, PLUGIN.ID, '/api/index_management/'); - server.expose('addIndexManagementDataEnricher', addIndexManagementDataEnricher); - registerLicenseChecker(server, PLUGIN.ID, PLUGIN.NAME, PLUGIN.MINIMUM_LICENSE_REQUIRED); - registerIndicesRoutes(router); - registerTemplateRoutes(router, server); - registerSettingsRoutes(router); - registerStatsRoute(router); - registerMappingRoute(router); - } - }); -} diff --git a/x-pack/legacy/plugins/index_management/index.ts b/x-pack/legacy/plugins/index_management/index.ts new file mode 100644 index 00000000000000..f2a543337199f4 --- /dev/null +++ b/x-pack/legacy/plugins/index_management/index.ts @@ -0,0 +1,60 @@ +/* + * 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 { resolve } from 'path'; +import { i18n } from '@kbn/i18n'; +import { Legacy } from 'kibana'; +import { createRouter } from '../../server/lib/create_router'; +import { registerLicenseChecker } from '../../server/lib/register_license_checker'; +import { PLUGIN, API_BASE_PATH } from './common/constants'; +import { LegacySetup } from './server/plugin'; +import { plugin as initServerPlugin } from './server'; + +export type ServerFacade = Legacy.Server; + +export function indexManagement(kibana: any) { + return new kibana.Plugin({ + id: PLUGIN.ID, + configPrefix: 'xpack.index_management', + publicDir: resolve(__dirname, 'public'), + require: ['kibana', 'elasticsearch', 'xpack_main'], + + uiExports: { + styleSheetPaths: resolve(__dirname, 'public/index.scss'), + managementSections: ['plugins/index_management'], + }, + + init(server: ServerFacade) { + const coreSetup = server.newPlatform.setup.core; + + const pluginsSetup = {}; + + const __LEGACY: LegacySetup = { + router: createRouter(server, PLUGIN.ID, `${API_BASE_PATH}/`), + plugins: { + license: { + registerLicenseChecker: registerLicenseChecker.bind( + null, + server, + PLUGIN.ID, + PLUGIN.getI18nName(i18n), + PLUGIN.MINIMUM_LICENSE_REQUIRED as 'basic' + ), + }, + elasticsearch: server.plugins.elasticsearch, + }, + }; + + const serverPlugin = initServerPlugin(); + const indexMgmtSetup = serverPlugin.setup(coreSetup, pluginsSetup, __LEGACY); + + server.expose( + 'addIndexManagementDataEnricher', + indexMgmtSetup.addIndexManagementDataEnricher + ); + }, + }); +} diff --git a/x-pack/legacy/plugins/index_management/public/_index_management.scss b/x-pack/legacy/plugins/index_management/public/_index_management.scss deleted file mode 100644 index abdd267038318b..00000000000000 --- a/x-pack/legacy/plugins/index_management/public/_index_management.scss +++ /dev/null @@ -1,23 +0,0 @@ -.indTable { - // The index table is a bespoke table and can't make use of EuiBasicTable's width settings - thead th.indTable__header--name { - width: 25%; - } - - // The index name can't contain spaces, so this is a rare case of break being OK. - .indTable__cell--name { - word-break: break-all; - } -} - -.indTable__link { - text-align: left; -} - -.indTable__link { - text-align: left; -} - -.indDetail__codeBlock { - background: transparent; -} diff --git a/x-pack/legacy/plugins/index_management/public/app.js b/x-pack/legacy/plugins/index_management/public/app/app.tsx similarity index 75% rename from x-pack/legacy/plugins/index_management/public/app.js rename to x-pack/legacy/plugins/index_management/public/app/app.tsx index 07fa15a1a13323..9ed824e1841206 100644 --- a/x-pack/legacy/plugins/index_management/public/app.js +++ b/x-pack/legacy/plugins/index_management/public/app/app.tsx @@ -6,15 +6,15 @@ import React, { useEffect } from 'react'; import { HashRouter, Switch, Route, Redirect } from 'react-router-dom'; -import { BASE_PATH, UIM_APP_LOAD } from '../common/constants'; +import { BASE_PATH, UIM_APP_LOAD } from '../../common/constants'; import { IndexManagementHome } from './sections/home'; import { TemplateCreate } from './sections/template_create'; import { TemplateClone } from './sections/template_clone'; import { TemplateEdit } from './sections/template_edit'; -import { trackUiMetric } from './services'; +import { uiMetricService } from './services/ui_metric'; export const App = () => { - useEffect(() => trackUiMetric('loaded', UIM_APP_LOAD), []); + useEffect(() => uiMetricService.trackMetric('loaded', UIM_APP_LOAD), []); return ( @@ -28,12 +28,8 @@ export const AppWithoutRouter = () => ( - + - + ); diff --git a/x-pack/legacy/plugins/index_management/public/components/index.ts b/x-pack/legacy/plugins/index_management/public/app/components/index.ts similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/index.ts rename to x-pack/legacy/plugins/index_management/public/app/components/index.ts diff --git a/x-pack/legacy/plugins/index_management/public/components/no_match/index.ts b/x-pack/legacy/plugins/index_management/public/app/components/no_match/index.ts similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/no_match/index.ts rename to x-pack/legacy/plugins/index_management/public/app/components/no_match/index.ts diff --git a/x-pack/legacy/plugins/index_management/public/components/no_match/no_match.tsx b/x-pack/legacy/plugins/index_management/public/app/components/no_match/no_match.tsx similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/no_match/no_match.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/no_match/no_match.tsx diff --git a/x-pack/legacy/plugins/index_management/public/components/page_error/index.ts b/x-pack/legacy/plugins/index_management/public/app/components/page_error/index.ts similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/page_error/index.ts rename to x-pack/legacy/plugins/index_management/public/app/components/page_error/index.ts diff --git a/x-pack/legacy/plugins/index_management/public/components/page_error/page_error_forbidden.tsx b/x-pack/legacy/plugins/index_management/public/app/components/page_error/page_error_forbidden.tsx similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/page_error/page_error_forbidden.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/page_error/page_error_forbidden.tsx diff --git a/x-pack/legacy/plugins/index_management/public/components/section_error.tsx b/x-pack/legacy/plugins/index_management/public/app/components/section_error.tsx similarity index 85% rename from x-pack/legacy/plugins/index_management/public/components/section_error.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/section_error.tsx index c6fdc9f0d8439a..f807ef45559f1b 100644 --- a/x-pack/legacy/plugins/index_management/public/components/section_error.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/section_error.tsx @@ -8,11 +8,9 @@ import { EuiCallOut, EuiSpacer } from '@elastic/eui'; import React, { Fragment } from 'react'; export interface Error { - data: { - error: string; - cause?: string[]; - message?: string; - }; + cause?: string[]; + message?: string; + statusText?: string; } interface Props { @@ -22,14 +20,14 @@ interface Props { export const SectionError: React.FunctionComponent = ({ title, error, ...rest }) => { const { - error: errorString, cause, // wrapEsError() on the server adds a "cause" array message, - } = error.data; + statusText, + } = error; return ( -
{message || errorString}
+
{message || statusText}
{cause && ( diff --git a/x-pack/legacy/plugins/index_management/public/components/section_loading.tsx b/x-pack/legacy/plugins/index_management/public/app/components/section_loading.tsx similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/section_loading.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/section_loading.tsx diff --git a/x-pack/legacy/plugins/index_management/public/components/template_delete_modal.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_delete_modal.tsx similarity index 96% rename from x-pack/legacy/plugins/index_management/public/components/template_delete_modal.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_delete_modal.tsx index 7cfa4335fa2fb0..4e36643dbe117b 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_delete_modal.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_delete_modal.tsx @@ -8,9 +8,9 @@ import { EuiConfirmModal, EuiOverlayMask, EuiCallOut, EuiCheckbox, EuiBadge } fr import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment, useState } from 'react'; -import { toastNotifications } from 'ui/notify'; import { deleteTemplates } from '../services/api'; -import { Template } from '../../common/types'; +import { notificationService } from '../services/notification'; +import { Template } from '../../../common/types'; export const TemplateDeleteModal = ({ templatesToDelete, @@ -51,7 +51,7 @@ export const TemplateDeleteModal = ({ ); callback({ hasDeletedTemplates }); - toastNotifications.addSuccess(successMessage); + notificationService.showSuccessToast(successMessage); } if (error || (errors && errors.length)) { @@ -71,7 +71,7 @@ export const TemplateDeleteModal = ({ defaultMessage: "Error deleting template '{name}'", values: { name: (errors && errors[0].name) || templatesToDelete[0] }, }); - toastNotifications.addDanger(errorMessage); + notificationService.showDangerToast(errorMessage); } }); }; diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/index.ts b/x-pack/legacy/plugins/index_management/public/app/components/template_form/index.ts similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/template_form/index.ts rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/index.ts diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/index.ts b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/index.ts similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/template_form/steps/index.ts rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/index.ts diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_aliases.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_aliases.tsx similarity index 96% rename from x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_aliases.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_aliases.tsx index 96abbae93d0f46..8628b6d8b8d74f 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_aliases.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_aliases.tsx @@ -18,7 +18,7 @@ import { EuiCode, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { templatesDocumentationLink } from '../../../lib/documentation_links'; +import { documentationService } from '../../../services/documentation'; import { StepProps } from '../types'; import { useJsonStep } from './use_json_step'; @@ -63,7 +63,7 @@ export const StepAliases: React.FunctionComponent = ({ diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_logistics.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx similarity index 94% rename from x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_logistics.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx index 86ef102dcec44d..290ade35045512 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_logistics.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx @@ -11,12 +11,12 @@ import { useForm, Form, getUseField, -} from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; +} from '../../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; import { getFormRow, Field, -} from '../../../../../../../../src/plugins/es_ui_shared/static/forms/components'; -import { templatesDocumentationLink } from '../../../lib/documentation_links'; +} from '../../../../../../../../../src/plugins/es_ui_shared/static/forms/components'; +import { documentationService } from '../../../services/documentation'; import { StepProps } from '../types'; import { schemas } from '../template_form_schemas'; @@ -110,7 +110,7 @@ export const StepLogistics: React.FunctionComponent = ({ diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_mappings.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_mappings.tsx similarity index 96% rename from x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_mappings.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_mappings.tsx index 74cb09b1c8e695..97cbaa57afef28 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_mappings.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_mappings.tsx @@ -18,7 +18,7 @@ import { EuiCodeEditor, EuiCode, } from '@elastic/eui'; -import { mappingDocumentationLink } from '../../../lib/documentation_links'; +import { documentationService } from '../../../services/documentation'; import { StepProps } from '../types'; import { useJsonStep } from './use_json_step'; @@ -63,7 +63,7 @@ export const StepMappings: React.FunctionComponent = ({ diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_review.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_review.tsx similarity index 97% rename from x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_review.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_review.tsx index 2c7fe939cc7596..8f2d3978a67806 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_review.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_review.tsx @@ -20,10 +20,10 @@ import { EuiCodeBlock, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { serializers } from '../../../../../../../../src/plugins/es_ui_shared/static/forms/helpers'; +import { serializers } from '../../../../../../../../../src/plugins/es_ui_shared/static/forms/helpers'; -import { serializeTemplate } from '../../../../common/lib/template_serialization'; -import { Template } from '../../../../common/types'; +import { serializeTemplate } from '../../../../../common/lib/template_serialization'; +import { Template } from '../../../../../common/types'; import { StepProps } from '../types'; const { stripEmptyFields } = serializers; diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_settings.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_settings.tsx similarity index 96% rename from x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_settings.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_settings.tsx index 9509ca38003ba8..cead652c9f6fcb 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/step_settings.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_settings.tsx @@ -18,7 +18,7 @@ import { EuiCode, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { settingsDocumentationLink } from '../../../lib/documentation_links'; +import { documentationService } from '../../../services/documentation'; import { StepProps } from '../types'; import { useJsonStep } from './use_json_step'; @@ -63,7 +63,7 @@ export const StepSettings: React.FunctionComponent = ({ diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/use_json_step.ts b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/use_json_step.ts similarity index 94% rename from x-pack/legacy/plugins/index_management/public/components/template_form/steps/use_json_step.ts rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/use_json_step.ts index dd0d7d26933707..ae16a2e9263ff5 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/steps/use_json_step.ts +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/use_json_step.ts @@ -7,7 +7,7 @@ import { useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; -import { isJSON } from '../../../../../../../../src/plugins/es_ui_shared/static/validators/string'; +import { isJSON } from '../../../../../../../../../src/plugins/es_ui_shared/static/validators/string'; import { StepProps } from '../types'; interface Parameters { diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/template_form.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form.tsx similarity index 97% rename from x-pack/legacy/plugins/index_management/public/components/template_form/template_form.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form.tsx index cb4e0d987b22f7..78bf7e8e212fdb 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/template_form.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form.tsx @@ -14,8 +14,8 @@ import { EuiSpacer, } from '@elastic/eui'; -import { serializers } from '../../../../../../../src/plugins/es_ui_shared/static/forms/helpers'; -import { Template } from '../../../common/types'; +import { serializers } from '../../../../../../../../src/plugins/es_ui_shared/static/forms/helpers'; +import { Template } from '../../../../common/types'; import { TemplateSteps } from './template_steps'; import { StepAliases, StepLogistics, StepMappings, StepSettings, StepReview } from './steps'; import { StepProps, DataGetterFunc } from './types'; diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/template_form_schemas.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx similarity index 95% rename from x-pack/legacy/plugins/index_management/public/components/template_form/template_form_schemas.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx index 0e11129fe7d15c..79d1b4d3c95b3b 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/template_form_schemas.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx @@ -12,17 +12,17 @@ import { FormSchema, FIELD_TYPES, VALIDATION_TYPES, -} from '../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; +} from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; import { fieldFormatters, fieldValidators, -} from '../../../../../../../src/plugins/es_ui_shared/static/forms/helpers'; +} from '../../../../../../../../src/plugins/es_ui_shared/static/forms/helpers'; import { INVALID_INDEX_PATTERN_CHARS, INVALID_TEMPLATE_NAME_CHARS, -} from '../../../common/constants'; +} from '../../../../common/constants'; const { emptyField, containsCharsField, startsWithField, indexPatternField } = fieldValidators; const { toInt } = fieldFormatters; diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/template_steps.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_steps.tsx similarity index 100% rename from x-pack/legacy/plugins/index_management/public/components/template_form/template_steps.tsx rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/template_steps.tsx diff --git a/x-pack/legacy/plugins/index_management/public/components/template_form/types.ts b/x-pack/legacy/plugins/index_management/public/app/components/template_form/types.ts similarity index 91% rename from x-pack/legacy/plugins/index_management/public/components/template_form/types.ts rename to x-pack/legacy/plugins/index_management/public/app/components/template_form/types.ts index 953c45ff199815..4bb939f11c3fe7 100644 --- a/x-pack/legacy/plugins/index_management/public/components/template_form/types.ts +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Template } from '../../../common/types'; +import { Template } from '../../../../common/types'; export interface StepProps { template: Partial