Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize Management apps into Ingest, Data, Alerts and Insights, Security, Kibana, and Stack groups #65796

Merged
merged 31 commits into from May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
465d813
Reorganize Management apps into Ingest, Data, Insights and Alerting, …
cjcenizal May 7, 2020
a66a7e0
Fix TS error in beats due to missing visible option.
cjcenizal May 8, 2020
7cc3490
Update snapshots.
cjcenizal May 8, 2020
25cb6ac
Remove support for icon.
cjcenizal May 9, 2020
f93aba0
Create ManagementSectionId enum and remove ability to register additi…
cjcenizal May 9, 2020
a9fdf54
Merge branch 'master' into reorg/management-apps
cjcenizal May 9, 2020
d3f557e
Return Index Patterns to Kibana section.
cjcenizal May 9, 2020
5c6d09e
Rename Beats Central Management to Beats Management in nav.
cjcenizal May 9, 2020
6ceed19
Add tooltips to sections.
cjcenizal May 10, 2020
3aa1d8f
Throw error if retrieved managementSection is missing.
cjcenizal May 12, 2020
b1771a1
Merge branch 'master' into reorg/management-apps
cjcenizal May 12, 2020
b4b5b64
Fix types to specify that a retrieved ManagementSection cannot be und…
cjcenizal May 12, 2020
accc91e
Add test to verify that the management service will throw an error if…
cjcenizal May 12, 2020
9d97c23
Revert name change to Beats Central Management.
cjcenizal May 12, 2020
af06fc5
Fixed management nav on narrow screens.
cjcenizal May 12, 2020
29fa95e
Merge branch 'master' into reorg/management-apps
cjcenizal May 12, 2020
3e38251
Remove undefined export. Fix Security and Spaces unit tests.
cjcenizal May 12, 2020
cde5d36
Update paths to apps in functional tests config.
cjcenizal May 12, 2020
d14f15f
Fix plugin functional test.
cjcenizal May 13, 2020
cd6fa5e
Fix TS errors.
cjcenizal May 14, 2020
f1ddf84
Change kibana/triggersActions paths to insightsAndAlerting/triggersAc…
cjcenizal May 14, 2020
1cf0af1
Merge branch 'master' into reorg/management-apps
cjcenizal May 14, 2020
265373e
Fix spaces snapshot.
cjcenizal May 14, 2020
68c61fa
Fix management plugin functional tests.
cjcenizal May 14, 2020
64cda1a
Fix i18n.
cjcenizal May 14, 2020
58b6e10
Fix reporting tests.
cjcenizal May 14, 2020
68c0eb4
Fix broken links and update snapshots.
cjcenizal May 15, 2020
dfccfa5
Fix watcher links.
cjcenizal May 15, 2020
3554533
Fix broken license management link.
cjcenizal May 15, 2020
79bcbb7
Merge branch 'master' into reorg/management-apps
cjcenizal May 15, 2020
69762fd
Merge branch 'master' into reorg/management-apps
cjcenizal May 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -18,6 +18,7 @@
*/

import { management } from 'ui/management';
import { ManagementSectionId } from '../../../../../../../plugins/management/public';
import './create_index_pattern_wizard';
import './edit_index_pattern';
import uiRoutes from 'ui/routes';
Expand Down Expand Up @@ -163,7 +164,7 @@ uiModules
};
});

