Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Index management] Move to new platform "plugins" folder #58109

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4984cbf
Move index_management to "plugins" folder
sebelga Feb 18, 2020
73568a7
Remove index.html from "public" folder
sebelga Feb 18, 2020
42abf51
Import "extensionsService" in legacy from ngSetup.plugins.indexManage…
sebelga Feb 18, 2020
3034bcc
Fix indexDataEnricher extend from legacy plugins
sebelga Feb 18, 2020
a64cc92
Update public contract
sebelga Feb 18, 2020
7bcef05
Update plugin path in i18nrc
sebelga Feb 18, 2020
52b8bcc
Export config schema from server
sebelga Feb 18, 2020
a26999f
Add Legacy type to config object in remote_clusters app
sebelga Feb 18, 2020
517f639
Expose config$ from __legacy in setup()
sebelga Feb 18, 2020
383cf0e
Expose index_management config for legacy apps
sebelga Feb 18, 2020
dfd7d4d
Fix infinite re-render from useEffect()
sebelga Feb 18, 2020
0be4ad1
Use "brace" instead of "ace" to edit index settings
sebelga Feb 20, 2020
5e33714
Fix indexManagement plugin link for server extension
sebelga Feb 20, 2020
2330607
Fix TS issues
sebelga Feb 20, 2020
32b4724
Remove indexManagement from rollup server shim
sebelga Feb 21, 2020
56f3338
Remove config$ export as legacy from setup
sebelga Feb 21, 2020
f5cd28b
Check first if indexManagement is enabled before calling extensions
sebelga Feb 21, 2020
40fcf7e
Remove unnecessary legacy config
sebelga Feb 21, 2020
acca91e
Merge remote-tracking branch 'upstream/master' into np-migration/inde…
sebelga Feb 21, 2020
e6bb10a
Fix jest test
sebelga Feb 21, 2020
43233d8
Merge branch 'master' into np-migration/index-management-plugins-folder
elasticmachine Feb 24, 2020
108ff98
Merge branch 'master' into np-migration/index-management-plugins-folder
elasticmachine Feb 24, 2020
4443ae1
Merge branch 'master' into np-migration/index-management-plugins-folder
elasticmachine Feb 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs to stay until all dependent apps have migrated to the "plugins" folder.

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