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 8, 2020
1 parent 034f259 commit 465d813
Show file tree
Hide file tree
Showing 39 changed files with 117 additions and 213 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export { INDEX_NAMES } from './index_names';
export { PLUGIN } from './plugin';
export { LICENSES, REQUIRED_LICENSES, REQUIRED_ROLES } from './security';
export { TABLE_CONFIG } from './table';
export const BASE_PATH = '/management/beats_management';
export const BASE_PATH = '/management/ingest/beats_management';
18 changes: 2 additions & 16 deletions x-pack/legacy/plugins/beats_management/public/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function startApp(libs: FrontendLibs) {
BASE_PATH,
<ThemeProvider theme={{ eui: euiVars }}>
<I18nContext>
<HashRouter basename="/management/beats_management">
<HashRouter basename={BASE_PATH}>
<UnstatedProvider inject={[new BeatsContainer(libs), new TagsContainer(libs)]}>
<BreadcrumbProvider useGlobalBreadcrumbs={libs.framework.versionGreaterThen('6.7.0')}>
<Subscribe to={[BeatsContainer, TagsContainer]}>
Expand All @@ -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,11 +9,13 @@ 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';
import { SecurityPluginSetup } from '../../../../../../../plugins/security/public';
import { BufferedKibanaServiceCall, KibanaAdapterServiceRefs, KibanaUIConfig } from '../../types';
import { BASE_PATH } from '../../../../common/constants';
import {
FrameworkAdapter,
FrameworkInfo,
Expand Down Expand Up @@ -148,45 +150,13 @@ 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,
url: `#${BASE_PATH}/`,
});
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const APPS = {
};

export const MANAGEMENT_ID = 'cross_cluster_replication';
export const BASE_PATH = `/management/elasticsearch/${MANAGEMENT_ID}`;
export const BASE_PATH_REMOTE_CLUSTERS = '/management/elasticsearch/remote_clusters';
export const BASE_PATH = `/management/data/${MANAGEMENT_ID}`;
export const BASE_PATH_REMOTE_CLUSTERS = '/management/data/remote_clusters';
export const API_BASE_PATH = '/api/cross_cluster_replication';
export const API_REMOTE_CLUSTERS_BASE_PATH = '/api/remote_clusters';
export const API_INDEX_MANAGEMENT_BASE_PATH = '/api/index_management';
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const PLUGIN = {
}),
};

export const BASE_PATH = '/management/elasticsearch/index_lifecycle_management/';
export const BASE_PATH = '/management/data/index_lifecycle_management/';

export const API_BASE_PATH = '/api/index_lifecycle_management';
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const BASE_PATH = '/management/elasticsearch/license_management/';
export const BASE_PATH = '/management/stack/license_management/';

export const API_BASE_PATH = '/api/license';
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
Loading

0 comments on commit 465d813

Please sign in to comment.