Skip to content

Commit 2d36b21

Browse files
authored
move management registry to new platform (#53020)
* move management registry to new platform
1 parent 18b5cf9 commit 2d36b21

File tree

28 files changed

+220
-83
lines changed

28 files changed

+220
-83
lines changed

.i18nrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"kbn": "src/legacy/core_plugins/kibana",
2222
"kbnDocViews": "src/legacy/core_plugins/kbn_doc_views",
2323
"kbnVislibVisTypes": "src/legacy/core_plugins/kbn_vislib_vis_types",
24-
"management": "src/legacy/core_plugins/management",
24+
"management": ["src/legacy/core_plugins/management", "src/plugins/management"],
2525
"kibana_react": "src/legacy/core_plugins/kibana_react",
2626
"kibana-react": "src/plugins/kibana_react",
2727
"kibana_utils": "src/plugins/kibana_utils",

src/legacy/core_plugins/telemetry/public/components/telemetry_form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
} from '@elastic/eui';
3232
import { PRIVACY_STATEMENT_URL } from '../../common/constants';
3333
import { OptInExampleFlyout } from './opt_in_details_component';
34-
import { Field } from 'ui/management';
34+
import { Field } from '../../../kibana/public/management/sections/settings/components/field/field';
3535
import { FormattedMessage } from '@kbn/i18n/react';
3636
import { i18n } from '@kbn/i18n';
3737

src/legacy/ui/public/management/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export {
2323
PAGE_FOOTER_COMPONENT,
2424
} from '../../../core_plugins/kibana/public/management/sections/settings/components/default_component_registry';
2525
export { registerSettingsComponent } from '../../../core_plugins/kibana/public/management/sections/settings/components/component_registry';
26-
export { Field } from '../../../core_plugins/kibana/public/management/sections/settings/components/field/field';
27-
export { management } from './sections_register';
2826
export { SidebarNav } from './components';
2927
export { MANAGEMENT_BREADCRUMB } from './breadcrumbs';
28+
29+
import { npStart } from 'ui/new_platform';
30+
export const management = npStart.plugins.management.legacy;

src/legacy/ui/public/new_platform/__mocks__/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { navigationPluginMock } from '../../../../../plugins/navigation/public/m
2525
import { expressionsPluginMock } from '../../../../../plugins/expressions/public/mocks';
2626
import { inspectorPluginMock } from '../../../../../plugins/inspector/public/mocks';
2727
import { uiActionsPluginMock } from '../../../../../plugins/ui_actions/public/mocks';
28+
import { managementPluginMock } from '../../../../../plugins/management/public/mocks';
2829
import { usageCollectionPluginMock } from '../../../../../plugins/usage_collection/public/mocks';
2930
/* eslint-enable @kbn/eslint/no-restricted-paths */
3031

@@ -45,6 +46,7 @@ export const pluginsMock = {
4546
inspector: inspectorPluginMock.createStartContract(),
4647
expressions: expressionsPluginMock.createStartContract(),
4748
uiActions: uiActionsPluginMock.createStartContract(),
49+
management: managementPluginMock.createStartContract(),
4850
}),
4951
};
5052

src/legacy/ui/public/new_platform/new_platform.karma_mock.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ export const npStart = {
137137
chrome: {},
138138
},
139139
plugins: {
140+
management: {
141+
legacy: {
142+
getSection: () => ({
143+
register: sinon.fake(),
144+
}),
145+
},
146+
},
140147
embeddable: {
141148
getEmbeddableFactory: sinon.fake(),
142149
getEmbeddableFactories: sinon.fake(),

src/legacy/ui/public/new_platform/new_platform.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { DevToolsSetup, DevToolsStart } from '../../../../plugins/dev_tools/publ
3232
import { KibanaLegacySetup, KibanaLegacyStart } from '../../../../plugins/kibana_legacy/public';
3333
import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../plugins/home/public';
3434
import { SharePluginSetup, SharePluginStart } from '../../../../plugins/share/public';
35+
import { ManagementStart } from '../../../../plugins/management/public';
3536
import { BfetchPublicSetup, BfetchPublicStart } from '../../../../plugins/bfetch/public';
3637
import { UsageCollectionSetup } from '../../../../plugins/usage_collection/public';
3738
import {
@@ -67,6 +68,7 @@ export interface PluginsStart {
6768
dev_tools: DevToolsStart;
6869
kibana_legacy: KibanaLegacyStart;
6970
share: SharePluginStart;
71+
management: ManagementStart;
7072
}
7173

7274
export const npSetup = {

src/plugins/management/kibana.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"id": "management",
3+
"version": "kibana",
4+
"server": false,
5+
"ui": true,
6+
"requiredPlugins": []
7+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { PluginInitializerContext } from 'kibana/public';
21+
import { ManagementPlugin } from './plugin';
22+
23+
export function plugin(initializerContext: PluginInitializerContext) {
24+
return new ManagementPlugin();
25+
}
26+
27+
export { ManagementStart } from './types';

src/legacy/ui/public/management/__tests__/index.js renamed to src/plugins/management/public/legacy/index.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,4 @@
1717
* under the License.
1818
*/
1919

20-
import expect from '@kbn/expect';
21-
22-
import { management } from '..';
23-
import { ManagementSection } from '../section';
24-
25-
describe('Management', () => {
26-
it('provides ManagementSection', () => {
27-
expect(management).to.be.a(ManagementSection);
28-
});
29-
});
20+
export { management } from './sections_register';

src/legacy/ui/public/management/section.js renamed to src/plugins/management/public/legacy/section.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
*/
1919

2020
import { assign } from 'lodash';
21-
import { IndexedArray } from '../indexed_array';
22-
import { capabilities } from '../capabilities';
21+
import { IndexedArray } from '../../../../legacy/ui/public/indexed_array';
2322

2423
const listeners = [];
2524

@@ -37,7 +36,7 @@ export class ManagementSection {
3736
* @returns {ManagementSection}
3837
*/
3938

40-
constructor(id, options = {}) {
39+
constructor(id, options = {}, capabilities) {
4140
this.display = id;
4241
this.id = id;
4342
this.items = new IndexedArray({
@@ -49,13 +48,14 @@ export class ManagementSection {
4948
this.tooltip = '';
5049
this.icon = '';
5150
this.url = '';
51+
this.capabilities = capabilities;
5252

5353
assign(this, options);
5454
}
5555

5656
get visibleItems() {
5757
return this.items.inOrder.filter(item => {
58-
const capabilityManagementSection = capabilities.get().management[this.id];
58+
const capabilityManagementSection = this.capabilities.management[this.id];
5959
const itemCapability = capabilityManagementSection
6060
? capabilityManagementSection[item.id]
6161
: null;
@@ -83,7 +83,7 @@ export class ManagementSection {
8383
*/
8484

8585
register(id, options = {}) {
86-
const item = new ManagementSection(id, assign(options, { parent: this }));
86+
const item = new ManagementSection(id, assign(options, { parent: this }), this.capabilities);
8787

8888
if (this.hasItem(id)) {
8989
throw new Error(`'${id}' is already registered`);

0 commit comments

Comments
 (0)