Skip to content

Commit

Permalink
[Index management] Move to new platform "plugins" folder (#58109)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Feb 25, 2020
1 parent 3333413 commit 277b380
Show file tree
Hide file tree
Showing 365 changed files with 297 additions and 261 deletions.
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"xpack.fileUpload": "legacy/plugins/file_upload",
"xpack.graph": ["legacy/plugins/graph", "plugins/graph"],
"xpack.grokDebugger": "legacy/plugins/grokdebugger",
"xpack.idxMgmt": "legacy/plugins/index_management",
"xpack.idxMgmt": "plugins/index_management",
"xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management",
"xpack.infra": "plugins/infra",
"xpack.ingestManager": "plugins/ingest_manager",
Expand Down
7 changes: 3 additions & 4 deletions x-pack/legacy/plugins/cross_cluster_replication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ export function crossClusterReplication(kibana) {
init: function initCcrPlugin(server) {
registerLicenseChecker(server);
registerRoutes(server);

if (
server.config().get('xpack.ccr.ui.enabled') &&
server.plugins.index_management &&
server.plugins.index_management.addIndexManagementDataEnricher
server.newPlatform.setup.plugins.indexManagement &&
server.newPlatform.setup.plugins.indexManagement.indexDataEnricher
) {
server.plugins.index_management.addIndexManagementDataEnricher(ccrDataEnricher);
server.newPlatform.setup.plugins.indexManagement.indexDataEnricher.add(ccrDataEnricher);
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { getIndexListUri } from '../../../../../../../../index_management/public/application/services/navigation';
import { getIndexListUri } from '../../../../../../../../../../plugins/index_management/public';

import {
EuiButtonEmpty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { getIndexListUri } from '../../../../../../../../index_management/public/application/services/navigation';

import {
EuiButton,
EuiButtonEmpty,
Expand All @@ -31,12 +29,11 @@ import {
EuiTextColor,
EuiTitle,
} from '@elastic/eui';

import 'brace/theme/textmate';

import { ContextMenu } from '../context_menu';

import { getIndexListUri } from '../../../../../../../../../../plugins/index_management/public';
import { API_STATUS } from '../../../../../constants';
import { ContextMenu } from '../context_menu';

export class DetailPanel extends Component {
static propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import { extensionsService } from '../../../index_management/public';
import { npSetup } from 'ui/new_platform';
import { get } from 'lodash';

const propertyPath = 'isFollowerIndex';
export const followerBadgeExtension = {

const followerBadgeExtension = {
matchIndex: index => {
return get(index, propertyPath);
},
Expand All @@ -19,4 +20,6 @@ export const followerBadgeExtension = {
filterExpression: 'isFollowerIndex:true',
};

extensionsService.addBadge(followerBadgeExtension);
if (npSetup.plugins.indexManagement) {
npSetup.plugins.indexManagement.extensionsService.addBadge(followerBadgeExtension);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ initHttp(axios.create({ adapter: axiosXhrAdapter }), path => path);
initUiMetric(() => () => {});

jest.mock('ui/new_platform');
jest.mock('../../index_management/public', async () => {
const { indexManagementMock } = await import('../../index_management/public/mocks.ts');
jest.mock('../../../../plugins/index_management/public', async () => {
const { indexManagementMock } = await import(
'../../../../plugins/index_management/public/mocks.ts'
);
return indexManagementMock.createSetup();
});

Expand Down
8 changes: 4 additions & 4 deletions x-pack/legacy/plugins/index_lifecycle_management/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ export class Plugin {
registerPoliciesRoutes(server);
registerTemplatesRoutes(server);

const serverPlugins = server.plugins as any;
const serverPlugins = server.newPlatform.setup.plugins as any;

if (
server.config().get('xpack.ilm.ui.enabled') &&
serverPlugins.index_management &&
serverPlugins.index_management.addIndexManagementDataEnricher
serverPlugins.indexManagement &&
serverPlugins.indexManagement.indexDataEnricher
) {
serverPlugins.index_management.addIndexManagementDataEnricher(indexLifecycleDataEnricher);
serverPlugins.indexManagement.indexDataEnricher.add(indexLifecycleDataEnricher);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import { addAllExtensions } from './np_ready/extend_index_management';
if (chrome.getInjected('ilmUiEnabled')) {
// We have to initialize this outside of the NP lifecycle, otherwise these extensions won't
// be available in Index Management unless the user visits ILM first.
addAllExtensions();
if ((npSetup.plugins as any).indexManagement) {
addAllExtensions((npSetup.plugins as any).indexManagement.extensionsService);
}

// This method handles the cleanup needed when route is scope is destroyed. It also prevents Angular
// from destroying scope when route changes and both old route and new route are this same route.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {

import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services';

import { getIndexListUri } from '../../../../../../../../index_management/public/application/services/navigation';
import { getIndexListUri } from '../../../../../../../../../../plugins/index_management/public';
import { BASE_PATH } from '../../../../../../../common/constants';
import { UIM_EDIT_CLICK } from '../../../../constants';
import { getPolicyPath } from '../../../../services/navigation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { get, every, any } from 'lodash';
import { i18n } from '@kbn/i18n';
import { EuiSearchBar } from '@elastic/eui';

import { extensionsService } from '../../../../index_management/public';
import { init as initUiMetric } from '../application/services/ui_metric';
import { init as initNotification } from '../application/services/notification';
import { retryLifecycleForIndex } from '../application/services/api';
Expand Down Expand Up @@ -238,7 +237,7 @@ export const ilmFilterExtension = indices => {
}
};

export const addAllExtensions = () => {
export const addAllExtensions = extensionsService => {
extensionsService.addAction(retryLifecycleActionExtension);
extensionsService.addAction(removeLifecyclePolicyActionExtension);
extensionsService.addAction(addLifecyclePolicyActionExtension);
Expand Down
29 changes: 1 addition & 28 deletions x-pack/legacy/plugins/index_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { resolve } from 'path';
import { Legacy } from 'kibana';
import { PLUGIN } from './common/constants';
import { plugin as initServerPlugin, Dependencies } from './server';

export type ServerFacade = Legacy.Server;

export function indexManagement(kibana: any) {
return new kibana.Plugin({
id: PLUGIN.id,
id: 'index_management',
configPrefix: 'xpack.index_management',
publicDir: resolve(__dirname, 'public'),
require: ['kibana', 'elasticsearch', 'xpack_main'],

uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
managementSections: ['plugins/index_management'],
},

init(server: ServerFacade) {
const coreSetup = server.newPlatform.setup.core;
const coreInitializerContext = server.newPlatform.coreContext;
const pluginsSetup: Dependencies = {
licensing: server.newPlatform.setup.plugins.licensing as any,
};

const serverPlugin = initServerPlugin(coreInitializerContext as any);
const serverPublicApi = serverPlugin.setup(coreSetup, pluginsSetup);

server.expose('addIndexManagementDataEnricher', serverPublicApi.indexDataEnricher.add);
},
});
}
3 changes: 0 additions & 3 deletions x-pack/legacy/plugins/index_management/public/index.html

This file was deleted.

4 changes: 3 additions & 1 deletion x-pack/legacy/plugins/remote_clusters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

import { resolve } from 'path';
import { Legacy } from 'kibana';

import { PLUGIN } from './common';

export function remoteClusters(kibana: any) {
Expand All @@ -28,7 +30,7 @@ export function remoteClusters(kibana: any) {
enabled: Joi.boolean().default(true),
}).default();
},
isEnabled(config: any) {
isEnabled(config: Legacy.KibanaConfig) {
return (
config.get('xpack.remote_clusters.enabled') && config.get('xpack.index_management.enabled')
);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/rollup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function rollup(kibana: any) {
},
init(server: any) {
const { core: coreSetup, plugins } = server.newPlatform.setup;
const { usageCollection, metrics } = plugins;
const { usageCollection, metrics, indexManagement } = plugins;

const rollupSetup = (plugins.rollup as unknown) as RollupSetup;

Expand All @@ -54,11 +54,11 @@ export function rollup(kibana: any) {
rollupPluginInstance.setup(coreSetup, {
usageCollection,
metrics,
indexManagement,
__LEGACY: {
plugins: {
xpack_main: server.plugins.xpack_main,
rollup: server.plugins[PLUGIN.ID],
index_management: server.plugins.index_management,
},
},
});
Expand Down
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/rollup/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { aggTypeFieldFilters } from 'ui/agg_types';
import { addSearchStrategy } from '../../../../../src/plugins/data/public';
import { RollupPlugin } from './plugin';
import { setup as management } from '../../../../../src/legacy/core_plugins/management/public/legacy';
import { extensionsService } from '../../index_management/public';

const plugin = new RollupPlugin();

Expand All @@ -20,7 +19,6 @@ export const setup = plugin.setup(npSetup.core, {
aggTypeFilters,
aggTypeFieldFilters,
addSearchStrategy,
indexManagementExtensions: extensionsService,
managementLegacy: management,
},
});
Expand Down
20 changes: 9 additions & 11 deletions x-pack/legacy/plugins/rollup/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
// @ts-ignore
import { CRUD_APP_BASE_PATH } from './crud_app/constants';
import { ManagementSetup } from '../../../../../src/plugins/management/public';
import { IndexMgmtSetup } from '../../index_management/public';
import { IndexMgmtSetup } from '../../../../plugins/index_management/public';
// @ts-ignore
import { setEsBaseAndXPackBase, setHttp } from './crud_app/services';
import { setNotifications, setFatalErrors } from './kibana_services';
Expand All @@ -39,30 +39,28 @@ export interface RollupPluginSetupDependencies {
aggTypeFieldFilters: AggTypeFieldFilters;
addSearchStrategy: (searchStrategy: SearchStrategyProvider) => void;
managementLegacy: ManagementSetupLegacy;
indexManagementExtensions: IndexMgmtSetup['extensionsService'];
};
home?: HomePublicPluginSetup;
management: ManagementSetup;
indexManagement?: IndexMgmtSetup;
}

export class RollupPlugin implements Plugin {
setup(
core: CoreSetup,
{
__LEGACY: {
aggTypeFilters,
aggTypeFieldFilters,
addSearchStrategy,
managementLegacy,
indexManagementExtensions,
},
__LEGACY: { aggTypeFilters, aggTypeFieldFilters, addSearchStrategy, managementLegacy },
home,
management,
indexManagement,
}: RollupPluginSetupDependencies
) {
setFatalErrors(core.fatalErrors);
indexManagementExtensions.addBadge(rollupBadgeExtension);
indexManagementExtensions.addToggle(rollupToggleExtension);

if (indexManagement) {
indexManagement.extensionsService.addBadge(rollupBadgeExtension);
indexManagement.extensionsService.addToggle(rollupToggleExtension);
}

const isRollupIndexPatternsEnabled = core.uiSettings.get(CONFIG_ROLLUPS);

Expand Down
10 changes: 5 additions & 5 deletions x-pack/legacy/plugins/rollup/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { i18n } from '@kbn/i18n';

import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { VisTypeTimeseriesSetup } from 'src/plugins/vis_type_timeseries/server';
import { IndexMgmtSetup } from '../../../../plugins/index_management/server';
import { registerLicenseChecker } from '../../../server/lib/register_license_checker';
import { PLUGIN } from '../common';
import { ServerShim, RouteDependencies } from './types';
Expand Down Expand Up @@ -38,10 +39,12 @@ export class RollupsServerPlugin implements Plugin<void, void, any, any> {
__LEGACY: serverShim,
usageCollection,
metrics,
indexManagement,
}: {
__LEGACY: ServerShim;
usageCollection?: UsageCollectionSetup;
metrics?: VisTypeTimeseriesSetup;
indexManagement?: IndexMgmtSetup;
}
) {
const elasticsearch = await elasticsearchService.adminClient;
Expand Down Expand Up @@ -76,11 +79,8 @@ export class RollupsServerPlugin implements Plugin<void, void, any, any> {
});
}

if (
serverShim.plugins.index_management &&
serverShim.plugins.index_management.addIndexManagementDataEnricher
) {
serverShim.plugins.index_management.addIndexManagementDataEnricher(rollupDataEnricher);
if (indexManagement && indexManagement.indexDataEnricher) {
indexManagement.indexDataEnricher.add(rollupDataEnricher);
}

if (metrics) {
Expand Down
7 changes: 2 additions & 5 deletions x-pack/legacy/plugins/rollup/server/rollup_data_enricher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

interface Index {
name: string;
[key: string]: unknown;
}
import { Index } from '../../../../plugins/index_management/server';

export const rollupDataEnricher = async (indicesList: Index[], callWithRequest: any) => {
if (!indicesList || !indicesList.length) {
return indicesList;
return Promise.resolve(indicesList);
}

const params = {
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/rollup/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface ServerShim {
plugins: {
xpack_main: XPackMainPlugin;
rollup: any;
index_management: any;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
TestBedConfig,
findTestSubject,
nextTick,
} from '../../../../../../test_utils';
import { IndexManagementHome } from '../../../public/application/sections/home';
} from '../../../../../test_utils';
import { IndexManagementHome } from '../../../public/application/sections/home'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { BASE_PATH } from '../../../common/constants';
import { indexManagementStore } from '../../../public/application/store';
import { indexManagementStore } from '../../../public/application/store'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { Template } from '../../../common/types';
import { WithAppDependencies, services } from './setup_environment';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { setup as templateCreateSetup } from './template_create.helpers';
import { setup as templateCloneSetup } from './template_clone.helpers';
import { setup as templateEditSetup } from './template_edit.helpers';

export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../../test_utils';
export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../test_utils';

export { setupEnvironment } from './setup_environment';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
/* eslint-disable @kbn/eslint/no-restricted-paths */
import React from 'react';
import axios from 'axios';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';

import {
notificationServiceMock,
docLinksServiceMock,
} from '../../../../../../../src/core/public/mocks';
} from '../../../../../../src/core/public/mocks';
import { AppContextProvider } from '../../../public/application/app_context';
import { httpService } from '../../../public/application/services/http';
import { breadcrumbService } from '../../../public/application/services/breadcrumbs';
Expand Down
Loading

0 comments on commit 277b380

Please sign in to comment.