Skip to content

Commit

Permalink
Reorganize Management apps into Ingest, Data, Insights and Alerting, …
Browse files Browse the repository at this point in the history
…Security, Kibana, and Stack groups.

- Define these groups in src/plugins/management/public/legacy/sections_register to act as a single source of truth in both OSS and X-Pack.
  • Loading branch information
cjcenizal committed May 7, 2020
1 parent 034f259 commit 3015048
Show file tree
Hide file tree
Showing 29 changed files with 103 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ uiModules
};
});

management.getSection('kibana').register('index_patterns', {
management.getSection('data').register('index_patterns', {
display: i18n.translate('kbn.management.indexPattern.sectionsHeader', {
defaultMessage: 'Index Patterns',
}),
order: 0,
order: 1,
url: '#/management/kibana/index_patterns/',
});
2 changes: 1 addition & 1 deletion src/plugins/management/public/legacy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { LegacyManagementAdapter } from './sections_register';
export { LegacyManagementAdapter, sections } from './sections_register';
export { LegacyManagementSection } from './section';
56 changes: 33 additions & 23 deletions src/plugins/management/public/legacy/sections_register.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@
import { LegacyManagementSection } from './section';
import { i18n } from '@kbn/i18n';

export const sections = [
{
id: 'ingest',
title: 'Ingest',
},
{
id: 'data',
title: 'Data',
},
{
id: 'insightsAndAlerting',
title: 'Insights and Alerting',
},
{
id: 'security',
title: 'Security',
},
{
id: 'kibana',
title: 'Kibana',
},
{
id: 'stack',
title: 'Stack',
},
];

export class LegacyManagementAdapter {
main = undefined;
init = capabilities => {
Expand All @@ -33,29 +60,12 @@ export class LegacyManagementAdapter {
capabilities
);

this.main.register('data', {
display: i18n.translate('management.connectDataDisplayName', {
defaultMessage: 'Connect Data',
}),
order: 0,
});

this.main.register('elasticsearch', {
display: 'Elasticsearch',
order: 20,
icon: 'logoElasticsearch',
});

this.main.register('kibana', {
display: 'Kibana',
order: 30,
icon: 'logoKibana',
});

this.main.register('logstash', {
display: 'Logstash',
order: 30,
icon: 'logoLogstash',
sections.forEach(({ id, title, icon }, idx) => {
this.main.register(id, {
display: title,
order: idx,
icon,
});
});

return this.main;
Expand Down
14 changes: 6 additions & 8 deletions src/plugins/management/public/management_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { ManagementSection } from './management_section';
import { KibanaLegacySetup } from '../../kibana_legacy/public';
// @ts-ignore
import { LegacyManagementSection } from './legacy';
import { LegacyManagementSection, sections } from './legacy';
import { CreateSection } from './types';
import { StartServicesAccessor, CoreStart } from '../../../core/public';

Expand Down Expand Up @@ -79,13 +79,11 @@ export class ManagementService {
getStartServices
);

register({ id: 'kibana', title: 'Kibana', order: 30, euiIconType: 'logoKibana' });
register({
id: 'elasticsearch',
title: 'Elasticsearch',
order: 20,
euiIconType: 'logoElasticsearch',
});
sections.forEach(
({ id, title, icon }: { id: string; title: string; icon?: string }, idx: number) => {
register({ id, title, euiIconType: icon, order: idx });
}
);

return {
register,
Expand Down
16 changes: 1 addition & 15 deletions x-pack/legacy/plugins/beats_management/public/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,7 @@ async function startApp(libs: FrontendLibs) {
await libs.framework.waitUntilFrameworkReady();

if (libs.framework.licenseIsAtLeast('standard')) {
libs.framework.registerManagementSection({
id: 'beats',
name: i18n.translate('xpack.beatsManagement.centralManagementSectionLabel', {
defaultMessage: 'Beats',
}),
iconName: 'logoBeats',
});

libs.framework.registerManagementUI({
sectionId: 'beats',
name: i18n.translate('xpack.beatsManagement.centralManagementLinkLabel', {
defaultMessage: 'Central Management',
}),
basePath: BASE_PATH,
});
libs.framework.registerManagementSection();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,7 @@ export interface FrameworkAdapter {
component: React.ReactElement<any>,
toController: 'management' | 'self'
): void;
registerManagementSection(settings: {
id?: string;
name: string;
iconName: string;
order?: number;
}): void;
registerManagementUI(settings: {
sectionId?: string;
name: string;
basePath: string;
visable?: boolean;
order?: number;
}): void;
registerManagementSection(): void;
}

export const RuntimeFrameworkInfo = t.type({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IScope } from 'angular';
import { PathReporter } from 'io-ts/lib/PathReporter';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { i18n } from '@kbn/i18n';
import { UIRoutes } from 'ui/routes';
import { isLeft } from 'fp-ts/lib/Either';
import { npSetup } from 'ui/new_platform';
Expand Down Expand Up @@ -148,45 +149,12 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
);
}

public registerManagementSection(settings: {
id?: string;
name: string;
iconName: string;
order?: number;
}) {
const sectionId = settings.id || this.PLUGIN_ID;

if (!this.management.hasItem(sectionId)) {
this.management.register(sectionId, {
display: settings.name,
icon: settings.iconName,
order: settings.order || 30,
});
}
}

public registerManagementUI(settings: {
sectionId?: string;
name: string;
basePath: string;
visable?: boolean;
order?: number;
}) {
const sectionId = settings.sectionId || this.PLUGIN_ID;

if (!this.management.hasItem(sectionId)) {
throw new Error(
`registerManagementUI was called with a sectionId of ${sectionId}, and that is is not yet regestered as a section`
);
}

const section = this.management.getSection(sectionId);

section.register(sectionId, {
visible: settings.visable || true,
display: settings.name,
order: settings.order || 30,
url: `#${settings.basePath}`,
public registerManagementSection() {
this.management.getSection('ingest')!.register('beats_central_management', {
display: i18n.translate('xpack.beatsManagement.centralManagementSectionLabel', {
defaultMessage: 'Beats Central Management',
}),
order: 2,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,7 @@ export class TestingFrameworkAdapter implements FrameworkAdapter {
throw new Error('not yet implamented');
}

public registerManagementSection(settings: {
id?: string;
name: string;
iconName: string;
order?: number;
}) {
throw new Error('not yet implamented');
}

public registerManagementUI(settings: {
sectionId?: string;
name: string;
basePath: string;
visable?: boolean;
order?: number;
}) {
public registerManagementSection() {
throw new Error('not yet implamented');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class FrameworkLib {
public waitUntilFrameworkReady = this.adapter.waitUntilFrameworkReady.bind(this.adapter);
public renderUIAtPath = this.adapter.renderUIAtPath.bind(this.adapter);
public registerManagementSection = this.adapter.registerManagementSection.bind(this.adapter);
public registerManagementUI = this.adapter.registerManagementUI.bind(this.adapter);

constructor(private readonly adapter: FrameworkAdapter) {}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cross_cluster_replication/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CrossClusterReplicationPlugin implements Plugin {

public setup(coreSetup: CoreSetup, plugins: PluginDependencies) {
const { licensing, remoteClusters, usageCollection, management, indexManagement } = plugins;
const esSection = management.sections.getSection('elasticsearch');
const esSection = management.sections.getSection('data');

const {
http,
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/index_lifecycle_management/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export class IndexLifecycleManagementPlugin {
initUiMetric(usageCollection);
initNotification(toasts, fatalErrors);

management.sections.getSection('elasticsearch')!.registerApp({
management.sections.getSection('data')!.registerApp({
id: PLUGIN.ID,
title: PLUGIN.TITLE,
order: 3,
order: 2,
mount: async ({ element }) => {
const [coreStart] = await getStartServices();
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const BASE_PATH = '/management/elasticsearch/index_management/';
export const BASE_PATH = '/management/data/index_management/';
4 changes: 2 additions & 2 deletions x-pack/plugins/index_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export class IndexMgmtUIPlugin {
notificationService.setup(notifications);
this.uiMetricService.setup(usageCollection);

management.sections.getSection('elasticsearch')!.registerApp({
management.sections.getSection('data')!.registerApp({
id: PLUGIN.id,
title: i18n.translate('xpack.idxMgmt.appTitle', { defaultMessage: 'Index Management' }),
order: 2,
order: 0,
mount: async params => {
const { mountManagementSection } = await import('./application/mount_management_section');
const services = {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_pipelines/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class IngestPipelinesPlugin implements Plugin {
uiMetricService.setup(usageCollection);
apiService.setup(http, uiMetricService);

management.sections.getSection('elasticsearch')!.registerApp({
management.sections.getSection('ingest')!.registerApp({
id: PLUGIN_ID,
order: 1,
title: i18n.translate('xpack.ingestPipelines.appTitle', {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/license_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export class LicenseManagementUIPlugin
const { getStartServices } = coreSetup;
const { management, telemetry, licensing } = plugins;

management.sections.getSection('elasticsearch')!.registerApp({
management.sections.getSection('stack')!.registerApp({
id: PLUGIN.id,
title: PLUGIN.title,
order: 99,
order: 0,
mount: async ({ element, setBreadcrumbs }) => {
const [core] = await getStartServices();
const initialLicense = await plugins.licensing.license$.pipe(first()).toPromise();
Expand Down
13 changes: 4 additions & 9 deletions x-pack/plugins/logstash/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ export class LogstashPlugin implements Plugin<void, void, SetupDeps> {
const logstashLicense$ = plugins.licensing.license$.pipe(
map(license => new LogstashLicenseService(license))
);
const section = plugins.management.sections.register({
id: 'logstash',
title: 'Logstash',
order: 30,
euiIconType: 'logoLogstash',
});
const managementApp = section.registerApp({

const managementApp = plugins.management.sections.getSection('ingest')!.registerApp({
id: 'pipelines',
title: i18n.translate('xpack.logstash.managementSection.pipelinesTitle', {
defaultMessage: 'Pipelines',
defaultMessage: 'Logstash Pipelines',
}),
order: 10,
order: 1,
mount: async params => {
const [coreStart] = await core.getStartServices();
const { renderApp } = await import('./application');
Expand Down
17 changes: 4 additions & 13 deletions x-pack/plugins/ml/public/application/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { take } from 'rxjs/operators';
import { CoreSetup } from 'kibana/public';
import { MlStartDependencies, MlSetupDependencies } from '../../plugin';

import { PLUGIN_ID, PLUGIN_ICON } from '../../../common/constants/app';
import { PLUGIN_ID } from '../../../common/constants/app';
import { MINIMUM_FULL_LICENSE } from '../../../common/license';

export function initManagementSection(
Expand All @@ -30,21 +30,12 @@ export function initManagementSection(
management !== undefined &&
license.check(PLUGIN_ID, MINIMUM_FULL_LICENSE).state === 'valid'
) {
const mlSection = management.sections.register({
id: PLUGIN_ID,
title: i18n.translate('xpack.ml.management.mlTitle', {
defaultMessage: 'Machine Learning',
}),
order: 100,
icon: PLUGIN_ICON,
});

mlSection.registerApp({
management.sections.getSection('insightsAndAlerting')!.registerApp({
id: 'jobsListLink',
title: i18n.translate('xpack.ml.management.jobsListTitle', {
defaultMessage: 'Jobs list',
defaultMessage: 'Machine Learning Jobs',
}),
order: 10,
order: 2,
async mount(params) {
const { mountApp } = await import('./jobs_list');
return mountApp(core, params);
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/remote_clusters/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ export class RemoteClustersUIPlugin
} = this.initializerContext.config.get<ClientConfigType>();

if (isRemoteClustersUiEnabled) {
const esSection = management.sections.getSection('elasticsearch');
const esSection = management.sections.getSection('data');

esSection!.registerApp({
id: 'remote_clusters',
title: i18n.translate('xpack.remoteClusters.appTitle', {
defaultMessage: 'Remote Clusters',
}),
order: 7,
mount: async ({ element, setBreadcrumbs }) => {
const [core] = await getStartServices();
const {
Expand Down
Loading

0 comments on commit 3015048

Please sign in to comment.