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

This commit is contained in:
Sébastien Loix 2020-02-25 13:12:27 +05:30 committed by GitHub
parent 33334132ea
commit 277b38079e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
365 changed files with 295 additions and 259 deletions

View file

@ -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",

View file

@ -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);
}
},
});

View file

@ -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,

View file

@ -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,
@ -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 = {

View file

@ -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);
},
@ -19,4 +20,6 @@ export const followerBadgeExtension = {
filterExpression: 'isFollowerIndex:true',
};
extensionsService.addBadge(followerBadgeExtension);
if (npSetup.plugins.indexManagement) {
npSetup.plugins.indexManagement.extensionsService.addBadge(followerBadgeExtension);
}

View file

@ -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();
});

View file

@ -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);
}
}
}

View file

@ -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.

View file

@ -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';

View file

@ -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';
@ -238,7 +237,7 @@ export const ilmFilterExtension = indices => {
}
};
export const addAllExtensions = () => {
export const addAllExtensions = extensionsService => {
extensionsService.addAction(retryLifecycleActionExtension);
extensionsService.addAction(removeLifecyclePolicyActionExtension);
extensionsService.addAction(addLifecyclePolicyActionExtension);

View file

@ -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);
},
});
}

View file

@ -1,3 +0,0 @@
<kbn-management-app section="elasticsearch/index_management">
<div id="indexManagementReactRoot"></div>
</kbn-management-app>

View file

@ -5,6 +5,8 @@
*/
import { resolve } from 'path';
import { Legacy } from 'kibana';
import { PLUGIN } from './common';
export function remoteClusters(kibana: any) {
@ -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')
);

View file

@ -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;
@ -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,
},
},
});

View file

@ -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();
@ -20,7 +19,6 @@ export const setup = plugin.setup(npSetup.core, {
aggTypeFilters,
aggTypeFieldFilters,
addSearchStrategy,
indexManagementExtensions: extensionsService,
managementLegacy: management,
},
});

View file

@ -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';
@ -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);

View file

