Skip to content

Commit 2b26a39

Browse files
authored
Advanced settings component registry ⇒ kibana platform plugin (#55940) (#56808)
* advanced settings component registry to new platform
1 parent f48c339 commit 2b26a39

File tree

41 files changed

+399
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+399
-297
lines changed

.i18nrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"src/legacy/core_plugins/management",
2727
"src/plugins/management"
2828
],
29+
"advancedSettings": "src/plugins/advanced_settings",
2930
"kibana_react": "src/legacy/core_plugins/kibana_react",
3031
"kibana-react": "src/plugins/kibana_react",
3132
"kibana_utils": "src/plugins/kibana_utils",

src/legacy/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/legacy/core_plugins/kibana/public/management/sections/settings/advanced_settings.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import {
2727
UiSettingsType,
2828
} from '../../../../../../../core/public';
2929
import { FieldSetting } from './types';
30+
3031
import { AdvancedSettings } from './advanced_settings';
32+
jest.mock('ui/new_platform');
3133

3234
jest.mock('ui/new_platform', () => ({
3335
npStart: mockConfig(),
@@ -215,6 +217,22 @@ function mockConfig() {
215217
core: {
216218
uiSettings: config,
217219
},
220+
plugins: {
221+
advancedSettings: {
222+
component: {
223+
register: jest.fn(),
224+
get: () => {
225+
const foo: React.ComponentType = () => <div>Hello</div>;
226+
foo.displayName = 'foo_component';
227+
return foo;
228+
},
229+
componentType: {
230+
PAGE_TITLE_COMPONENT: 'page_title_component',
231+
PAGE_SUBTITLE_COMPONENT: 'page_subtitle_component',
232+
},
233+
},
234+
},
235+
},
218236
};
219237
}
220238

src/legacy/core_plugins/kibana/public/management/sections/settings/advanced_settings.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ import { getAriaName, toEditableConfig, DEFAULT_CATEGORY } from './lib';
3131

3232
import { FieldSetting, IQuery } from './types';
3333

34-
import {
35-
registerDefaultComponents,
36-
PAGE_TITLE_COMPONENT,
37-
PAGE_SUBTITLE_COMPONENT,
38-
PAGE_FOOTER_COMPONENT,
39-
} from './components/default_component_registry';
40-
import { getSettingsComponent } from './components/component_registry';
41-
4234
interface AdvancedSettingsProps {
4335
queryText: string;
4436
enableSaving: boolean;
@@ -75,8 +67,6 @@ export class AdvancedSettings extends Component<AdvancedSettingsProps, AdvancedS
7567
footerQueryMatched: false,
7668
filteredSettings: this.mapSettings(Query.execute(parsedQuery, this.settings)),
7769
};
78-
79-
registerDefaultComponents();
8070
}
8171

8272
init(config: IUiSettingsClient) {
@@ -166,10 +156,13 @@ export class AdvancedSettings extends Component<AdvancedSettingsProps, AdvancedS
166156

167157
render() {
168158
const { filteredSettings, query, footerQueryMatched } = this.state;
159+
const componentRegistry = npStart.plugins.advancedSettings.component;
169160

170-
const PageTitle = getSettingsComponent(PAGE_TITLE_COMPONENT);
171-
const PageSubtitle = getSettingsComponent(PAGE_SUBTITLE_COMPONENT);
172-
const PageFooter = getSettingsComponent(PAGE_FOOTER_COMPONENT);
161+
const PageTitle = componentRegistry.get(componentRegistry.componentType.PAGE_TITLE_COMPONENT);
162+
const PageSubtitle = componentRegistry.get(
163+
componentRegistry.componentType.PAGE_SUBTITLE_COMPONENT
164+
);
165+
const PageFooter = componentRegistry.get(componentRegistry.componentType.PAGE_FOOTER_COMPONENT);
173166

174167
return (
175168
<div>

src/legacy/core_plugins/kibana/public/management/sections/settings/components/__snapshots__/component_registry.test.tsx.snap

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.test.tsx

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.test.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/legacy/core_plugins/telemetry/public/views/management/management.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
import React from 'react';
2020
import routes from 'ui/routes';
2121

22-
import { registerSettingsComponent, PAGE_FOOTER_COMPONENT } from 'ui/management';
22+
import { npSetup } from 'ui/new_platform';
2323
import { TelemetryOptInProvider } from '../../services';
2424
import { TelemetryForm } from '../../components';
2525

2626
routes.defaults(/\/management/, {
2727
resolve: {
2828
telemetryManagementSection: function(Private) {
2929
const telemetryOptInProvider = Private(TelemetryOptInProvider);
30+
const componentRegistry = npSetup.plugins.advancedSettings.component;
3031

3132
const Component = props => (
3233
<TelemetryForm
@@ -36,7 +37,11 @@ routes.defaults(/\/management/, {
3637
/>
3738
);
3839

39-
registerSettingsComponent(PAGE_FOOTER_COMPONENT, Component, true);
40+
componentRegistry.register(
41+
componentRegistry.componentType.PAGE_FOOTER_COMPONENT,
42+
Component,
43+
true
44+
);
4045
},
4146
},
4247
});

src/legacy/ui/public/management/index.d.ts

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

2020
declare module 'ui/management' {
21-
export const PAGE_TITLE_COMPONENT: string;
22-
export const PAGE_SUBTITLE_COMPONENT: string;
23-
export const PAGE_FOOTER_COMPONENT: string;
2421
export const SidebarNav: React.FC<any>;
25-
export function registerSettingsComponent(
26-
id: string,
27-
component: string | React.FC<any>,
28-
allowOverride: boolean
29-
): void;
3022
export const management: any; // TODO - properly provide types
3123
export const MANAGEMENT_BREADCRUMB: {
3224
text: string;

0 commit comments

Comments
 (0)