management.getSection('kibana').register('index_patterns', {
management.getSection(ManagementSectionId.Kibana).register('index_patterns', {
display: i18n.translate('kbn.management.indexPattern.sectionsHeader', {
defaultMessage: 'Index Patterns',
}),
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/advanced_settings/public/plugin.ts
Expand Up @@ -18,7 +18,7 @@
*/
import { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { ManagementApp } from '../../management/public';
import { ManagementApp, ManagementSectionId } from '../../management/public';
import { ComponentRegistry } from './component_registry';
import { AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup } from './types';

Expand All @@ -32,15 +32,12 @@ export class AdvancedSettingsPlugin
implements Plugin<AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup> {
private managementApp?: ManagementApp;
public setup(core: CoreSetup, { management }: AdvancedSettingsPluginSetup) {
const kibanaSection = management.sections.getSection('kibana');
if (!kibanaSection) {
throw new Error('`kibana` management section not found.');
}
const kibanaSection = management.sections.getSection(ManagementSectionId.Kibana);

this.managementApp = kibanaSection.registerApp({
id: 'settings',
title,
order: 20,
order: 3,
async mount(params) {
const { mountManagementSection } = await import(
'./management_app/mount_management_section'
Expand Down
@@ -1,5 +1,5 @@
.mgtSideBarNav {
width: 192px;
width: 210px;
}

@include euiBreakpoint('xs','s') {
Expand Down
Expand Up @@ -25,14 +25,14 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import React from 'react';
import React, { ReactElement } from 'react';
import { LegacySection, LegacyApp } from '../../types';
import { ManagementApp } from '../../management_app';
import { ManagementSection } from '../../management_section';

interface NavApp {
id: string;
name: string;
name: ReactElement | string;
[key: string]: unknown;
order: number; // only needed while merging platform and legacy
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/management/public/index.ts
Expand Up @@ -28,6 +28,7 @@ export {
ManagementSetup,
ManagementStart,
RegisterManagementApp,
ManagementSectionId,
RegisterManagementAppArgs,
ManagementAppMountParams,
} from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/management/public/legacy/index.js
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { LegacyManagementAdapter } from './sections_register';
export { LegacyManagementAdapter, sections } from './sections_register';
export { LegacyManagementSection } from './section';
31 changes: 7 additions & 24 deletions src/plugins/management/public/legacy/sections_register.js
Expand Up @@ -17,8 +17,9 @@
* under the License.
*/

import { LegacyManagementSection } from './section';
import { i18n } from '@kbn/i18n';
import { LegacyManagementSection } from './section';
import { managementSections } from '../management_sections';

export class LegacyManagementAdapter {
main = undefined;
Expand All @@ -33,29 +34,11 @@ 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',
managementSections.forEach(({ id, title }, idx) => {
this.main.register(id, {
display: title,
order: idx,
});
});

return this.main;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/management/public/management_section.test.ts
Expand Up @@ -18,6 +18,7 @@
*/

import { ManagementSection } from './management_section';
import { ManagementSectionId } from './types';
// @ts-ignore
import { LegacyManagementSection } from './legacy';
import { coreMock } from '../../../core/public/mocks';
Expand All @@ -27,7 +28,7 @@ function createSection(registerLegacyApp: () => void) {
const getLegacySection = () => legacySection;
const getManagementSections: () => ManagementSection[] = () => [];

const testSectionConfig = { id: 'test-section', title: 'Test Section' };
const testSectionConfig = { id: ManagementSectionId.Data, title: 'Test Section' };
return new ManagementSection(
testSectionConfig,
getManagementSections,
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/management/public/management_section.ts
Expand Up @@ -17,16 +17,18 @@
* under the License.
*/

import { CreateSection, RegisterManagementAppArgs } from './types';
import { ReactElement } from 'react';

import { CreateSection, RegisterManagementAppArgs, ManagementSectionId } from './types';
import { KibanaLegacySetup } from '../../kibana_legacy/public';
import { StartServicesAccessor } from '../../../core/public';
// @ts-ignore
import { LegacyManagementSection } from './legacy';
import { ManagementApp } from './management_app';

export class ManagementSection {
public readonly id: string = '';
public readonly title: string = '';
public readonly id: ManagementSectionId;
public readonly title: string | ReactElement = '';
public readonly apps: ManagementApp[] = [];
public readonly order: number;
public readonly euiIconType?: string;
Expand Down
77 changes: 77 additions & 0 deletions src/plugins/management/public/management_sections.tsx
@@ -0,0 +1,77 @@
/*
* 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 React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiIcon } from '@elastic/eui';

import { ManagementSectionId } from './types';

interface Props {
text: string;
tip: string;
}

const ManagementSectionTitle = ({ text, tip }: Props) => (
<EuiToolTip content={tip} position="right">
<EuiFlexGroup alignItems="center" gutterSize="s">
snide marked this conversation as resolved.
Show resolved Hide resolved
<EuiFlexItem grow={false}>{text}</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiIcon type="questionInCircle" />
</EuiFlexItem>
</EuiFlexGroup>
</EuiToolTip>
);

export const managementSections = [
{
id: ManagementSectionId.Ingest,
title: (
<ManagementSectionTitle
text="Ingest"
tip="Manage how data is transformed and loaded into the cluster"
/>
),
},
{
id: ManagementSectionId.Data,
title: <ManagementSectionTitle text="Data" tip="Manage your cluster data and backups" />,
},
{
id: ManagementSectionId.InsightsAndAlerting,
title: (
<ManagementSectionTitle
text="Insights and Alerting"
tip="Manage how to detect changes in your data"
/>
),
},
{
id: ManagementSectionId.Security,
title: <ManagementSectionTitle text="Security" tip="Control access to data and apps" />,
},
{
id: ManagementSectionId.Kibana,
title: <ManagementSectionTitle text="Kibana" tip="Customize Kibana and manage its internals" />,
},
{
id: ManagementSectionId.Stack,
title: <ManagementSectionTitle text="Stack" tip="Upgrade the Stack and manage your license" />,
},
];
31 changes: 8 additions & 23 deletions src/plugins/management/public/management_service.test.ts
Expand Up @@ -18,6 +18,7 @@
*/

import { ManagementService } from './management_service';
import { ManagementSectionId } from './types';
import { coreMock } from '../../../core/public/mocks';
import { npSetup } from '../../../legacy/ui/public/new_platform/__mocks__';

Expand All @@ -29,27 +30,11 @@ test('Provides default sections', () => {
() => {},
coreMock.createSetup().getStartServices
);
expect(service.getAllSections().length).toEqual(2);
expect(service.getSection('kibana')).not.toBeUndefined();
expect(service.getSection('elasticsearch')).not.toBeUndefined();
});

test('Register section, enable and disable', () => {
const service = new ManagementService().setup(
npSetup.plugins.kibanaLegacy,
() => {},
coreMock.createSetup().getStartServices
);
const testSection = service.register({ id: 'test-section', title: 'Test Section' });
expect(service.getSection('test-section')).not.toBeUndefined();

const testApp = testSection.registerApp({
id: 'test-app',
title: 'Test App',
mount: () => () => {},
});
expect(testSection.getApp('test-app')).not.toBeUndefined();
expect(service.getSectionsEnabled().length).toEqual(1);
testApp.disable();
expect(service.getSectionsEnabled().length).toEqual(0);
expect(service.getAllSections().length).toEqual(6);
expect(service.getSection(ManagementSectionId.Ingest)).toBeDefined();
expect(service.getSection(ManagementSectionId.Data)).toBeDefined();
expect(service.getSection(ManagementSectionId.InsightsAndAlerting)).toBeDefined();
expect(service.getSection(ManagementSectionId.Security)).toBeDefined();
expect(service.getSection(ManagementSectionId.Kibana)).toBeDefined();
expect(service.getSection(ManagementSectionId.Stack)).toBeDefined();
});
31 changes: 19 additions & 12 deletions src/plugins/management/public/management_service.ts
Expand Up @@ -17,11 +17,14 @@
* under the License.
*/

import { ReactElement } from 'react';

import { ManagementSection } from './management_section';
import { managementSections } from './management_sections';
import { KibanaLegacySetup } from '../../kibana_legacy/public';
// @ts-ignore
import { LegacyManagementSection } from './legacy';
import { CreateSection } from './types';
import { LegacyManagementSection, sections } from './legacy';
import { CreateSection, ManagementSectionId } from './types';
import { StartServicesAccessor, CoreStart } from '../../../core/public';

export class ManagementService {
Expand All @@ -48,7 +51,8 @@ export class ManagementService {
return newSection;
};
}
private getSection(sectionId: ManagementSection['id']) {

private getSection(sectionId: ManagementSectionId) {
return this.sections.find(section => section.id === sectionId);
}

Expand All @@ -63,7 +67,13 @@ export class ManagementService {
}

private sharedInterface = {
getSection: this.getSection.bind(this),
getSection: (sectionId: ManagementSectionId) => {
const section = this.getSection(sectionId);
if (!section) {
throw new Error(`Management section with id ${sectionId} is undefined`);
}
return section;
},
getSectionsEnabled: this.getSectionsEnabled.bind(this),
getAllSections: this.getAllSections.bind(this),
};
Expand All @@ -79,16 +89,13 @@ export class ManagementService {
getStartServices
);

register({ id: 'kibana', title: 'Kibana', order: 30, euiIconType: 'logoKibana' });
register({
id: 'elasticsearch',
title: 'Elasticsearch',
order: 20,
euiIconType: 'logoElasticsearch',
});
managementSections.forEach(
({ id, title }: { id: ManagementSectionId; title: ReactElement }, idx: number) => {
register({ id, title, order: idx });
}
);

return {
register,
...this.sharedInterface,
};
}
Expand Down
1 change: 0 additions & 1 deletion src/plugins/management/public/mocks/index.ts
Expand Up @@ -30,7 +30,6 @@ const createManagementSectionMock = (): jest.Mocked<PublicMethodsOf<ManagementSe

const createSetupContract = (): DeeplyMockedKeys<ManagementSetup> => ({
sections: {
register: jest.fn(),
getSection: jest.fn().mockReturnValue(createManagementSectionMock()),
getAllSections: jest.fn().mockReturnValue([]),
},
Expand Down