@ -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';
@ -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;
@ -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) {

View file

@ -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 = {

View file

@ -11,7 +11,6 @@ export interface ServerShim {
plugins: {
xpack_main: XPackMainPlugin;
rollup: any;
index_management: any;
};
}

View file

@ -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';

View file

@ -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';

View file

@ -3,6 +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.
*/
/* eslint-disable @kbn/eslint/no-restricted-paths */
import React from 'react';
import axios from 'axios';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';
@ -10,7 +11,7 @@ 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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -20,13 +20,13 @@ import { setUiMetricService } from '../../public/application/services/api';
import { indexManagementStore } from '../../public/application/store';
import { setExtensionsService } from '../../public/application/store/selectors';
import { BASE_PATH, API_BASE_PATH } from '../../common/constants';
import { mountWithIntl } from '../../../../../test_utils/enzyme_helpers';
import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
import { ExtensionsService } from '../../public/services';
import sinon from 'sinon';
import { findTestSubject } from '@elastic/eui/lib/test';
/* eslint-disable @kbn/eslint/no-restricted-paths */
import { notificationServiceMock } from '../../../../../../src/core/public/notifications/notifications_service.mock';
import { notificationServiceMock } from '../../../../../src/core/public/notifications/notifications_service.mock';
jest.mock('ui/new_platform');

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { LicenseType } from '../../../../../plugins/licensing/common/types';
import { LicenseType } from '../../../licensing/common/types';
const basicLicense: LicenseType = 'basic';

View file

@ -0,0 +1,15 @@
{
"id": "indexManagement",
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": [
"home",
"licensing",
"management"
],
"optionalPlugins": [
"usageCollection"
],
"configPath": ["xpack", "index_management"]
}

View file

@ -16,7 +16,7 @@ import { useServices } from './app_context';
export const App = () => {
const { uiMetricService } = useServices();
useEffect(() => uiMetricService.trackMetric('loaded', UIM_APP_LOAD), []);
useEffect(() => uiMetricService.trackMetric('loaded', UIM_APP_LOAD), [uiMetricService]);
return (
<HashRouter>

View file

@ -5,9 +5,9 @@
*/
import React, { createContext, useContext } from 'react';
import { CoreStart } from '../../../../../../src/core/public';
import { CoreStart } from '../../../../../src/core/public';
import { UsageCollectionSetup } from '../../../../../../src/plugins/usage_collection/public';
import { UsageCollectionSetup } from '../../../../../src/plugins/usage_collection/public';
import { IndexMgmtMetricsType } from '../types';
import { UiMetricService, NotificationService, HttpService } from './services';
import { ExtensionsService } from '../services';

View file

@ -10,7 +10,7 @@ export {
getRandomString,
findTestSubject,
TestBed,
} from '../../../../../../../../../../test_utils';
} from '../../../../../../../../../test_utils';
export const componentHelpers = {
mappingsEditor: { setup: mappingsEditorSetup },

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { registerTestBed } from '../../../../../../../../../../test_utils';
import { registerTestBed } from '../../../../../../../../../test_utils';
import { MappingsEditor } from '../../../mappings_editor';
export const setup = (props: any) =>

View file

@ -110,7 +110,7 @@ export const ConfigurationForm = React.memo(({ defaultValue }: Props) => {
});
});
return subscription.unsubscribe;
}, [form]);
}, [form, dispatch]);
useEffect(() => {
if (didMountRef.current) {
@ -121,14 +121,14 @@ export const ConfigurationForm = React.memo(({ defaultValue }: Props) => {
// Avoid reseting the form on component mount.
didMountRef.current = true;
}
}, [defaultValue]);
}, [defaultValue, form]);
useEffect(() => {
return () => {
// On unmount => save in the state a snapshot of the current form data.
dispatch({ type: 'configuration.save' });
};
}, []);
}, [dispatch]);
return (
<Form form={form} isInvalid={form.isSubmitted && !form.isValid} error={form.getErrors()}>

View file

@ -24,7 +24,7 @@ export const DocumentFields = React.memo(() => {
if (editorType === 'json') {
return deNormalize(fields);
}
}, [editorType]);
}, [editorType, fields]);
const editor =
editorType === 'json' ? (
@ -41,9 +41,12 @@ export const DocumentFields = React.memo(() => {
return <EditFieldContainer field={field} allFields={fields.byId} />;
};
const onSearchChange = useCallback((value: string) => {
dispatch({ type: 'search:update', value });
}, []);
const onSearchChange = useCallback(
(value: string) => {
dispatch({ type: 'search:update', value });
},
[dispatch]
);
const searchTerm = search.term.trim();

View file

@ -56,15 +56,21 @@ export const AnalyzerParameterSelects = ({
});
return subscription.unsubscribe;
}, [form]);
}, [form, onChange]);
const getSubOptionsMeta = (mainValue: string) =>
mapOptionsToSubOptions !== undefined ? mapOptionsToSubOptions[mainValue] : undefined;
const getSubOptionsMeta = useCallback(
(mainValue: string) =>
mapOptionsToSubOptions !== undefined ? mapOptionsToSubOptions[mainValue] : undefined,
[mapOptionsToSubOptions]
);
const onMainValueChange = useCallback((mainValue: unknown) => {
const subOptionsMeta = getSubOptionsMeta(mainValue as string);
form.setFieldValue('sub', subOptionsMeta ? subOptionsMeta.options[0].value : undefined);
}, []);
const onMainValueChange = useCallback(
(mainValue: unknown) => {
const subOptionsMeta = getSubOptionsMeta(mainValue as string);
form.setFieldValue('sub', subOptionsMeta ? subOptionsMeta.options[0].value : undefined);
},
[form, getSubOptionsMeta]
);
const renderSelect = (field: FieldHook, opts: Options) => {
const isSuperSelect = areOptionsSuperSelect(opts);

Some files were not shown because too many files have changed in this diff Show more