mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Index pattern management plugin - src/legacy/core_plugins/management => new platform plugin (#62594) (#63019)
* implement index pattern management plugin in new platform
This commit is contained in:
parent
6d5c6d1162
commit
8cd90593c2
44 changed files with 184 additions and 297 deletions
|
@ -24,6 +24,7 @@
|
|||
"src/legacy/core_plugins/management",
|
||||
"src/plugins/management"
|
||||
],
|
||||
"indexPatternManagement": "src/plugins/index_pattern_management",
|
||||
"advancedSettings": "src/plugins/advanced_settings",
|
||||
"kibana_legacy": "src/plugins/kibana_legacy",
|
||||
"kibana_react": "src/legacy/core_plugins/kibana_react",
|
||||
|
|
|
@ -17,4 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export * from './index_pattern_management';
|
||||
export {
|
||||
ProcessedImportResponse,
|
||||
processImportResponse,
|
||||
} from './management/sections/objects/lib/process_import_response';
|
|
@ -21,7 +21,7 @@ import React from 'react';
|
|||
import { StepIndexPattern } from '../step_index_pattern';
|
||||
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
|
||||
import { Header } from './components/header';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../management/public';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../../../plugins/index_pattern_management/public';
|
||||
import { coreMock } from '../../../../../../../../../../core/public/mocks';
|
||||
import { dataPluginMock } from '../../../../../../../../../../plugins/data/public/mocks';
|
||||
import { SavedObjectsFindResponsePublic } from '../../../../../../../../../../core/public';
|
||||
|
|
|
@ -39,7 +39,7 @@ import { LoadingIndices } from './components/loading_indices';
|
|||
import { StatusMessage } from './components/status_message';
|
||||
import { IndicesList } from './components/indices_list';
|
||||
import { Header } from './components/header';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../management/public';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../../../plugins/index_pattern_management/public';
|
||||
import { MatchedIndex } from '../../types';
|
||||
|
||||
interface StepIndexPatternProps {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../management/public';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../../../plugins/index_pattern_management/public';
|
||||
import { IFieldType } from '../../../../../../../../../../plugins/data/public';
|
||||
|
||||
import { StepTimeField } from '../step_time_field';
|
||||
|
|
|
@ -34,7 +34,7 @@ import { Header } from './components/header';
|
|||
import { TimeField } from './components/time_field';
|
||||
import { AdvancedOptions } from './components/advanced_options';
|
||||
import { ActionButtons } from './components/action_buttons';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../management/public';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../../../plugins/index_pattern_management/public';
|
||||
import { DataPublicPluginStart } from '../../../../../../../../../../plugins/data/public';
|
||||
|
||||
interface StepTimeFieldProps {
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
import uiRoutes from 'ui/routes';
|
||||
import angularTemplate from './angular_template.html';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { setup as managementSetup } from '../../../../../../management/public/legacy';
|
||||
import { getCreateBreadcrumbs } from '../breadcrumbs';
|
||||
|
||||
import { renderCreateIndexPatternWizard, destroyCreateIndexPatternWizard } from './render';
|
||||
|
@ -33,7 +32,7 @@ uiRoutes.when('/management/kibana/index_pattern', {
|
|||
const kbnUrl = $injector.get('kbnUrl');
|
||||
$scope.$$postDigest(() => {
|
||||
const $routeParams = $injector.get('$routeParams');
|
||||
const indexPatternCreationType = managementSetup.indexPattern.creation.getType(
|
||||
const indexPatternCreationType = npStart.plugins.indexPatternManagement.creation.getType(
|
||||
$routeParams.type
|
||||
);
|
||||
const services = {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { getIndices } from './get_indices';
|
||||
import { IndexPatternCreationConfig } from './../../../../../../../management/public';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../../plugins/index_pattern_management/public';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search';
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { get, sortBy } from 'lodash';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../management/public';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../../../../plugins/index_pattern_management/public';
|
||||
import { DataPublicPluginStart } from '../../../../../../../../../plugins/data/public';
|
||||
import { MatchedIndex } from '../types';
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import { uiModules } from 'ui/modules';
|
|||
import template from './edit_index_pattern.html';
|
||||
import { fieldWildcardMatcher } from '../../../../../../../../plugins/kibana_utils/public';
|
||||
import { subscribeWithScope } from '../../../../../../../../plugins/kibana_legacy/public';
|
||||
import { setup as managementSetup } from '../../../../../../management/public/legacy';
|
||||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { SourceFiltersTable } from './source_filters_table';
|
||||
|
@ -239,14 +238,12 @@ uiModules
|
|||
$scope.editSectionsProvider = Private(IndicesEditSectionsProvider);
|
||||
$scope.kbnUrl = Private(KbnUrlProvider);
|
||||
$scope.indexPattern = $route.current.locals.indexPattern;
|
||||
$scope.indexPatternListProvider = managementSetup.indexPattern.list;
|
||||
$scope.indexPattern.tags = managementSetup.indexPattern.list.getIndexPatternTags(
|
||||
$scope.indexPatternListProvider = npStart.plugins.indexPatternManagement.list;
|
||||
$scope.indexPattern.tags = npStart.plugins.indexPatternManagement.list.getIndexPatternTags(
|
||||
$scope.indexPattern,
|
||||
$scope.indexPattern.id === config.get('defaultIndex')
|
||||
);
|
||||
$scope.getFieldInfo = managementSetup.indexPattern.list.getFieldInfo.bind(
|
||||
managementSetup.indexPattern.list
|
||||
);
|
||||
$scope.getFieldInfo = npStart.plugins.indexPatternManagement.list.getFieldInfo;
|
||||
docTitle.change($scope.indexPattern.title);
|
||||
|
||||
const otherPatterns = _.filter($route.current.locals.indexPatterns, pattern => {
|
||||
|
@ -257,7 +254,7 @@ uiModules
|
|||
$scope.editSections = $scope.editSectionsProvider(
|
||||
$scope.indexPattern,
|
||||
$scope.fieldFilter,
|
||||
managementSetup.indexPattern.list
|
||||
npStart.plugins.indexPatternManagement.list
|
||||
);
|
||||
$scope.refreshFilters();
|
||||
$scope.fields = $scope.indexPattern.getNonScriptedFields();
|
||||
|
@ -375,7 +372,7 @@ uiModules
|
|||
$scope.editSections = $scope.editSectionsProvider(
|
||||
$scope.indexPattern,
|
||||
$scope.fieldFilter,
|
||||
managementSetup.indexPattern.list
|
||||
npStart.plugins.indexPatternManagement.list
|
||||
);
|
||||
|
||||
if ($scope.fieldFilter === undefined) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
import { management } from 'ui/management';
|
||||
import { setup as managementSetup } from '../../../../../management/public/legacy';
|
||||
import './create_index_pattern_wizard';
|
||||
import './edit_index_pattern';
|
||||
import uiRoutes from 'ui/routes';
|
||||
|
@ -111,7 +110,7 @@ uiModules
|
|||
transclude: true,
|
||||
template: indexTemplate,
|
||||
link: async function($scope) {
|
||||
const indexPatternCreationOptions = await managementSetup.indexPattern.creation.getIndexPatternCreationOptions(
|
||||
const indexPatternCreationOptions = await npStart.plugins.indexPatternManagement.creation.getIndexPatternCreationOptions(
|
||||
url => {
|
||||
$scope.$evalAsync(() => kbnUrl.change(url));
|
||||
}
|
||||
|
@ -124,7 +123,7 @@ uiModules
|
|||
const id = pattern.id;
|
||||
const title = pattern.get('title');
|
||||
const isDefault = $scope.defaultIndex === id;
|
||||
const tags = managementSetup.indexPattern.list.getIndexPatternTags(
|
||||
const tags = npStart.plugins.indexPatternManagement.list.getIndexPatternTags(
|
||||
pattern,
|
||||
isDefault
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
|
||||
import { mockManagementPlugin } from '../../../../../../../../management/public/np_ready/mocks';
|
||||
import { mockManagementPlugin } from '../../../../../../../../../../plugins/index_pattern_management/public/mocks';
|
||||
import { Query } from '@elastic/eui';
|
||||
|
||||
import { ObjectsTable, POSSIBLE_TYPES } from '../objects_table';
|
||||
|
@ -30,7 +30,7 @@ import { extractExportDetails } from '../../../lib/extract_export_details';
|
|||
|
||||
jest.mock('ui/kfetch', () => ({ kfetch: jest.fn() }));
|
||||
|
||||
jest.mock('../../../../../../../../management/public/legacy', () => ({
|
||||
jest.mock('../../../../../../../../../../plugins/index_pattern_management/public', () => ({
|
||||
setup: mockManagementPlugin.createSetupContract(),
|
||||
start: mockManagementPlugin.createStartContract(),
|
||||
}));
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
|
||||
import { mockManagementPlugin } from '../../../../../../../../../../management/public/np_ready/mocks';
|
||||
import { mockManagementPlugin } from '../../../../../../../../../../../../plugins/index_pattern_management/public/mocks';
|
||||
import { Flyout } from '../flyout';
|
||||
|
||||
jest.mock('ui/kfetch', () => ({ kfetch: jest.fn() }));
|
||||
|
@ -48,7 +48,7 @@ jest.mock('../../../../../lib/resolve_saved_objects', () => ({
|
|||
saveObjects: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../../../../../../../../../management/public/legacy', () => ({
|
||||
jest.mock('../../../../../../../../../../../../plugins/index_pattern_management/public', () => ({
|
||||
setup: mockManagementPlugin.createSetupContract(),
|
||||
start: mockManagementPlugin.createStartContract(),
|
||||
}));
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { Legacy } from '../../../../kibana';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function ManagementPlugin(kibana: any) {
|
||||
const config: Legacy.PluginSpecOptions = {
|
||||
id: 'stack-management',
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
config: (Joi: any) => {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
}).default();
|
||||
},
|
||||
init: (server: Legacy.Server) => ({}),
|
||||
};
|
||||
|
||||
return new kibana.Plugin(config);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"name": "management",
|
||||
"version": "kibana"
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Static np-ready code, re-exported here so consumers can import from
|
||||
* `src/legacy/core_plugins/management/public`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
export {
|
||||
ManagementSetup,
|
||||
ManagementStart,
|
||||
plugin,
|
||||
IndexPatternCreationConfig,
|
||||
IndexPatternListConfig,
|
||||
} from './np_ready';
|
||||
|
||||
export {
|
||||
processImportResponse,
|
||||
ProcessedImportResponse,
|
||||
} from '../../kibana/public/management/sections/objects/lib/process_import_response';
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* New Platform Shim
|
||||
*
|
||||
* In this file, we import any legacy dependencies we have, and shim them into
|
||||
* our plugin by manually constructing the values that the new platform will
|
||||
* eventually be passing to the `setup/start` method of our plugin definition.
|
||||
*
|
||||
* The idea is that our `plugin.ts` can stay "pure" and not contain any legacy
|
||||
* world code. Then when it comes time to migrate to the new platform, we can
|
||||
* simply delete this shim file.
|
||||
*
|
||||
* We are also calling `setup/start` here and exporting our public contract so that
|
||||
* other legacy plugins are able to import from '../core_plugins/management/legacy'
|
||||
* and receive the response value of the `setup/start` contract, mimicking the
|
||||
* data that will eventually be injected by the new platform.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from 'src/core/public';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
|
||||
import { plugin } from '.';
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
||||
export const setup = pluginInstance.setup(npSetup.core, { home: npSetup.plugins.home });
|
||||
export const start = pluginInstance.start(npStart.core, {});
|
|
@ -290,6 +290,10 @@ export const npSetup = {
|
|||
}),
|
||||
},
|
||||
},
|
||||
indexPatternManagement: {
|
||||
list: { addListConfig: sinon.fake() },
|
||||
creation: { addCreationConfig: sinon.fake() },
|
||||
},
|
||||
discover: {
|
||||
docViews: {
|
||||
addDocView: sinon.fake(),
|
||||
|
@ -325,6 +329,17 @@ export const npStart = {
|
|||
}),
|
||||
},
|
||||
},
|
||||
indexPatternManagement: {
|
||||
list: {
|
||||
getType: sinon.fake(),
|
||||
getIndexPatternCreationOptions: sinon.fake(),
|
||||
},
|
||||
creation: {
|
||||
getIndexPatternTags: sinon.fake(),
|
||||
getFieldInfo: sinon.fake(),
|
||||
areScriptedFieldsEnabled: sinon.fake(),
|
||||
},
|
||||
},
|
||||
embeddable: {
|
||||
getEmbeddableFactory: sinon.fake(),
|
||||
getEmbeddableFactories: sinon.fake(),
|
||||
|
|
|
@ -47,6 +47,10 @@ import {
|
|||
AdvancedSettingsStart,
|
||||
} from '../../../../plugins/advanced_settings/public';
|
||||
import { ManagementSetup, ManagementStart } from '../../../../plugins/management/public';
|
||||
import {
|
||||
IndexPatternManagementSetup,
|
||||
IndexPatternManagementStart,
|
||||
} from '../../../../plugins/index_pattern_management/public';
|
||||
import { BfetchPublicSetup, BfetchPublicStart } from '../../../../plugins/bfetch/public';
|
||||
import { UsageCollectionSetup } from '../../../../plugins/usage_collection/public';
|
||||
import { TelemetryPluginSetup, TelemetryPluginStart } from '../../../../plugins/telemetry/public';
|
||||
|
@ -86,6 +90,7 @@ export interface PluginsSetup {
|
|||
visualizations: VisualizationsSetup;
|
||||
telemetry?: TelemetryPluginSetup;
|
||||
savedObjectsManagement: SavedObjectsManagementPluginSetup;
|
||||
indexPatternManagement: IndexPatternManagementSetup;
|
||||
}
|
||||
|
||||
export interface PluginsStart {
|
||||
|
@ -107,6 +112,7 @@ export interface PluginsStart {
|
|||
telemetry?: TelemetryPluginStart;
|
||||
dashboard: DashboardStart;
|
||||
savedObjectsManagement: SavedObjectsManagementPluginStart;
|
||||
indexPatternManagement: IndexPatternManagementStart;
|
||||
}
|
||||
|
||||
export const npSetup = {
|
||||
|
|
7
src/plugins/index_pattern_management/kibana.json
Normal file
7
src/plugins/index_pattern_management/kibana.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "indexPatternManagement",
|
||||
"version": "kibana",
|
||||
"server": false,
|
||||
"ui": true,
|
||||
"requiredPlugins": []
|
||||
}
|
|
@ -29,14 +29,11 @@
|
|||
* either types, or static code.
|
||||
*/
|
||||
import { PluginInitializerContext } from 'src/core/public';
|
||||
import { ManagementPlugin } from './plugin';
|
||||
export { ManagementSetup, ManagementStart } from './plugin';
|
||||
import { IndexPatternManagementPlugin } from './plugin';
|
||||
export { IndexPatternManagementSetup, IndexPatternManagementStart } from './plugin';
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext) {
|
||||
return new ManagementPlugin(initializerContext);
|
||||
return new IndexPatternManagementPlugin(initializerContext);
|
||||
}
|
||||
|
||||
export {
|
||||
IndexPatternCreationConfig,
|
||||
IndexPatternListConfig,
|
||||
} from './services/index_pattern_management';
|
||||
export { IndexPatternCreationConfig, IndexPatternListConfig } from './service';
|
|
@ -18,42 +18,38 @@
|
|||
*/
|
||||
|
||||
import { PluginInitializerContext } from 'src/core/public';
|
||||
import { coreMock } from '../../../../../core/public/mocks';
|
||||
import { coreMock } from '../../../core/public/mocks';
|
||||
import {
|
||||
ManagementSetup,
|
||||
ManagementStart,
|
||||
ManagementPlugin,
|
||||
ManagementPluginSetupDependencies,
|
||||
IndexPatternManagementSetup,
|
||||
IndexPatternManagementStart,
|
||||
IndexPatternManagementPlugin,
|
||||
} from './plugin';
|
||||
|
||||
const createSetupContract = (): ManagementSetup => ({
|
||||
indexPattern: {
|
||||
creation: {
|
||||
add: jest.fn(),
|
||||
getType: jest.fn(),
|
||||
getIndexPatternCreationOptions: jest.fn(),
|
||||
} as any,
|
||||
list: {
|
||||
add: jest.fn(),
|
||||
getIndexPatternTags: jest.fn(),
|
||||
getFieldInfo: jest.fn(),
|
||||
areScriptedFieldsEnabled: jest.fn(),
|
||||
} as any,
|
||||
},
|
||||
const createSetupContract = (): IndexPatternManagementSetup => ({
|
||||
creation: {
|
||||
addCreationConfig: jest.fn(),
|
||||
} as any,
|
||||
list: {
|
||||
addListConfig: jest.fn(),
|
||||
} as any,
|
||||
});
|
||||
|
||||
const createStartContract = (): ManagementStart => ({});
|
||||
const createStartContract = (): IndexPatternManagementStart => ({
|
||||
creation: {
|
||||
getType: jest.fn(),
|
||||
getIndexPatternCreationOptions: jest.fn(),
|
||||
} as any,
|
||||
list: {
|
||||
getIndexPatternTags: jest.fn(),
|
||||
getFieldInfo: jest.fn(),
|
||||
areScriptedFieldsEnabled: jest.fn(),
|
||||
} as any,
|
||||
});
|
||||
|
||||
const createInstance = async () => {
|
||||
const plugin = new ManagementPlugin({} as PluginInitializerContext);
|
||||
const plugin = new IndexPatternManagementPlugin({} as PluginInitializerContext);
|
||||
|
||||
const setup = plugin.setup(coreMock.createSetup(), ({
|
||||
home: {
|
||||
featureCatalogue: {
|
||||
register: jest.fn(),
|
||||
},
|
||||
},
|
||||
} as unknown) as ManagementPluginSetupDependencies);
|
||||
const setup = plugin.setup(coreMock.createSetup());
|
||||
const doStart = () => plugin.start(coreMock.createStart(), {});
|
||||
|
||||
return {
|
|
@ -17,43 +17,40 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
|
||||
import { HomePublicPluginSetup } from 'src/plugins/home/public';
|
||||
import { IndexPatternManagementService, IndexPatternManagementSetup } from './services';
|
||||
|
||||
export interface ManagementPluginSetupDependencies {
|
||||
home: HomePublicPluginSetup;
|
||||
}
|
||||
import {
|
||||
IndexPatternManagementService,
|
||||
IndexPatternManagementServiceSetup,
|
||||
IndexPatternManagementServiceStart,
|
||||
} from './service';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface ManagementPluginStartDependencies {}
|
||||
|
||||
export interface ManagementSetup {
|
||||
indexPattern: IndexPatternManagementSetup;
|
||||
}
|
||||
export interface IndexPatternManagementSetupDependencies {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface ManagementStart {}
|
||||
export interface IndexPatternManagementStartDependencies {}
|
||||
|
||||
export class ManagementPlugin
|
||||
export type IndexPatternManagementSetup = IndexPatternManagementServiceSetup;
|
||||
|
||||
export type IndexPatternManagementStart = IndexPatternManagementServiceStart;
|
||||
|
||||
export class IndexPatternManagementPlugin
|
||||
implements
|
||||
Plugin<
|
||||
ManagementSetup,
|
||||
ManagementStart,
|
||||
ManagementPluginSetupDependencies,
|
||||
ManagementPluginStartDependencies
|
||||
IndexPatternManagementSetup,
|
||||
IndexPatternManagementStart,
|
||||
IndexPatternManagementSetupDependencies,
|
||||
IndexPatternManagementStartDependencies
|
||||
> {
|
||||
private readonly indexPattern = new IndexPatternManagementService();
|
||||
|
||||
constructor(initializerContext: PluginInitializerContext) {}
|
||||
|
||||
public setup(core: CoreSetup, { home }: ManagementPluginSetupDependencies) {
|
||||
return {
|
||||
indexPattern: this.indexPattern.setup({ httpClient: core.http, home }),
|
||||
};
|
||||
public setup(core: CoreSetup) {
|
||||
return this.indexPattern.setup({ httpClient: core.http });
|
||||
}
|
||||
|
||||
public start(core: CoreStart, plugins: ManagementPluginStartDependencies) {
|
||||
return {};
|
||||
public start(core: CoreStart, plugins: IndexPatternManagementStartDependencies) {
|
||||
return this.indexPattern.start();
|
||||
}
|
||||
|
||||
public stop() {
|
|
@ -18,20 +18,20 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { MatchedIndex } from '../../../../../../kibana/public/management/sections/index_patterns/create_index_pattern_wizard/types';
|
||||
import { MatchedIndex } from '../../../../../legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/types';
|
||||
|
||||
const indexPatternTypeName = i18n.translate(
|
||||
'management.editIndexPattern.createIndex.defaultTypeName',
|
||||
'indexPatternManagement.editIndexPattern.createIndex.defaultTypeName',
|
||||
{ defaultMessage: 'index pattern' }
|
||||
);
|
||||
|
||||
const indexPatternButtonText = i18n.translate(
|
||||
'management.editIndexPattern.createIndex.defaultButtonText',
|
||||
'indexPatternManagement.editIndexPattern.createIndex.defaultButtonText',
|
||||
{ defaultMessage: 'Standard index pattern' }
|
||||
);
|
||||
|
||||
const indexPatternButtonDescription = i18n.translate(
|
||||
'management.editIndexPattern.createIndex.defaultButtonDescription',
|
||||
'indexPatternManagement.editIndexPattern.createIndex.defaultButtonDescription',
|
||||
{ defaultMessage: 'Perform full aggregations against any data' }
|
||||
);
|
||||
|
|
@ -17,23 +17,25 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { HttpSetup } from '../../../../../../../../core/public';
|
||||
import { HttpSetup } from '../../../../../core/public';
|
||||
import { IndexPatternCreationConfig, UrlHandler, IndexPatternCreationOption } from './config';
|
||||
|
||||
export class IndexPatternCreationManager {
|
||||
private configs: IndexPatternCreationConfig[];
|
||||
|
||||
constructor(private readonly httpClient: HttpSetup) {
|
||||
constructor() {
|
||||
this.configs = [];
|
||||
}
|
||||
|
||||
public add(Config: typeof IndexPatternCreationConfig) {
|
||||
const config = new Config({ httpClient: this.httpClient });
|
||||
public addCreationConfig = (httpClient: HttpSetup) => (
|
||||
Config: typeof IndexPatternCreationConfig
|
||||
) => {
|
||||
const config = new Config({ httpClient });
|
||||
if (this.configs.findIndex(c => c.key === config.key) !== -1) {
|
||||
throw new Error(`${config.key} exists in IndexPatternCreationManager.`);
|
||||
}
|
||||
this.configs.push(config);
|
||||
}
|
||||
};
|
||||
|
||||
public getType(key: string | undefined): IndexPatternCreationConfig | null {
|
||||
if (key) {
|
||||
|
@ -58,4 +60,13 @@ export class IndexPatternCreationManager {
|
|||
);
|
||||
return options;
|
||||
}
|
||||
|
||||
setup = (httpClient: HttpSetup) => ({
|
||||
addCreationConfig: this.addCreationConfig(httpClient).bind(this),
|
||||
});
|
||||
|
||||
start = () => ({
|
||||
getType: this.getType.bind(this),
|
||||
getIndexPatternCreationOptions: this.getIndexPatternCreationOptions.bind(this),
|
||||
});
|
||||
}
|
|
@ -17,18 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import {
|
||||
FeatureCatalogueCategory,
|
||||
HomePublicPluginSetup,
|
||||
} from '../../../../../../../plugins/home/public';
|
||||
import { HttpSetup } from '../../../../../../../core/public';
|
||||
import { HttpSetup } from '../../../../core/public';
|
||||
import { IndexPatternCreationManager, IndexPatternCreationConfig } from './creation';
|
||||
import { IndexPatternListManager, IndexPatternListConfig } from './list';
|
||||
|
||||
interface SetupDependencies {
|
||||
httpClient: HttpSetup;
|
||||
home: HomePublicPluginSetup;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,31 +31,29 @@ interface SetupDependencies {
|
|||
* @internal
|
||||
*/
|
||||
export class IndexPatternManagementService {
|
||||
public setup({ httpClient, home }: SetupDependencies) {
|
||||
const creation = new IndexPatternCreationManager(httpClient);
|
||||
const list = new IndexPatternListManager();
|
||||
indexPatternCreationManager: IndexPatternCreationManager;
|
||||
indexPatternListConfig: IndexPatternListManager;
|
||||
|
||||
creation.add(IndexPatternCreationConfig);
|
||||
list.add(IndexPatternListConfig);
|
||||
constructor() {
|
||||
this.indexPatternCreationManager = new IndexPatternCreationManager();
|
||||
this.indexPatternListConfig = new IndexPatternListManager();
|
||||
}
|
||||
|
||||
home.featureCatalogue.register({
|
||||
id: 'index_patterns',
|
||||
title: i18n.translate('management.indexPatternHeader', {
|
||||
defaultMessage: 'Index Patterns',
|
||||
}),
|
||||
description: i18n.translate('management.indexPatternLabel', {
|
||||
defaultMessage:
|
||||
'Manage the index patterns that help retrieve your data from Elasticsearch.',
|
||||
}),
|
||||
icon: 'indexPatternApp',
|
||||
path: '/app/kibana#/management/kibana/index_patterns',
|
||||
showOnHomePage: true,
|
||||
category: FeatureCatalogueCategory.ADMIN,
|
||||
});
|
||||
public setup({ httpClient }: SetupDependencies) {
|
||||
const creationManagerSetup = this.indexPatternCreationManager.setup(httpClient);
|
||||
creationManagerSetup.addCreationConfig(IndexPatternCreationConfig);
|
||||
this.indexPatternListConfig.setup().addListConfig(IndexPatternListConfig);
|
||||
|
||||
return {
|
||||
creation,
|
||||
list,
|
||||
creation: creationManagerSetup,
|
||||
list: this.indexPatternListConfig.setup(),
|
||||
};
|
||||
}
|
||||
|
||||
public start() {
|
||||
return {
|
||||
creation: this.indexPatternCreationManager.start(),
|
||||
list: this.indexPatternListConfig.start(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -71,4 +63,5 @@ export class IndexPatternManagementService {
|
|||
}
|
||||
|
||||
/** @internal */
|
||||
export type IndexPatternManagementSetup = ReturnType<IndexPatternManagementService['setup']>;
|
||||
export type IndexPatternManagementServiceSetup = ReturnType<IndexPatternManagementService['setup']>;
|
||||
export type IndexPatternManagementServiceStart = ReturnType<IndexPatternManagementService['start']>;
|
|
@ -33,9 +33,12 @@ export class IndexPatternListConfig {
|
|||
? [
|
||||
{
|
||||
key: 'default',
|
||||
name: i18n.translate('management.editIndexPattern.list.defaultIndexPatternListName', {
|
||||
defaultMessage: 'Default',
|
||||
}),
|
||||
name: i18n.translate(
|
||||
'indexPatternManagement.editIndexPattern.list.defaultIndexPatternListName',
|
||||
{
|
||||
defaultMessage: 'Default',
|
||||
}
|
||||
),
|
||||
},
|
||||
]
|
||||
: [];
|
|
@ -27,7 +27,7 @@ export class IndexPatternListManager {
|
|||
this.configs = [];
|
||||
}
|
||||
|
||||
public add(Config: typeof IndexPatternListConfig) {
|
||||
private addListConfig(Config: typeof IndexPatternListConfig) {
|
||||
const config = new Config();
|
||||
if (this.configs.findIndex(c => c.key === config.key) !== -1) {
|
||||
throw new Error(`${config.key} exists in IndexPatternListManager.`);
|
||||
|
@ -35,7 +35,7 @@ export class IndexPatternListManager {
|
|||
this.configs.push(config);
|
||||
}
|
||||
|
||||
public getIndexPatternTags(indexPattern: IIndexPattern, isDefault: boolean) {
|
||||
private getIndexPatternTags(indexPattern: IIndexPattern, isDefault: boolean) {
|
||||
return this.configs.reduce((tags: IndexPatternTag[], config) => {
|
||||
return config.getIndexPatternTags
|
||||
? tags.concat(config.getIndexPatternTags(indexPattern, isDefault))
|
||||
|
@ -43,15 +43,25 @@ export class IndexPatternListManager {
|
|||
}, []);
|
||||
}
|
||||
|
||||
public getFieldInfo(indexPattern: IIndexPattern, field: IFieldType): string[] {
|
||||
private getFieldInfo(indexPattern: IIndexPattern, field: IFieldType): string[] {
|
||||
return this.configs.reduce((info: string[], config) => {
|
||||
return config.getFieldInfo ? info.concat(config.getFieldInfo(indexPattern, field)) : info;
|
||||
}, []);
|
||||
}
|
||||
|
||||
public areScriptedFieldsEnabled(indexPattern: IIndexPattern): boolean {
|
||||
private areScriptedFieldsEnabled(indexPattern: IIndexPattern): boolean {
|
||||
return this.configs.every(config => {
|
||||
return config.areScriptedFieldsEnabled ? config.areScriptedFieldsEnabled(indexPattern) : true;
|
||||
});
|
||||
}
|
||||
|
||||
setup = () => ({
|
||||
addListConfig: this.addListConfig.bind(this),
|
||||
});
|
||||
|
||||
start = () => ({
|
||||
getIndexPatternTags: this.getIndexPatternTags.bind(this),
|
||||
getFieldInfo: this.getFieldInfo.bind(this),
|
||||
areScriptedFieldsEnabled: this.areScriptedFieldsEnabled.bind(this),
|
||||
});
|
||||
}
|
|
@ -4,7 +4,8 @@
|
|||
"requiredPlugins": [
|
||||
"home",
|
||||
"index_management",
|
||||
"metrics"
|
||||
"metrics",
|
||||
"indexPatternManagement"
|
||||
],
|
||||
"optionalPlugins": [
|
||||
"usageCollection"
|
||||
|
|
|
@ -8,7 +8,7 @@ import React from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { RollupPrompt } from './components/rollup_prompt';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../src/legacy/core_plugins/management/public';
|
||||
import { IndexPatternCreationConfig } from '../../../../../../src/plugins/index_pattern_management/public';
|
||||
|
||||
const rollupIndexPatternTypeName = i18n.translate(
|
||||
'xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultTypeName',
|
||||
|
|
|
@ -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 { IndexPatternListConfig } from '../../../../../../src/legacy/core_plugins/management/public';
|
||||
import { IndexPatternListConfig } from '../../../../../../src/plugins/index_pattern_management/public';
|
||||
|
||||
function isRollup(indexPattern) {
|
||||
return (
|
||||
|
|
|
@ -6,14 +6,8 @@
|
|||
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
import { RollupPlugin } from './plugin';
|
||||
import { setup as management } from '../../../../../src/legacy/core_plugins/management/public/legacy';
|
||||
|
||||
const plugin = new RollupPlugin();
|
||||
|
||||
export const setup = plugin.setup(npSetup.core, {
|
||||
...npSetup.plugins,
|
||||
__LEGACY: {
|
||||
managementLegacy: management,
|
||||
},
|
||||
});
|
||||
export const setup = plugin.setup(npSetup.core, npSetup.plugins);
|
||||
export const start = plugin.start(npStart.core, npStart.plugins);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
|
||||
import { PluginsStart } from './legacy_imports';
|
||||
import { ManagementSetup as ManagementSetupLegacy } from '../../../../../src/legacy/core_plugins/management/public/np_ready';
|
||||
import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management';
|
||||
// @ts-ignore
|
||||
import { RollupIndexPatternCreationConfig } from './index_pattern_creation/rollup_index_pattern_creation_config';
|
||||
|
@ -26,6 +25,7 @@ import {
|
|||
import { CRUD_APP_BASE_PATH } from './crud_app/constants';
|
||||
import { ManagementSetup } from '../../../../../src/plugins/management/public';
|
||||
import { IndexMgmtSetup } from '../../../../plugins/index_management/public';
|
||||
import { IndexPatternManagementSetup } from '../../../../../src/plugins/index_pattern_management/public';
|
||||
import { search } from '../../../../../src/plugins/data/public';
|
||||
// @ts-ignore
|
||||
import { setEsBaseAndXPackBase, setHttp } from './crud_app/services';
|
||||
|
@ -33,23 +33,16 @@ import { setNotifications, setFatalErrors } from './kibana_services';
|
|||
import { renderApp } from './application';
|
||||
|
||||
export interface RollupPluginSetupDependencies {
|
||||
__LEGACY: {
|
||||
managementLegacy: ManagementSetupLegacy;
|
||||
};
|
||||
home?: HomePublicPluginSetup;
|
||||
management: ManagementSetup;
|
||||
indexManagement?: IndexMgmtSetup;
|
||||
indexPatternManagement: IndexPatternManagementSetup;
|
||||
}
|
||||
|
||||
export class RollupPlugin implements Plugin {
|
||||
setup(
|
||||
core: CoreSetup,
|
||||
{
|
||||
__LEGACY: { managementLegacy },
|
||||
home,
|
||||
management,
|
||||
indexManagement,
|
||||
}: RollupPluginSetupDependencies
|
||||
{ home, management, indexManagement, indexPatternManagement }: RollupPluginSetupDependencies
|
||||
) {
|
||||
setFatalErrors(core.fatalErrors);
|
||||
|
||||
|
@ -61,8 +54,8 @@ export class RollupPlugin implements Plugin {
|
|||
const isRollupIndexPatternsEnabled = core.uiSettings.get(CONFIG_ROLLUPS);
|
||||
|
||||
if (isRollupIndexPatternsEnabled) {
|
||||
managementLegacy.indexPattern.creation.add(RollupIndexPatternCreationConfig);
|
||||
managementLegacy.indexPattern.list.add(RollupIndexPatternListConfig);
|
||||
indexPatternManagement.creation.addCreationConfig(RollupIndexPatternCreationConfig);
|
||||
indexPatternManagement.list.addListConfig(RollupIndexPatternListConfig);
|
||||
}
|
||||
|
||||
if (home) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import React from 'react';
|
||||
import Boom from 'boom';
|
||||
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
|
||||
import { mockManagementPlugin } from '../../../../../../src/legacy/core_plugins/management/public/np_ready/mocks';
|
||||
import { CopySavedObjectsToSpaceFlyout } from './copy_to_space_flyout';
|
||||
import { CopyToSpaceForm } from './copy_to_space_form';
|
||||
import { EuiLoadingSpinner, EuiEmptyPrompt } from '@elastic/eui';
|
||||
|
@ -19,11 +18,6 @@ import { spacesManagerMock } from '../../spaces_manager/mocks';
|
|||
import { SpacesManager } from '../../spaces_manager';
|
||||
import { ToastsApi } from 'src/core/public';
|
||||
|
||||
jest.mock('../../../../../../src/legacy/core_plugins/management/public/legacy', () => ({
|
||||
setup: mockManagementPlugin.createSetupContract(),
|
||||
start: mockManagementPlugin.createStartContract(),
|
||||
}));
|
||||
|
||||
interface SetupOpts {
|
||||
mockSpaces?: Space[];
|
||||
returnBeforeSpacesLoad?: boolean;
|
||||
|
|
|
@ -25,7 +25,7 @@ import { ToastsStart } from 'src/core/public';
|
|||
import {
|
||||
ProcessedImportResponse,
|
||||
processImportResponse,
|
||||
} from '../../../../../../src/legacy/core_plugins/management/public';
|
||||
} from '../../../../../../src/legacy/core_plugins/kibana/public';
|
||||
import { SavedObjectsManagementRecord } from '../../../../../../src/plugins/saved_objects_management/public';
|
||||
import { Space } from '../../../common/model/space';
|
||||
import { SpacesManager } from '../../spaces_manager';
|
||||
|
|
|
@ -8,7 +8,7 @@ import React, { Fragment } from 'react';
|
|||
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiStat, EuiHorizontalRule } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { ProcessedImportResponse } from '../../../../../../src/legacy/core_plugins/management/public';
|
||||
import { ProcessedImportResponse } from '../../../../../../src/legacy/core_plugins/kibana/public';
|
||||
import { ImportRetry } from '../types';
|
||||
|
||||
interface Props {
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
EuiHorizontalRule,
|
||||
} from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { ProcessedImportResponse } from '../../../../../../src/legacy/core_plugins/management/public';
|
||||
import { ProcessedImportResponse } from '../../../../../../src/legacy/core_plugins/kibana/public';
|
||||
import { SavedObjectsManagementRecord } from '../../../../../../src/plugins/saved_objects_management/public';
|
||||
import { Space } from '../../../common/model/space';
|
||||
import { CopyOptions, ImportRetry } from '../types';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { summarizeCopyResult } from './summarize_copy_result';
|
||||
import { ProcessedImportResponse } from 'src/legacy/core_plugins/management/public';
|
||||
import { ProcessedImportResponse } from 'src/legacy/core_plugins/kibana/public';
|
||||
|
||||
const createSavedObjectsManagementRecord = () => ({
|
||||
type: 'dashboard',
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { ProcessedImportResponse } from 'src/legacy/core_plugins/management/public';
|
||||
import { ProcessedImportResponse } from 'src/legacy/core_plugins/kibana/public';
|
||||
import { SavedObjectsManagementRecord } from 'src/plugins/saved_objects_management/public';
|
||||
|
||||
export interface SummarizedSavedObjectResult {
|
||||
|
|
|
@ -2531,12 +2531,10 @@
|
|||
"management.breadcrumb": "管理",
|
||||
"management.connectDataDisplayName": "データに接続",
|
||||
"management.displayName": "管理",
|
||||
"management.editIndexPattern.createIndex.defaultButtonDescription": "すべてのデータに完全集約を実行",
|
||||
"management.editIndexPattern.createIndex.defaultButtonText": "標準インデックスパターン",
|
||||
"management.editIndexPattern.createIndex.defaultTypeName": "インデックスパターン",
|
||||
"management.editIndexPattern.list.defaultIndexPatternListName": "デフォルト",
|
||||
"management.indexPatternHeader": "インデックスパターン",
|
||||
"management.indexPatternLabel": "Elasticsearch からのデータの取得に役立つインデックスパターンを管理します。",
|
||||
"indexPatternManagement.editIndexPattern.createIndex.defaultButtonDescription": "すべてのデータに完全集約を実行",
|
||||
"indexPatternManagement.editIndexPattern.createIndex.defaultButtonText": "標準インデックスパターン",
|
||||
"indexPatternManagement.editIndexPattern.createIndex.defaultTypeName": "インデックスパターン",
|
||||
"indexPatternManagement.editIndexPattern.list.defaultIndexPatternListName": "デフォルト",
|
||||
"management.nav.label": "管理",
|
||||
"management.nav.menu": "管理メニュー",
|
||||
"management.stackManagement.managementDescription": "Elastic Stack の管理を行うセンターコンソールです。",
|
||||
|
|
|
@ -2532,12 +2532,10 @@
|
|||
"management.breadcrumb": "管理",
|
||||
"management.connectDataDisplayName": "连接数据",
|
||||
"management.displayName": "管理",
|
||||
"management.editIndexPattern.createIndex.defaultButtonDescription": "对任何数据执行完全聚合",
|
||||
"management.editIndexPattern.createIndex.defaultButtonText": "标准索引模式",
|
||||
"management.editIndexPattern.createIndex.defaultTypeName": "索引模式",
|
||||
"management.editIndexPattern.list.defaultIndexPatternListName": "默认值",
|
||||
"management.indexPatternHeader": "索引模式",
|
||||
"management.indexPatternLabel": "管理帮助从 Elasticsearch 检索数据的索引模式。",
|
||||
"indexPatternManagement.editIndexPattern.createIndex.defaultButtonDescription": "对任何数据执行完全聚合",
|
||||
"indexPatternManagement.editIndexPattern.createIndex.defaultButtonText": "标准索引模式",
|
||||
"indexPatternManagement.editIndexPattern.createIndex.defaultTypeName": "索引模式",
|
||||
"indexPatternManagement.editIndexPattern.list.defaultIndexPatternListName": "默认值",
|
||||
"management.nav.label": "管理",
|
||||
"management.nav.menu": "管理菜单",
|
||||
"management.stackManagement.managementDescription": "您用于管理 Elastic Stack 的中心控制台。",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue