diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json
index d7d9249a946cb..17faebbe94e6d 100644
--- a/x-pack/.i18nrc.json
+++ b/x-pack/.i18nrc.json
@@ -26,7 +26,7 @@
"xpack.logstash": "legacy/plugins/logstash",
"xpack.main": "legacy/plugins/xpack_main",
"xpack.monitoring": "legacy/plugins/monitoring",
- "xpack.remoteClusters": ["plugins/remote_clusters", "legacy/plugins/remote_clusters"],
+ "xpack.remoteClusters": "plugins/remote_clusters",
"xpack.reporting": ["plugins/reporting", "legacy/plugins/reporting"],
"xpack.rollupJobs": "legacy/plugins/rollup",
"xpack.searchProfiler": "plugins/searchprofiler",
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/setup_environment.js b/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/setup_environment.js
deleted file mode 100644
index d2385dc900bb2..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/setup_environment.js
+++ /dev/null
@@ -1,35 +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 axios from 'axios';
-import axiosXhrAdapter from 'axios/lib/adapters/xhr';
-import chrome from 'ui/chrome'; // eslint-disable-line import/no-unresolved
-import { MANAGEMENT_BREADCRUMB } from 'ui/management'; // eslint-disable-line import/no-unresolved
-import { fatalError, toastNotifications } from 'ui/notify'; // eslint-disable-line import/no-unresolved
-
-import { init as initBreadcrumb } from '../../../public/app/services/breadcrumb';
-import { init as initHttp } from '../../../public/app/services/http';
-import { init as initNotification } from '../../../public/app/services/notification';
-import { init as initUiMetric } from '../../../public/app/services/ui_metric';
-import { init as initHttpRequests } from './http_requests';
-
-export const setupEnvironment = () => {
- chrome.breadcrumbs = {
- set: () => {},
- };
- // axios has a $http like interface so using it to simulate $http
- initHttp(axios.create({ adapter: axiosXhrAdapter }), path => path);
- initBreadcrumb(() => {}, MANAGEMENT_BREADCRUMB);
- initNotification(toastNotifications, fatalError);
- initUiMetric(() => () => {});
-
- const { server, httpRequestsMockHelpers } = initHttpRequests();
-
- return {
- server,
- httpRequestsMockHelpers,
- };
-};
diff --git a/x-pack/legacy/plugins/remote_clusters/common/cluster_serialization.test.ts b/x-pack/legacy/plugins/remote_clusters/common/cluster_serialization.test.ts
deleted file mode 100644
index 476fbee7fb6a0..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/common/cluster_serialization.test.ts
+++ /dev/null
@@ -1,137 +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 { deserializeCluster, serializeCluster } from './cluster_serialization';
-
-describe('cluster_serialization', () => {
- describe('deserializeCluster()', () => {
- it('should throw an error for invalid arguments', () => {
- expect(() => deserializeCluster('foo', 'bar')).toThrowError();
- });
-
- it('should deserialize a complete cluster object', () => {
- expect(
- deserializeCluster('test_cluster', {
- seeds: ['localhost:9300'],
- connected: true,
- num_nodes_connected: 1,
- max_connections_per_cluster: 3,
- initial_connect_timeout: '30s',
- skip_unavailable: false,
- transport: {
- ping_schedule: '-1',
- compress: false,
- },
- })
- ).toEqual({
- name: 'test_cluster',
- seeds: ['localhost:9300'],
- isConnected: true,
- connectedNodesCount: 1,
- maxConnectionsPerCluster: 3,
- initialConnectTimeout: '30s',
- skipUnavailable: false,
- transportPingSchedule: '-1',
- transportCompress: false,
- });
- });
-
- it('should deserialize a cluster object without transport information', () => {
- expect(
- deserializeCluster('test_cluster', {
- seeds: ['localhost:9300'],
- connected: true,
- num_nodes_connected: 1,
- max_connections_per_cluster: 3,
- initial_connect_timeout: '30s',
- skip_unavailable: false,
- })
- ).toEqual({
- name: 'test_cluster',
- seeds: ['localhost:9300'],
- isConnected: true,
- connectedNodesCount: 1,
- maxConnectionsPerCluster: 3,
- initialConnectTimeout: '30s',
- skipUnavailable: false,
- });
- });
-
- it('should deserialize a cluster object with arbitrary missing properties', () => {
- expect(
- deserializeCluster('test_cluster', {
- seeds: ['localhost:9300'],
- connected: true,
- num_nodes_connected: 1,
- initial_connect_timeout: '30s',
- transport: {
- compress: false,
- },
- })
- ).toEqual({
- name: 'test_cluster',
- seeds: ['localhost:9300'],
- isConnected: true,
- connectedNodesCount: 1,
- initialConnectTimeout: '30s',
- transportCompress: false,
- });
- });
- });
-
- describe('serializeCluster()', () => {
- it('should throw an error for invalid arguments', () => {
- expect(() => serializeCluster('foo')).toThrowError();
- });
-
- it('should serialize a complete cluster object to only dynamic properties', () => {
- expect(
- serializeCluster({
- name: 'test_cluster',
- seeds: ['localhost:9300'],
- isConnected: true,
- connectedNodesCount: 1,
- maxConnectionsPerCluster: 3,
- initialConnectTimeout: '30s',
- skipUnavailable: false,
- transportPingSchedule: '-1',
- transportCompress: false,
- })
- ).toEqual({
- persistent: {
- cluster: {
- remote: {
- test_cluster: {
- seeds: ['localhost:9300'],
- skip_unavailable: false,
- },
- },
- },
- },
- });
- });
-
- it('should serialize a cluster object with missing properties', () => {
- expect(
- serializeCluster({
- name: 'test_cluster',
- seeds: ['localhost:9300'],
- })
- ).toEqual({
- persistent: {
- cluster: {
- remote: {
- test_cluster: {
- seeds: ['localhost:9300'],
- skip_unavailable: null,
- },
- },
- },
- },
- });
- });
- });
-});
diff --git a/x-pack/legacy/plugins/remote_clusters/common/cluster_serialization.ts b/x-pack/legacy/plugins/remote_clusters/common/cluster_serialization.ts
deleted file mode 100644
index 07ea79d42b800..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/common/cluster_serialization.ts
+++ /dev/null
@@ -1,71 +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.
- */
-
-export function deserializeCluster(name: string, esClusterObject: any): any {
- if (!name || !esClusterObject || typeof esClusterObject !== 'object') {
- throw new Error('Unable to deserialize cluster');
- }
-
- const {
- seeds,
- connected: isConnected,
- num_nodes_connected: connectedNodesCount,
- max_connections_per_cluster: maxConnectionsPerCluster,
- initial_connect_timeout: initialConnectTimeout,
- skip_unavailable: skipUnavailable,
- transport,
- } = esClusterObject;
-
- let deserializedClusterObject: any = {
- name,
- seeds,
- isConnected,
- connectedNodesCount,
- maxConnectionsPerCluster,
- initialConnectTimeout,
- skipUnavailable,
- };
-
- if (transport) {
- const { ping_schedule: transportPingSchedule, compress: transportCompress } = transport;
-
- deserializedClusterObject = {
- ...deserializedClusterObject,
- transportPingSchedule,
- transportCompress,
- };
- }
-
- // It's unnecessary to send undefined values back to the client, so we can remove them.
- Object.keys(deserializedClusterObject).forEach(key => {
- if (deserializedClusterObject[key] === undefined) {
- delete deserializedClusterObject[key];
- }
- });
-
- return deserializedClusterObject;
-}
-
-export function serializeCluster(deserializedClusterObject: any): any {
- if (!deserializedClusterObject || typeof deserializedClusterObject !== 'object') {
- throw new Error('Unable to serialize cluster');
- }
-
- const { name, seeds, skipUnavailable } = deserializedClusterObject;
-
- return {
- persistent: {
- cluster: {
- remote: {
- [name]: {
- seeds: seeds ? seeds : null,
- skip_unavailable: skipUnavailable !== undefined ? skipUnavailable : null,
- },
- },
- },
- },
- };
-}
diff --git a/x-pack/legacy/plugins/remote_clusters/common/index.ts b/x-pack/legacy/plugins/remote_clusters/common/index.ts
index 8f80b3b7dc6a3..c643f549cbfe1 100644
--- a/x-pack/legacy/plugins/remote_clusters/common/index.ts
+++ b/x-pack/legacy/plugins/remote_clusters/common/index.ts
@@ -4,20 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { i18n } from '@kbn/i18n';
-import { LICENSE_TYPE_BASIC, LicenseType } from '../../../common/constants';
-
export const PLUGIN = {
ID: 'remote_clusters',
- // Remote Clusters are used in both CCS and CCR, and CCS is available for all licenses.
- MINIMUM_LICENSE_REQUIRED: LICENSE_TYPE_BASIC as LicenseType,
- getI18nName: (): string => {
- return i18n.translate('xpack.remoteClusters.appName', {
- defaultMessage: 'Remote Clusters',
- });
- },
};
-
-export const API_BASE_PATH = '/api/remote_clusters';
-
-export { deserializeCluster, serializeCluster } from './cluster_serialization';
diff --git a/x-pack/legacy/plugins/remote_clusters/index.ts b/x-pack/legacy/plugins/remote_clusters/index.ts
index 5dd823e09eb8b..37b2224f8d7c2 100644
--- a/x-pack/legacy/plugins/remote_clusters/index.ts
+++ b/x-pack/legacy/plugins/remote_clusters/index.ts
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Legacy } from 'kibana';
import { resolve } from 'path';
import { PLUGIN } from './common';
@@ -13,18 +12,11 @@ export function remoteClusters(kibana: any) {
id: PLUGIN.ID,
configPrefix: 'xpack.remote_clusters',
publicDir: resolve(__dirname, 'public'),
- // xpack_main is required for license checking.
- require: ['kibana', 'elasticsearch', 'xpack_main', 'index_management'],
+ require: ['kibana'],
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
- managementSections: ['plugins/remote_clusters'],
- injectDefaultVars(server: Legacy.Server) {
- const config = server.config();
- return {
- remoteClustersUiEnabled: config.get('xpack.remote_clusters.ui.enabled'),
- };
- },
},
+ // TODO: Remove once CCR has migrated to NP
config(Joi: any) {
return Joi.object({
// display menu item
@@ -41,6 +33,6 @@ export function remoteClusters(kibana: any) {
config.get('xpack.remote_clusters.enabled') && config.get('xpack.index_management.enabled')
);
},
- init(server: any) {},
+ init() {},
});
}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/connection_status/_index.scss b/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/connection_status/_index.scss
deleted file mode 100644
index c85cb36c5dc5a..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/connection_status/_index.scss
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * 1. Prevent inherited flexbox layout from compressing this element on IE.
- */
- .remoteClustersConnectionStatus__message {
- flex-basis: auto !important; /* 1 */
-}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/http.ts b/x-pack/legacy/plugins/remote_clusters/public/app/services/http.ts
deleted file mode 100644
index 54dadf0ae3cb1..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/http.ts
+++ /dev/null
@@ -1,39 +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.
- */
-
-let _httpClient: any;
-let _prependBasePath: any;
-
-export function init(httpClient: any, prependBasePath: any): void {
- _httpClient = httpClient;
- _prependBasePath = prependBasePath;
-}
-
-export function getFullPath(path: string): string {
- const apiPrefix = _prependBasePath('/api/remote_clusters');
-
- if (path) {
- return `${apiPrefix}/${path}`;
- }
-
- return apiPrefix;
-}
-
-export function sendPost(path: string, payload: any): any {
- return _httpClient.post(getFullPath(path), payload);
-}
-
-export function sendGet(path: string): any {
- return _httpClient.get(getFullPath(path));
-}
-
-export function sendPut(path: string, payload: any): any {
- return _httpClient.put(getFullPath(path), payload);
-}
-
-export function sendDelete(path: string): any {
- return _httpClient.delete(getFullPath(path));
-}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/index.html b/x-pack/legacy/plugins/remote_clusters/public/index.html
deleted file mode 100644
index 4de600769fb40..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/public/index.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/x-pack/legacy/plugins/remote_clusters/public/index.js b/x-pack/legacy/plugins/remote_clusters/public/index.js
deleted file mode 100644
index 0a08011dd71a0..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/public/index.js
+++ /dev/null
@@ -1,12 +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 { Plugin as RemoteClustersPlugin } from './plugin';
-import { createShim } from './shim';
-
-const { coreStart, pluginsStart } = createShim();
-const remoteClustersPlugin = new RemoteClustersPlugin();
-remoteClustersPlugin.start(coreStart, pluginsStart);
diff --git a/x-pack/legacy/plugins/remote_clusters/public/index.scss b/x-pack/legacy/plugins/remote_clusters/public/index.scss
index 4618b005312a5..4ae11323642d8 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/index.scss
+++ b/x-pack/legacy/plugins/remote_clusters/public/index.scss
@@ -1,8 +1,7 @@
// Import the EUI global scope so we can use EUI constants
@import 'src/legacy/ui/public/styles/_styling_constants';
-@import './app/sections/remote_cluster_list/components/connection_status/index';
-// Index management plugin styles
+// Remote clusters plugin styles
// Prefix all styles with "remoteClusters" to avoid conflicts.
// Examples
@@ -16,8 +15,14 @@
* as the 'Reset to defaults' link is added to and removed from the DOM.
* 2. Fix the positioning.
*/
-
.remoteClusterSkipIfUnavailableSwitch {
justify-content: flex-start !important; /* 1 */
padding-top: $euiSizeS !important;
}
+
+/**
+ * 1. Prevent inherited flexbox layout from compressing this element on IE.
+ */
+ .remoteClustersConnectionStatus__message {
+ flex-basis: auto !important; /* 1 */
+}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/plugin.js b/x-pack/legacy/plugins/remote_clusters/public/plugin.js
deleted file mode 100644
index 8dbcfb98859cd..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/public/plugin.js
+++ /dev/null
@@ -1,123 +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 { unmountComponentAtNode } from 'react-dom';
-import { i18n } from '@kbn/i18n';
-import routes from 'ui/routes';
-
-import template from './index.html';
-import { renderReact } from './app';
-import { CRUD_APP_BASE_PATH } from './app/constants';
-import { setUserHasLeftApp, setRedirect } from './app/services';
-import { init as initBreadcrumbs } from './app/services/breadcrumb';
-import { init as initDocumentation } from './app/services/documentation';
-import { init as initHttp } from './app/services/http';
-import { init as initUiMetric } from './app/services/ui_metric';
-import { init as initNotification } from './app/services/notification';
-
-const REACT_ROOT_ID = 'remoteClustersReactRoot';
-
-export class Plugin {
- start(coreStart, pluginsStart) {
- const {
- i18n: { Context },
- chrome: { setBreadcrumbs },
- notifications: { toasts },
- fatalError,
- http: {
- basePath: { prepend: prependBasePath },
- },
- injectedMetadata: { getInjectedVar },
- documentation: { elasticWebsiteUrl, docLinkVersion },
- } = coreStart;
-
- if (getInjectedVar('remoteClustersUiEnabled')) {
- const {
- management: { getSection, breadcrumb: managementBreadcrumb },
- uiMetric: { createUiStatsReporter },
- } = pluginsStart;
-
- const esSection = getSection('elasticsearch');
- esSection.register('remote_clusters', {
- visible: true,
- display: i18n.translate('xpack.remoteClusters.appTitle', {
- defaultMessage: 'Remote Clusters',
- }),
- order: 5,
- url: `#${CRUD_APP_BASE_PATH}/list`,
- });
-
- // Initialize services
- initBreadcrumbs(setBreadcrumbs, managementBreadcrumb);
- initDocumentation(`${elasticWebsiteUrl}guide/en/elasticsearch/reference/${docLinkVersion}/`);
- initUiMetric(createUiStatsReporter);
- initNotification(toasts, fatalError);
-
- const unmountReactApp = () => {
- const appElement = document.getElementById(REACT_ROOT_ID);
- if (appElement) {
- unmountComponentAtNode(appElement);
- }
- };
-
- // NOTE: The New Platform will implicitly handle much of this logic by mounting the app at
- // the base route.
- routes.when(`${CRUD_APP_BASE_PATH}/:view?/:id?`, {
- template,
- controllerAs: 'remoteClusters',
- controller: class RemoteClustersController {
- constructor($scope, $route, $http, kbnUrl) {
- // NOTE: We depend upon Angular's $http service because it's decorated with interceptors,
- // e.g. to check license status per request.
- initHttp($http, prependBasePath);
-
- setRedirect(path => {
- $scope.$evalAsync(() => {
- kbnUrl.redirect(path);
- });
- });
-
- // If returning to the app, we'll need to reset this state.
- setUserHasLeftApp(false);
-
- // React-router's will cause this controller to re-execute without the $destroy
- // handler being called. This means the app will re-mount, so we need to unmount it first
- // here.
- unmountReactApp();
-
- $scope.$$postDigest(() => {
- const appElement = document.getElementById(REACT_ROOT_ID);
- if (appElement) {
- renderReact(appElement, Context);
- }
-
- const appRoute = $route.current;
- const stopListeningForLocationChange = $scope.$on('$locationChangeSuccess', () => {
- const currentRoute = $route.current;
- const isNavigationInApp =
- currentRoute.$$route.template === appRoute.$$route.template;
-
- // When we navigate within the app, prevent Angular from re-matching the route and
- // rebuilding the app.
- if (isNavigationInApp) {
- $route.current = appRoute;
- } else {
- // Set internal flag so we can prevent reacting to the route change internally.
- setUserHasLeftApp(true);
- }
- });
-
- $scope.$on('$destroy', () => {
- stopListeningForLocationChange();
- unmountReactApp();
- });
- });
- }
- },
- });
- }
- }
-}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/shim.ts b/x-pack/legacy/plugins/remote_clusters/public/shim.ts
deleted file mode 100644
index 83975fa4bd0fe..0000000000000
--- a/x-pack/legacy/plugins/remote_clusters/public/shim.ts
+++ /dev/null
@@ -1,42 +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 { management, MANAGEMENT_BREADCRUMB } from 'ui/management';
-import { fatalError } from 'ui/notify';
-import { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL } from 'ui/documentation_links';
-
-import { createUiStatsReporter } from '../../../../../src/legacy/core_plugins/ui_metric/public';
-
-export function createShim() {
- const {
- core: { chrome, i18n, notifications, http, injectedMetadata },
- } = npStart;
-
- return {
- coreStart: {
- chrome,
- i18n,
- notifications,
- fatalError,
- injectedMetadata,
- http,
- documentation: {
- elasticWebsiteUrl: ELASTIC_WEBSITE_URL,
- docLinkVersion: DOC_LINK_VERSION,
- },
- },
- pluginsStart: {
- management: {
- getSection: management.getSection.bind(management),
- breadcrumb: MANAGEMENT_BREADCRUMB,
- },
- uiMetric: {
- createUiStatsReporter,
- },
- },
- };
-}
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/constants.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/constants.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/constants.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/constants.js
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/http_requests.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/http_requests.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/http_requests.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/http_requests.js
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/index.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.js
similarity index 96%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/index.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.js
index 084a370666e45..d70ba2a21e176 100644
--- a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/index.js
+++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.js
@@ -8,7 +8,7 @@ import { setup as remoteClustersAddSetup } from './remote_clusters_add.helpers';
import { setup as remoteClustersEditSetup } from './remote_clusters_edit.helpers';
import { setup as remoteClustersListSetup } from './remote_clusters_list.helpers';
-export { nextTick, getRandomString, findTestSubject } from '../../../../../../test_utils';
+export { nextTick, getRandomString, findTestSubject } from '../../../../../test_utils';
export { setupEnvironment } from './setup_environment';
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_add.helpers.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_add.helpers.js
similarity index 66%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_add.helpers.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_add.helpers.js
index e573a4ebcef92..dd1d5d2187176 100644
--- a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_add.helpers.js
+++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_add.helpers.js
@@ -4,10 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { registerTestBed } from '../../../../../../test_utils';
-import { RemoteClusterAdd } from '../../../public/app/sections/remote_cluster_add';
-import { createRemoteClustersStore } from '../../../public/app/store';
-import { registerRouter } from '../../../public/app/services/routing';
+import { registerTestBed } from '../../../../../test_utils';
+
+/* eslint-disable @kbn/eslint/no-restricted-paths */
+import { RemoteClusterAdd } from '../../../public/application/sections/remote_cluster_add';
+import { createRemoteClustersStore } from '../../../public/application/store';
+import { registerRouter } from '../../../public/application/services/routing';
const testBedConfig = {
store: createRemoteClustersStore,
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_edit.helpers.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_edit.helpers.js
similarity index 68%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_edit.helpers.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_edit.helpers.js
index 6a90ed6657c78..426aea90e5a99 100644
--- a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_edit.helpers.js
+++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_edit.helpers.js
@@ -4,10 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { registerTestBed } from '../../../../../../test_utils';
-import { RemoteClusterEdit } from '../../../public/app/sections/remote_cluster_edit';
-import { createRemoteClustersStore } from '../../../public/app/store';
-import { registerRouter } from '../../../public/app/services/routing';
+import { registerTestBed } from '../../../../../test_utils';
+
+/* eslint-disable @kbn/eslint/no-restricted-paths */
+import { RemoteClusterEdit } from '../../../public/application/sections/remote_cluster_edit';
+import { createRemoteClustersStore } from '../../../public/application/store';
+import { registerRouter } from '../../../public/application/services/routing';
import { REMOTE_CLUSTER_EDIT_NAME } from './constants';
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_list.helpers.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_list.helpers.js
similarity index 88%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_list.helpers.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_list.helpers.js
index 0009bd84ffa6a..dc9b22b40542a 100644
--- a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_list.helpers.js
+++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_list.helpers.js
@@ -4,10 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { registerTestBed, findTestSubject } from '../../../../../../test_utils';
-import { RemoteClusterList } from '../../../public/app/sections/remote_cluster_list';
-import { createRemoteClustersStore } from '../../../public/app/store';
-import { registerRouter } from '../../../public/app/services/routing';
+import { registerTestBed, findTestSubject } from '../../../../../test_utils';
+
+/* eslint-disable @kbn/eslint/no-restricted-paths */
+import { RemoteClusterList } from '../../../public/application/sections/remote_cluster_list';
+import { createRemoteClustersStore } from '../../../public/application/store';
+import { registerRouter } from '../../../public/application/services/routing';
const testBedConfig = {
store: createRemoteClustersStore,
diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/setup_environment.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/setup_environment.js
new file mode 100644
index 0000000000000..c912a4ddabc9d
--- /dev/null
+++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/setup_environment.js
@@ -0,0 +1,48 @@
+/*
+ * 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 {
+ notificationServiceMock,
+ fatalErrorsServiceMock,
+ docLinksServiceMock,
+ injectedMetadataServiceMock,
+} from '../../../../../../src/core/public/mocks';
+
+import { usageCollectionPluginMock } from '../../../../../../src/plugins/usage_collection/public/mocks';
+
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { HttpService } from '../../../../../../src/core/public/http';
+
+/* eslint-disable @kbn/eslint/no-restricted-paths */
+import { init as initBreadcrumb } from '../../../public/application/services/breadcrumb';
+import { init as initHttp } from '../../../public/application/services/http';
+import { init as initNotification } from '../../../public/application/services/notification';
+import { init as initUiMetric } from '../../../public/application/services/ui_metric';
+import { init as initDocumentation } from '../../../public/application/services/documentation';
+import { init as initHttpRequests } from './http_requests';
+
+export const setupEnvironment = () => {
+ const httpServiceSetupMock = new HttpService().setup({
+ injectedMetadata: injectedMetadataServiceMock.createSetupContract(),
+ fatalErrors: fatalErrorsServiceMock.createSetupContract(),
+ });
+
+ initBreadcrumb(() => {});
+ initDocumentation(docLinksServiceMock.createStartContract());
+ initUiMetric(usageCollectionPluginMock.createSetupContract());
+ initNotification(
+ notificationServiceMock.createSetupContract().toasts,
+ fatalErrorsServiceMock.createSetupContract()
+ );
+ initHttp(httpServiceSetupMock);
+
+ const { server, httpRequestsMockHelpers } = initHttpRequests();
+
+ return {
+ server,
+ httpRequestsMockHelpers,
+ };
+};
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_add.test.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_add.test.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_add.test.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_add.test.js
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_edit.test.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_edit.test.js
similarity index 93%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_edit.test.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_edit.test.js
index 95dc65a96e30a..cab91854a5114 100644
--- a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_edit.test.js
+++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_edit.test.js
@@ -5,7 +5,7 @@
*/
jest.mock('ui/new_platform');
-import { RemoteClusterForm } from '../../public/app/sections/components/remote_cluster_form';
+import { RemoteClusterForm } from '../../public/application/sections/components/remote_cluster_form';
import { pageHelpers, setupEnvironment, nextTick } from './helpers';
import { REMOTE_CLUSTER_EDIT, REMOTE_CLUSTER_EDIT_NAME } from './helpers/constants';
@@ -31,7 +31,7 @@ describe('Edit Remote cluster', () => {
httpRequestsMockHelpers.setLoadRemoteClustersResponse([REMOTE_CLUSTER_EDIT]);
({ component, find, exists } = setup());
- await nextTick();
+ await nextTick(100); // We need to wait next tick for the mock server response to kick in
component.update();
});
diff --git a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
similarity index 96%
rename from x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
rename to x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
index 699c00e450a1f..1b7c600218cee 100644
--- a/x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
+++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
@@ -12,7 +12,7 @@ import {
findTestSubject,
} from './helpers';
-import { getRouter } from '../../public/app/services';
+import { getRouter } from '../../public/application/services';
import { getRemoteClusterMock } from '../../fixtures/remote_cluster';
jest.mock('ui/new_platform');
@@ -39,11 +39,11 @@ describe('', () => {
describe('on component mount', () => {
let exists;
- beforeEach(async () => {
+ beforeEach(() => {
({ exists } = setup());
});
- test('should show a "loading remote clusters" indicator', async () => {
+ test('should show a "loading remote clusters" indicator', () => {
expect(exists('remoteClustersTableLoading')).toBe(true);
});
});
@@ -55,7 +55,7 @@ describe('', () => {
beforeEach(async () => {
({ exists, component } = setup());
- await nextTick(); // We need to wait next tick for the mock server response to kick in
+ await nextTick(100); // We need to wait next tick for the mock server response to kick in
component.update();
});
@@ -97,7 +97,7 @@ describe('', () => {
// Mount the component
({ component, find, exists, table, actions } = setup());
- await nextTick(); // Make sure that the Http request is fulfilled
+ await nextTick(100); // Make sure that the Http request is fulfilled
component.update();
// Read the remote clusters list table
@@ -206,7 +206,7 @@ describe('', () => {
actions.clickBulkDeleteButton();
actions.clickConfirmModalDeleteRemoteCluster();
- await nextTick(550); // there is a 500ms timeout in the api action
+ await nextTick(600); // there is a 500ms timeout in the api action
component.update();
({ rows } = table.getMetaData('remoteClusterListTable'));
diff --git a/x-pack/legacy/plugins/remote_clusters/fixtures/remote_cluster.js b/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js
similarity index 91%
rename from x-pack/legacy/plugins/remote_clusters/fixtures/remote_cluster.js
rename to x-pack/plugins/remote_clusters/fixtures/remote_cluster.js
index 248e2b8232cad..e3e087548cf00 100644
--- a/x-pack/legacy/plugins/remote_clusters/fixtures/remote_cluster.js
+++ b/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js
@@ -3,7 +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.
*/
-import { getRandomString } from '../../../../test_utils';
+import { getRandomString } from '../../../test_utils';
export const getRemoteClusterMock = ({
name = getRandomString(),
diff --git a/x-pack/plugins/remote_clusters/kibana.json b/x-pack/plugins/remote_clusters/kibana.json
index de1e3d1e26865..27ae6802966dd 100644
--- a/x-pack/plugins/remote_clusters/kibana.json
+++ b/x-pack/plugins/remote_clusters/kibana.json
@@ -1,9 +1,17 @@
{
"id": "remote_clusters",
"version": "kibana",
+ "configPath": [
+ "xpack",
+ "remote_clusters"
+ ],
"requiredPlugins": [
- "licensing"
+ "licensing",
+ "management"
+ ],
+ "optionalPlugins": [
+ "usageCollection"
],
"server": true,
- "ui": false
+ "ui": true
}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/app.js b/x-pack/plugins/remote_clusters/public/application/app.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/app.js
rename to x-pack/plugins/remote_clusters/public/application/app.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/constants/index.ts b/x-pack/plugins/remote_clusters/public/application/constants/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/constants/index.ts
rename to x-pack/plugins/remote_clusters/public/application/constants/index.ts
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/constants/paths.ts b/x-pack/plugins/remote_clusters/public/application/constants/paths.ts
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/constants/paths.ts
rename to x-pack/plugins/remote_clusters/public/application/constants/paths.ts
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/constants/ui_metric.ts b/x-pack/plugins/remote_clusters/public/application/constants/ui_metric.ts
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/constants/ui_metric.ts
rename to x-pack/plugins/remote_clusters/public/application/constants/ui_metric.ts
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/redirect.js b/x-pack/plugins/remote_clusters/public/application/index.d.ts
similarity index 50%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/redirect.js
rename to x-pack/plugins/remote_clusters/public/application/index.d.ts
index ec77c2a2bfe99..b5c5ad5522134 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/redirect.js
+++ b/x-pack/plugins/remote_clusters/public/application/index.d.ts
@@ -4,14 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
-// This depends upon Angular, which is why we use this provider pattern to access it within
-// our React app.
-let _redirect;
+import { RegisterManagementAppArgs, I18nStart } from '../types';
-export function setRedirect(redirect) {
- _redirect = redirect;
-}
-
-export function redirect(path) {
- _redirect(path);
-}
+export declare const renderApp: (
+ elem: HTMLElement | null,
+ I18nContext: I18nStart['Context']
+) => ReturnType;
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/index.js b/x-pack/plugins/remote_clusters/public/application/index.js
similarity index 80%
rename from x-pack/legacy/plugins/remote_clusters/public/app/index.js
rename to x-pack/plugins/remote_clusters/public/application/index.js
index 2de59f4590553..0b8b26ace5daa 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/index.js
+++ b/x-pack/plugins/remote_clusters/public/application/index.js
@@ -5,14 +5,14 @@
*/
import React from 'react';
-import { render } from 'react-dom';
+import { render, unmountComponentAtNode } from 'react-dom';
import { HashRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { App } from './app';
import { remoteClustersStore } from './store';
-export const renderReact = async (elem, I18nContext) => {
+export const renderApp = (elem, I18nContext) => {
render(
@@ -23,4 +23,5 @@ export const renderReact = async (elem, I18nContext) => {
,
elem
);
+ return () => unmountComponentAtNode(elem);
};
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/configured_by_node_warning/configured_by_node_warning.js b/x-pack/plugins/remote_clusters/public/application/sections/components/configured_by_node_warning/configured_by_node_warning.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/configured_by_node_warning/configured_by_node_warning.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/configured_by_node_warning/configured_by_node_warning.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/configured_by_node_warning/index.js b/x-pack/plugins/remote_clusters/public/application/sections/components/configured_by_node_warning/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/configured_by_node_warning/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/configured_by_node_warning/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/index.js b/x-pack/plugins/remote_clusters/public/application/sections/components/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/index.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/remote_cluster_form.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.js
similarity index 99%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/remote_cluster_form.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.js
index f070bb218be42..08cd01496a8b9 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/remote_cluster_form.js
+++ b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.js
@@ -491,7 +491,7 @@ export class RemoteClusterForm extends Component {
let errorBody;
- if (cause) {
+ if (cause && Array.isArray(cause)) {
if (cause.length === 1) {
errorBody = {cause[0]}
;
} else {
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/remote_cluster_form.test.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.test.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/remote_cluster_form.test.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.test.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/request_flyout.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/request_flyout.js
similarity index 97%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/request_flyout.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/request_flyout.js
index deec26129abe5..70e2267001e3c 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/request_flyout.js
+++ b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/request_flyout.js
@@ -26,7 +26,7 @@ import {
EuiTitle,
} from '@elastic/eui';
-import { serializeCluster } from '../../../../../common';
+import { serializeCluster } from '../../../../../common/constants';
export class RequestFlyout extends PureComponent {
static propTypes = {
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/__snapshots__/validate_name.test.js.snap b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/__snapshots__/validate_name.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/__snapshots__/validate_name.test.js.snap
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/__snapshots__/validate_name.test.js.snap
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/__snapshots__/validate_seeds.test.js.snap b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/__snapshots__/validate_seeds.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/__snapshots__/validate_seeds.test.js.snap
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/__snapshots__/validate_seeds.test.js.snap
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/index.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_name.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_name.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_name.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_name.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_name.test.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_name.test.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_name.test.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_name.test.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seed.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seed.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seed.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seed.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seed.test.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seed.test.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seed.test.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seed.test.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seeds.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seeds.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seeds.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seeds.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seeds.test.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seeds.test.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_form/validators/validate_seeds.test.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/validators/validate_seeds.test.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_page_title/index.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_page_title/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_page_title/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_page_title/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_page_title/remote_cluster_page_title.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_page_title/remote_cluster_page_title.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/components/remote_cluster_page_title/remote_cluster_page_title.js
rename to x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_page_title/remote_cluster_page_title.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/index.js b/x-pack/plugins/remote_clusters/public/application/sections/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_add/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_add/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_add/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_add/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_add/remote_cluster_add.container.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_add/remote_cluster_add.container.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_add/remote_cluster_add.container.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_add/remote_cluster_add.container.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_add/remote_cluster_add.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_add/remote_cluster_add.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_add/remote_cluster_add.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_add/remote_cluster_add.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_edit/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_edit/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_edit/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_edit/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_edit/remote_cluster_edit.container.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_edit/remote_cluster_edit.container.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_edit/remote_cluster_edit.container.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_edit/remote_cluster_edit.container.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_edit/remote_cluster_edit.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_edit/remote_cluster_edit.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_edit/remote_cluster_edit.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_edit/remote_cluster_edit.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/connection_status/connection_status.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/connection_status/connection_status.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/connection_status/connection_status.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/connection_status/connection_status.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/connection_status/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/connection_status/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/connection_status/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/connection_status/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/remove_cluster_button_provider/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/remove_cluster_button_provider/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/remove_cluster_button_provider/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/remove_cluster_button_provider/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.container.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.container.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.container.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.container.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/components/remove_cluster_button_provider/remove_cluster_button_provider.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/detail_panel/detail_panel.container.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/detail_panel/detail_panel.container.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/detail_panel/detail_panel.container.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/detail_panel/detail_panel.container.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/detail_panel/detail_panel.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/detail_panel/detail_panel.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/detail_panel/detail_panel.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/detail_panel/detail_panel.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/detail_panel/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/detail_panel/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/detail_panel/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/detail_panel/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_list.container.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_list.container.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_list.container.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_list.container.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_list.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_list.js
similarity index 98%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_list.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_list.js
index dea6bc7627cc1..207aa8045c011 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_list.js
+++ b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_list.js
@@ -145,9 +145,9 @@ export class RemoteClusterList extends Component {
}
renderError(error) {
- // We can safely depend upon the shape of this error coming from Angular $http, because we
+ // We can safely depend upon the shape of this error coming from http service, because we
// handle unexpected error shapes in the API action.
- const { statusCode, error: errorString } = error.data;
+ const { statusCode, error: errorString } = error.body;
const title = i18n.translate('xpack.remoteClusters.remoteClusterList.loadingErrorTitle', {
defaultMessage: 'Error loading remote clusters',
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_table/index.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_table/index.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.container.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.container.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.container.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.container.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js
rename to x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/api.js b/x-pack/plugins/remote_clusters/public/application/services/api.js
similarity index 93%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/api.js
rename to x-pack/plugins/remote_clusters/public/application/services/api.js
index 8631bc5af12a8..72d5e3f9c3f9e 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/api.js
+++ b/x-pack/plugins/remote_clusters/public/application/services/api.js
@@ -9,19 +9,19 @@ import { trackUserRequest } from './ui_metric';
import { sendGet, sendPost, sendPut, sendDelete } from './http';
export async function loadClusters() {
- const response = await sendGet();
- return response.data;
+ return await sendGet();
}
export async function addCluster(cluster) {
const request = sendPost('', cluster);
+
return await trackUserRequest(request, UIM_CLUSTER_ADD);
}
export async function editCluster(cluster) {
const { name, ...rest } = cluster;
-
const request = sendPut(name, rest);
+
return await trackUserRequest(request, UIM_CLUSTER_UPDATE);
}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/api_errors.js b/x-pack/plugins/remote_clusters/public/application/services/api_errors.js
similarity index 77%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/api_errors.js
rename to x-pack/plugins/remote_clusters/public/application/services/api_errors.js
index c50ad92532071..8376f37f36f49 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/api_errors.js
+++ b/x-pack/plugins/remote_clusters/public/application/services/api_errors.js
@@ -4,12 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { fatalError, toasts } from './notification';
+import { toasts, fatalError } from './notification';
function createToastConfig(error, errorTitle) {
- // Expect an error in the shape provided by Angular's $http service.
- if (error && error.data) {
- const { error: errorString, statusCode, message } = error.data;
+ // Expect an error in the shape provided by http service.
+ if (error && error.body) {
+ const { error: errorString, statusCode, message } = error.body;
return {
title: errorTitle,
text: `${statusCode}: ${errorString}. ${message}`,
@@ -26,7 +26,7 @@ export function showApiWarning(error, errorTitle) {
// This error isn't an HTTP error, so let the fatal error screen tell the user something
// unexpected happened.
- return fatalError(error, errorTitle);
+ return fatalError.add(error, errorTitle);
}
export function showApiError(error, errorTitle) {
@@ -38,5 +38,5 @@ export function showApiError(error, errorTitle) {
// This error isn't an HTTP error, so let the fatal error screen tell the user something
// unexpected happened.
- fatalError(error, errorTitle);
+ fatalError.add(error, errorTitle);
}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/breadcrumb.ts b/x-pack/plugins/remote_clusters/public/application/services/breadcrumb.ts
similarity index 68%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/breadcrumb.ts
rename to x-pack/plugins/remote_clusters/public/application/services/breadcrumb.ts
index 68d34cc2a17d4..f90a0d3456166 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/breadcrumb.ts
+++ b/x-pack/plugins/remote_clusters/public/application/services/breadcrumb.ts
@@ -8,13 +8,22 @@ import { i18n } from '@kbn/i18n';
import { CRUD_APP_BASE_PATH } from '../constants';
-let _setBreadcrumbs: any;
-let _breadcrumbs: any;
+interface Breadcrumb {
+ text: string;
+ href?: string;
+}
+interface Breadcrumbs {
+ home: Breadcrumb;
+ add: Breadcrumb;
+ edit: Breadcrumb;
+}
+
+let _setBreadcrumbs: (breadcrumbs: Breadcrumb[]) => void;
+let _breadcrumbs: Breadcrumbs;
-export function init(setGlobalBreadcrumbs: any, managementBreadcrumb: any): void {
+export function init(setGlobalBreadcrumbs: (breadcrumbs: Breadcrumb[]) => void): void {
_setBreadcrumbs = setGlobalBreadcrumbs;
_breadcrumbs = {
- management: managementBreadcrumb,
home: {
text: i18n.translate('xpack.remoteClusters.listBreadcrumbTitle', {
defaultMessage: 'Remote Clusters',
@@ -34,13 +43,13 @@ export function init(setGlobalBreadcrumbs: any, managementBreadcrumb: any): void
};
}
-export function setBreadcrumbs(type: string, queryParams?: string): void {
+export function setBreadcrumbs(type: 'home' | 'add' | 'edit', queryParams?: string): void {
if (!_breadcrumbs[type]) {
return;
}
if (type === 'home') {
- _setBreadcrumbs([_breadcrumbs.management, _breadcrumbs.home]);
+ _setBreadcrumbs([_breadcrumbs.home]);
} else {
// Support deep-linking back to a remote cluster in the detail panel.
const homeBreadcrumb = {
@@ -48,6 +57,6 @@ export function setBreadcrumbs(type: string, queryParams?: string): void {
href: `${_breadcrumbs.home.href}${queryParams}`,
};
- _setBreadcrumbs([_breadcrumbs.management, homeBreadcrumb, _breadcrumbs[type]]);
+ _setBreadcrumbs([homeBreadcrumb, _breadcrumbs[type]]);
}
}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/documentation.ts b/x-pack/plugins/remote_clusters/public/application/services/documentation.ts
similarity index 70%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/documentation.ts
rename to x-pack/plugins/remote_clusters/public/application/services/documentation.ts
index 4d04aa6fad74d..38cf2223a313b 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/documentation.ts
+++ b/x-pack/plugins/remote_clusters/public/application/services/documentation.ts
@@ -4,11 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { DocLinksStart } from 'kibana/public';
+
export let skippingDisconnectedClustersUrl: string;
export let remoteClustersUrl: string;
export let transportPortUrl: string;
-export function init(esDocBasePath: string): void {
+export function init(docLinks: DocLinksStart): void {
+ const { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL } = docLinks;
+ const esDocBasePath = `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}`;
+
skippingDisconnectedClustersUrl = `${esDocBasePath}/modules-cross-cluster-search.html#_skipping_disconnected_clusters`;
remoteClustersUrl = `${esDocBasePath}/modules-remote-clusters.html`;
transportPortUrl = `${esDocBasePath}/modules-transport.html`;
diff --git a/x-pack/plugins/remote_clusters/public/application/services/http.ts b/x-pack/plugins/remote_clusters/public/application/services/http.ts
new file mode 100644
index 0000000000000..b49e95f3a5c65
--- /dev/null
+++ b/x-pack/plugins/remote_clusters/public/application/services/http.ts
@@ -0,0 +1,55 @@
+/*
+ * 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, HttpResponse } from 'kibana/public';
+import { API_BASE_PATH } from '../../../common/constants';
+
+let _httpClient: HttpSetup;
+
+export function init(httpClient: HttpSetup): void {
+ _httpClient = httpClient;
+}
+
+export function getFullPath(path: string): string {
+ if (path) {
+ return `${API_BASE_PATH}/${path}`;
+ }
+
+ return API_BASE_PATH;
+}
+
+export function sendPost(
+ path: string,
+ payload: {
+ name: string;
+ seeds: string[];
+ skipUnavailable: boolean;
+ }
+): Promise {
+ return _httpClient.post(getFullPath(path), {
+ body: JSON.stringify(payload),
+ });
+}
+
+export function sendGet(path: string): Promise {
+ return _httpClient.get(getFullPath(path));
+}
+
+export function sendPut(
+ path: string,
+ payload: {
+ seeds: string[];
+ skipUnavailable: boolean;
+ }
+): Promise {
+ return _httpClient.put(getFullPath(path), {
+ body: JSON.stringify(payload),
+ });
+}
+
+export function sendDelete(path: string): Promise {
+ return _httpClient.delete(getFullPath(path));
+}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/index.js b/x-pack/plugins/remote_clusters/public/application/services/index.js
similarity index 93%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/index.js
rename to x-pack/plugins/remote_clusters/public/application/services/index.js
index 69679e55dfef5..031770d9500ed 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/index.js
+++ b/x-pack/plugins/remote_clusters/public/application/services/index.js
@@ -8,7 +8,7 @@ export { loadClusters, addCluster, editCluster, removeClusterRequest } from './a
export { showApiError, showApiWarning } from './api_errors';
-export { setRedirect, redirect } from './redirect';
+export { initRedirect, redirect } from './redirect';
export { isSeedNodeValid, isSeedNodePortValid } from './validate_seed_node';
diff --git a/x-pack/plugins/remote_clusters/public/application/services/notification.ts b/x-pack/plugins/remote_clusters/public/application/services/notification.ts
new file mode 100644
index 0000000000000..1c9173e519b48
--- /dev/null
+++ b/x-pack/plugins/remote_clusters/public/application/services/notification.ts
@@ -0,0 +1,15 @@
+/*
+ * 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 { NotificationsSetup, FatalErrorsSetup } from 'src/core/public';
+
+export let toasts: NotificationsSetup['toasts'];
+export let fatalError: FatalErrorsSetup;
+
+export function init(_toasts: NotificationsSetup['toasts'], _fatalError: FatalErrorsSetup): void {
+ toasts = _toasts;
+ fatalError = _fatalError;
+}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/query_params.js b/x-pack/plugins/remote_clusters/public/application/services/query_params.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/query_params.js
rename to x-pack/plugins/remote_clusters/public/application/services/query_params.js
diff --git a/x-pack/plugins/remote_clusters/public/application/services/redirect.ts b/x-pack/plugins/remote_clusters/public/application/services/redirect.ts
new file mode 100644
index 0000000000000..00a97fa74c5ce
--- /dev/null
+++ b/x-pack/plugins/remote_clusters/public/application/services/redirect.ts
@@ -0,0 +1,17 @@
+/*
+ * 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 { CoreStart } from 'kibana/public';
+
+let navigateToApp: CoreStart['application']['navigateToApp'];
+
+export function init(_navigateToApp: CoreStart['application']['navigateToApp']) {
+ navigateToApp = _navigateToApp;
+}
+
+export function redirect(path: string) {
+ navigateToApp('kibana', { path: `#${path}` });
+}
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/routing.js b/x-pack/plugins/remote_clusters/public/application/services/routing.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/routing.js
rename to x-pack/plugins/remote_clusters/public/application/services/routing.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/ui_metric.ts b/x-pack/plugins/remote_clusters/public/application/services/ui_metric.ts
similarity index 62%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/ui_metric.ts
rename to x-pack/plugins/remote_clusters/public/application/services/ui_metric.ts
index 36a23476c1873..91354155cacb0 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/ui_metric.ts
+++ b/x-pack/plugins/remote_clusters/public/application/services/ui_metric.ts
@@ -4,17 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
+import { UiStatsMetricType } from '@kbn/analytics';
import { UIM_APP_NAME } from '../constants';
-import {
- createUiStatsReporter,
- METRIC_TYPE,
-} from '../../../../../../../src/legacy/core_plugins/ui_metric/public';
-export let trackUiMetric: ReturnType;
-export { METRIC_TYPE };
+export let trackUiMetric: (metricType: UiStatsMetricType, eventName: string) => void;
+export let METRIC_TYPE: UsageCollectionSetup['METRIC_TYPE'];
-export function init(getReporter: typeof createUiStatsReporter): void {
- trackUiMetric = getReporter(UIM_APP_NAME);
+export function init(usageCollection: UsageCollectionSetup): void {
+ trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
+ METRIC_TYPE = usageCollection.METRIC_TYPE;
}
/**
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/validate_seed_node.js b/x-pack/plugins/remote_clusters/public/application/services/validate_seed_node.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/validate_seed_node.js
rename to x-pack/plugins/remote_clusters/public/application/services/validate_seed_node.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/validate_seed_node.test.js b/x-pack/plugins/remote_clusters/public/application/services/validate_seed_node.test.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/validate_seed_node.test.js
rename to x-pack/plugins/remote_clusters/public/application/services/validate_seed_node.test.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/action_types.js b/x-pack/plugins/remote_clusters/public/application/store/action_types.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/action_types.js
rename to x-pack/plugins/remote_clusters/public/application/store/action_types.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/add_cluster.js b/x-pack/plugins/remote_clusters/public/application/store/actions/add_cluster.js
similarity index 88%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/actions/add_cluster.js
rename to x-pack/plugins/remote_clusters/public/application/store/actions/add_cluster.js
index 726bc56b08f12..0b7838f48b137 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/add_cluster.js
+++ b/x-pack/plugins/remote_clusters/public/application/store/actions/add_cluster.js
@@ -35,12 +35,12 @@ export const addCluster = cluster => async dispatch => {
]);
} catch (error) {
if (error) {
- const { statusCode, data } = error;
+ const { body } = error;
- // Expect an error in the shape provided by Angular's $http service.
- if (data) {
- // Some errors have statusCode directly available but some are under a data property.
- if ((statusCode || (data && data.statusCode)) === 409) {
+ // Expect an error in the shape provided by http service.
+ if (body) {
+ const { statusCode, message } = body;
+ if (statusCode && statusCode === 409) {
return dispatch({
type: ADD_CLUSTER_FAILURE,
payload: {
@@ -63,9 +63,8 @@ export const addCluster = cluster => async dispatch => {
error: {
message: i18n.translate('xpack.remoteClusters.addAction.failedDefaultErrorMessage', {
defaultMessage: 'Request failed with a {statusCode} error. {message}',
- values: { statusCode, message: data.message },
+ values: { statusCode, message },
}),
- cause: data.cause,
},
},
});
@@ -74,7 +73,7 @@ export const addCluster = cluster => async dispatch => {
// This error isn't an HTTP error, so let the fatal error screen tell the user something
// unexpected happened.
- return fatalError(
+ return fatalError.add(
error,
i18n.translate('xpack.remoteClusters.addAction.errorTitle', {
defaultMessage: 'Error adding cluster',
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/detail_panel.js b/x-pack/plugins/remote_clusters/public/application/store/actions/detail_panel.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/actions/detail_panel.js
rename to x-pack/plugins/remote_clusters/public/application/store/actions/detail_panel.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/edit_cluster.js b/x-pack/plugins/remote_clusters/public/application/store/actions/edit_cluster.js
similarity index 90%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/actions/edit_cluster.js
rename to x-pack/plugins/remote_clusters/public/application/store/actions/edit_cluster.js
index 3ed481aa0f8ea..062704472521e 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/edit_cluster.js
+++ b/x-pack/plugins/remote_clusters/public/application/store/actions/edit_cluster.js
@@ -6,7 +6,7 @@
import { i18n } from '@kbn/i18n';
-import { fatalError, toasts } from '../../services/notification';
+import { toasts, fatalError } from '../../services/notification';
import { CRUD_APP_BASE_PATH } from '../../constants';
import { loadClusters } from './load_clusters';
@@ -39,19 +39,19 @@ export const editCluster = cluster => async dispatch => {
]);
} catch (error) {
if (error) {
- const { statusCode, data } = error;
+ const { body } = error;
- // Expect an error in the shape provided by Angular's $http service.
- if (data) {
+ // Expect an error in the shape provided by http service.
+ if (body) {
+ const { statusCode, message } = body;
return dispatch({
type: EDIT_CLUSTER_FAILURE,
payload: {
error: {
message: i18n.translate('xpack.remoteClusters.editAction.failedDefaultErrorMessage', {
defaultMessage: 'Request failed with a {statusCode} error. {message}',
- values: { statusCode, message: data.message },
+ values: { statusCode, message },
}),
- cause: data.cause,
},
},
});
@@ -60,7 +60,7 @@ export const editCluster = cluster => async dispatch => {
// This error isn't an HTTP error, so let the fatal error screen tell the user something
// unexpected happened.
- return fatalError(
+ return fatalError.add(
error,
i18n.translate('xpack.remoteClusters.editAction.errorTitle', {
defaultMessage: 'Error editing cluster',
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/index.js b/x-pack/plugins/remote_clusters/public/application/store/actions/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/actions/index.js
rename to x-pack/plugins/remote_clusters/public/application/store/actions/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/load_clusters.js b/x-pack/plugins/remote_clusters/public/application/store/actions/load_clusters.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/actions/load_clusters.js
rename to x-pack/plugins/remote_clusters/public/application/store/actions/load_clusters.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/refresh_clusters.js b/x-pack/plugins/remote_clusters/public/application/store/actions/refresh_clusters.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/actions/refresh_clusters.js
rename to x-pack/plugins/remote_clusters/public/application/store/actions/refresh_clusters.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/remove_clusters.js b/x-pack/plugins/remote_clusters/public/application/store/actions/remove_clusters.js
similarity index 95%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/actions/remove_clusters.js
rename to x-pack/plugins/remote_clusters/public/application/store/actions/remove_clusters.js
index 4086a91e29021..8e22eac8b292b 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/store/actions/remove_clusters.js
+++ b/x-pack/plugins/remote_clusters/public/application/store/actions/remove_clusters.js
@@ -30,7 +30,7 @@ function getErrorTitle(count, name = null) {
}
} else {
return i18n.translate('xpack.remoteClusters.removeAction.errorMultipleNotificationTitle', {
- defaultMessage: `Error removing '{count}' remote clusters`,
+ defaultMessage: `Error removing {count} remote clusters`,
values: { count },
});
}
@@ -46,7 +46,7 @@ export const removeClusters = names => async (dispatch, getState) => {
await Promise.all([
sendRemoveClusterRequest(names.join(',')).then(response => {
- ({ itemsDeleted, errors } = response.data);
+ ({ itemsDeleted, errors } = response);
}),
// Wait at least half a second to avoid a weird flicker of the saving feedback (only visible
// when requests resolve very quickly).
@@ -55,7 +55,7 @@ export const removeClusters = names => async (dispatch, getState) => {
const errorTitle = getErrorTitle(names.length, names[0]);
toasts.addDanger({
title: errorTitle,
- text: error.data.message,
+ text: error.body?.message,
});
});
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/index.js b/x-pack/plugins/remote_clusters/public/application/store/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/index.js
rename to x-pack/plugins/remote_clusters/public/application/store/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/middleware/detail_panel.js b/x-pack/plugins/remote_clusters/public/application/store/middleware/detail_panel.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/middleware/detail_panel.js
rename to x-pack/plugins/remote_clusters/public/application/store/middleware/detail_panel.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/middleware/index.js b/x-pack/plugins/remote_clusters/public/application/store/middleware/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/middleware/index.js
rename to x-pack/plugins/remote_clusters/public/application/store/middleware/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/add_cluster.js b/x-pack/plugins/remote_clusters/public/application/store/reducers/add_cluster.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/add_cluster.js
rename to x-pack/plugins/remote_clusters/public/application/store/reducers/add_cluster.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/clusters.js b/x-pack/plugins/remote_clusters/public/application/store/reducers/clusters.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/clusters.js
rename to x-pack/plugins/remote_clusters/public/application/store/reducers/clusters.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/detail_panel.js b/x-pack/plugins/remote_clusters/public/application/store/reducers/detail_panel.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/detail_panel.js
rename to x-pack/plugins/remote_clusters/public/application/store/reducers/detail_panel.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/edit_cluster.js b/x-pack/plugins/remote_clusters/public/application/store/reducers/edit_cluster.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/edit_cluster.js
rename to x-pack/plugins/remote_clusters/public/application/store/reducers/edit_cluster.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/index.js b/x-pack/plugins/remote_clusters/public/application/store/reducers/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/index.js
rename to x-pack/plugins/remote_clusters/public/application/store/reducers/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/remove_cluster.js b/x-pack/plugins/remote_clusters/public/application/store/reducers/remove_cluster.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/reducers/remove_cluster.js
rename to x-pack/plugins/remote_clusters/public/application/store/reducers/remove_cluster.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/selectors/index.js b/x-pack/plugins/remote_clusters/public/application/store/selectors/index.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/selectors/index.js
rename to x-pack/plugins/remote_clusters/public/application/store/selectors/index.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/store/store.js b/x-pack/plugins/remote_clusters/public/application/store/store.js
similarity index 100%
rename from x-pack/legacy/plugins/remote_clusters/public/app/store/store.js
rename to x-pack/plugins/remote_clusters/public/application/store/store.js
diff --git a/x-pack/legacy/plugins/remote_clusters/public/app/services/notification.ts b/x-pack/plugins/remote_clusters/public/index.ts
similarity index 59%
rename from x-pack/legacy/plugins/remote_clusters/public/app/services/notification.ts
rename to x-pack/plugins/remote_clusters/public/index.ts
index 1ac329253cddb..dbe22b71b48df 100644
--- a/x-pack/legacy/plugins/remote_clusters/public/app/services/notification.ts
+++ b/x-pack/plugins/remote_clusters/public/index.ts
@@ -3,11 +3,6 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
+import { RemoteClustersUIPlugin } from './plugin';
-export let toasts: any;
-export let fatalError: any;
-
-export function init(_toasts: any, _fatalError: any): void {
- toasts = _toasts;
- fatalError = _fatalError;
-}
+export const plugin = () => new RemoteClustersUIPlugin();
diff --git a/x-pack/plugins/remote_clusters/public/plugin.ts b/x-pack/plugins/remote_clusters/public/plugin.ts
new file mode 100644
index 0000000000000..5b84fa1fde369
--- /dev/null
+++ b/x-pack/plugins/remote_clusters/public/plugin.ts
@@ -0,0 +1,55 @@
+/*
+ * 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 { CoreSetup, Plugin, CoreStart } from 'kibana/public';
+import { init as initBreadcrumbs } from './application/services/breadcrumb';
+import { init as initDocumentation } from './application/services/documentation';
+import { init as initHttp } from './application/services/http';
+import { init as initUiMetric } from './application/services/ui_metric';
+import { init as initNotification } from './application/services/notification';
+import { init as initRedirect } from './application/services/redirect';
+import { Dependencies } from './types';
+
+export class RemoteClustersUIPlugin implements Plugin {
+ setup(
+ { notifications: { toasts }, http, getStartServices }: CoreSetup,
+ { management, usageCollection }: Dependencies
+ ) {
+ const esSection = management.sections.getSection('elasticsearch');
+
+ esSection!.registerApp({
+ id: 'remote_clusters',
+ title: i18n.translate('xpack.remoteClusters.appTitle', {
+ defaultMessage: 'Remote Clusters',
+ }),
+ mount: async ({ element, setBreadcrumbs }) => {
+ const [core] = await getStartServices();
+ const {
+ i18n: { Context: i18nContext },
+ docLinks,
+ fatalErrors,
+ } = core;
+
+ // Initialize services
+ initBreadcrumbs(setBreadcrumbs);
+ initDocumentation(docLinks);
+ initUiMetric(usageCollection);
+ initNotification(toasts, fatalErrors);
+ initHttp(http);
+
+ const { renderApp } = await import('./application');
+ return renderApp(element, i18nContext);
+ },
+ });
+ }
+
+ start({ application }: CoreStart) {
+ initRedirect(application.navigateToApp);
+ }
+
+ stop() {}
+}
diff --git a/x-pack/plugins/remote_clusters/public/types.ts b/x-pack/plugins/remote_clusters/public/types.ts
new file mode 100644
index 0000000000000..45ae90f91587a
--- /dev/null
+++ b/x-pack/plugins/remote_clusters/public/types.ts
@@ -0,0 +1,19 @@
+/*
+ * 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 { ManagementSetup } from 'src/plugins/management/public';
+import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
+import { RegisterManagementAppArgs } from 'src/plugins/management/public';
+import { I18nStart } from 'kibana/public';
+
+export interface Dependencies {
+ management: ManagementSetup;
+ usageCollection: UsageCollectionSetup;
+}
+
+export { RegisterManagementAppArgs };
+
+export { I18nStart };
diff --git a/x-pack/plugins/remote_clusters/server/config.ts b/x-pack/plugins/remote_clusters/server/config.ts
new file mode 100644
index 0000000000000..9525fe1e2a0db
--- /dev/null
+++ b/x-pack/plugins/remote_clusters/server/config.ts
@@ -0,0 +1,21 @@
+/*
+ * 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 { schema, TypeOf } from '@kbn/config-schema';
+import { PluginConfigDescriptor } from 'kibana/server';
+
+export const configSchema = schema.object({
+ enabled: schema.boolean({ defaultValue: true }),
+});
+
+export type ConfigType = TypeOf;
+
+export const config: PluginConfigDescriptor = {
+ schema: configSchema,
+ exposeToBrowser: {
+ enabled: true,
+ },
+};
diff --git a/x-pack/plugins/remote_clusters/server/index.ts b/x-pack/plugins/remote_clusters/server/index.ts
index 896161d82919b..927fa768fc9fd 100644
--- a/x-pack/plugins/remote_clusters/server/index.ts
+++ b/x-pack/plugins/remote_clusters/server/index.ts
@@ -6,4 +6,6 @@
import { PluginInitializerContext } from 'kibana/server';
import { RemoteClustersServerPlugin } from './plugin';
+export { config } from './config';
+
export const plugin = (ctx: PluginInitializerContext) => new RemoteClustersServerPlugin(ctx);
diff --git a/x-pack/plugins/remote_clusters/server/plugin.ts b/x-pack/plugins/remote_clusters/server/plugin.ts
index dd0bb536d2695..d15ae44c8d5db 100644
--- a/x-pack/plugins/remote_clusters/server/plugin.ts
+++ b/x-pack/plugins/remote_clusters/server/plugin.ts
@@ -6,10 +6,12 @@
import { i18n } from '@kbn/i18n';
import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'src/core/server';
-import { PLUGIN } from '../common/constants';
+import { Observable } from 'rxjs';
import { LICENSE_CHECK_STATE } from '../../licensing/common/types';
-import { Dependencies, LicenseStatus, RouteDependencies } from './types';
+import { PLUGIN } from '../common/constants';
+import { Dependencies, LicenseStatus, RouteDependencies } from './types';
+import { ConfigType } from './config';
import {
registerGetRoute,
registerAddRoute,
@@ -20,9 +22,11 @@ import {
export class RemoteClustersServerPlugin implements Plugin {
licenseStatus: LicenseStatus;
log: Logger;
+ config: Observable;
- constructor({ logger }: PluginInitializerContext) {
+ constructor({ logger, config }: PluginInitializerContext) {
this.log = logger.get();
+ this.config = config.create();
this.licenseStatus = { valid: false };
}
diff --git a/x-pack/plugins/remote_clusters/server/routes/api/add_route.ts b/x-pack/plugins/remote_clusters/server/routes/api/add_route.ts
index aa09b6bf45667..e4ede01ca23ea 100644
--- a/x-pack/plugins/remote_clusters/server/routes/api/add_route.ts
+++ b/x-pack/plugins/remote_clusters/server/routes/api/add_route.ts
@@ -38,8 +38,7 @@ export const register = (deps: RouteDependencies): void => {
// Check if cluster already exists.
const existingCluster = await doesClusterExist(callAsCurrentUser, name);
if (existingCluster) {
- return response.customError({
- statusCode: 409,
+ return response.conflict({
body: {
message: i18n.translate(
'xpack.remoteClusters.addRemoteCluster.existingRemoteClusterErrorMessage',
diff --git a/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts b/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts
index fd707f15ad11e..ed584307d84c1 100644
--- a/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts
+++ b/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts
@@ -44,8 +44,7 @@ export const register = (deps: RouteDependencies): void => {
// Check if cluster does exist.
const existingCluster = await doesClusterExist(callAsCurrentUser, name);
if (!existingCluster) {
- return response.customError({
- statusCode: 404,
+ return response.notFound({
body: {
message: i18n.translate(
'xpack.remoteClusters.updateRemoteCluster.noRemoteClusterErrorMessage',