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 14 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 @@ -15,7 +15,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,7 +4,7 @@
* 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';
Expand All @@ -19,4 +19,4 @@ export const followerBadgeExtension = {
filterExpression: 'isFollowerIndex:true',
};

extensionsService.addBadge(followerBadgeExtension);
npSetup.plugins.indexManagement.extensionsService.addBadge(followerBadgeExtension);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is going to cause issues if index management is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I added a check.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ initUiMetric(() => () => {});

jest.mock('ui/new_platform');
jest.mock('../../index_management/public', async () => {
const { indexManagementMock } = await import('../../index_management/public/mocks.ts');
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,7 @@ 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();
addAllExtensions((npSetup.plugins as any).indexManagement.extensionsService);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will cause issues if the index_management plugin is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I added a check. I think this bug is present on master then.. but not for long 😊


// 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 @@ -204,7 +203,7 @@ export const ilmFilterExtension = indices => {
}
};

export const addAllExtensions = () => {
export const addAllExtensions = extensionsService => {
extensionsService.addAction(retryLifecycleActionExtension);
extensionsService.addAction(removeLifecyclePolicyActionExtension);
extensionsService.addAction(addLifecyclePolicyActionExtension);
Expand Down
40 changes: 15 additions & 25 deletions x-pack/legacy/plugins/index_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,26 @@
* 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'],
// TODO: Remove once All dependent apps have migrated to NP
config(Joi: any) {
return Joi.object({
// display menu item
ui: Joi.object({
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? I don't think xpack.index_management.ui.enabled is an existing setting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I'm not quite sure I follow why the legacy config is needed, since it didn't exist previously. Can you explain?

Copy link
Contributor Author

@sebelga sebelga Feb 21, 2020

Choose a reason for hiding this comment

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

I thought those were necessary but apparently not. I think that previously we forgot to add them though (at least the enabled config) 😊

I removed everything but configPrefix and id which seems to be the minimum for the dependent apps to not complain.

enabled: Joi.boolean().default(true),
}).default(),

uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
managementSections: ['plugins/index_management'],
// enable plugin
enabled: Joi.boolean().default(true),
}).default();
},

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);
isEnabled(config: any) {
return (
config.get('xpack.index_management.enabled') && config.get('xpack.index_management.enabled')
Copy link
Contributor

Choose a reason for hiding this comment

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

should this just be return config.get('xpack.index_management.enabled')?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lol 😄

);
},
});
}
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 @@ -58,7 +58,7 @@ export function rollup(kibana: any) {
plugins: {
xpack_main: server.plugins.xpack_main,
rollup: server.plugins[PLUGIN.ID],
index_management: server.plugins.index_management,
indexManagement,
},
},
});
Expand Down
3 changes: 1 addition & 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,7 @@ export const setup = plugin.setup(npSetup.core, {
aggTypeFilters,
aggTypeFieldFilters,
addSearchStrategy,
indexManagementExtensions: extensionsService,
indexManagementExtensions: (npSetup.plugins as any).indexManagement.extensionsService,
managementLegacy: management,
},
});
Expand Down
2 changes: 1 addition & 1 deletion 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 Down
6 changes: 3 additions & 3 deletions x-pack/legacy/plugins/rollup/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ export class RollupsServerPlugin implements Plugin<void, void, any, any> {
}

if (
serverShim.plugins.index_management &&
serverShim.plugins.index_management.addIndexManagementDataEnricher
serverShim.plugins.indexManagement &&
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can indexManagement be moved out of the serverShim now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call! 👍

serverShim.plugins.indexManagement.indexDataEnricher
) {
serverShim.plugins.index_management.addIndexManagementDataEnricher(rollupDataEnricher);
serverShim.plugins.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
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/rollup/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

import { IRouter, ElasticsearchServiceSetup, IClusterClient } from 'src/core/server';
import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
import { IndexMgmtSetup } from '../../../../plugins/index_management/server';

export interface ServerShim {
plugins: {
xpack_main: XPackMainPlugin;
rollup: any;
index_management: any;
indexManagement: IndexMgmtSetup;
};
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { registerTestBed, TestBedConfig } from '../../../../../../test_utils';
import { registerTestBed, TestBedConfig } from '../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateClone } from '../../../public/application/sections/template_clone';
import { TemplateClone } from '../../../public/application/sections/template_clone'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { formSetup } from './template_form.helpers';
import { TEMPLATE_NAME } from './constants';
import { WithAppDependencies } from './setup_environment';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { registerTestBed, TestBedConfig } from '../../../../../../test_utils';
import { registerTestBed, TestBedConfig } from '../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateCreate } from '../../../public/application/sections/template_create';
import { TemplateCreate } from '../../../public/application/sections/template_create'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { formSetup, TestSubjects } from './template_form.helpers';
import { WithAppDependencies } from './setup_environment';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { registerTestBed, TestBedConfig } from '../../../../../../test_utils';
import { registerTestBed, TestBedConfig } from '../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateEdit } from '../../../public/application/sections/template_edit';
import { TemplateEdit } from '../../../public/application/sections/template_edit'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { formSetup, TestSubjects } from './template_form.helpers';
import { TEMPLATE_NAME } from './constants';
import { WithAppDependencies } from './setup_environment';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestBed, SetupFunc, UnwrapPromise } from '../../../../../../test_utils';
import { TestBed, SetupFunc, UnwrapPromise } from '../../../../../test_utils';
import { Template } from '../../../common/types';
import { nextTick } from './index';

Expand Down
Loading