File tree Expand file tree Collapse file tree
legacy/core_plugins/kibana/public/dev_tools Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import { AppMountContext } from 'kibana/public';
2929import { DevTool } from '../../../../../plugins/dev_tools/public' ;
3030
3131interface DevToolsWrapperProps {
32- devTools : DevTool [ ] ;
32+ devTools : readonly DevTool [ ] ;
3333 activeDevTool : DevTool ;
3434 appMountContext : AppMountContext ;
3535 updateRoute : ( newRoute : string ) => void ;
@@ -145,10 +145,10 @@ export function renderApp(
145145 element : HTMLElement ,
146146 appMountContext : AppMountContext ,
147147 basePath : string ,
148- devTools : DevTool [ ]
148+ devTools : readonly DevTool [ ]
149149) {
150150 if ( redirectOnMissingCapabilities ( appMountContext ) ) {
151- return ;
151+ return ( ) => { } ;
152152 }
153153 setBadge ( appMountContext ) ;
154154 setBreadcrumbs ( appMountContext ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export interface DevToolsPluginStartDependencies {
3636}
3737
3838export class DevToolsPlugin implements Plugin {
39- private getSortedDevTools : ( ( ) => DevTool [ ] ) | null = null ;
39+ private getSortedDevTools : ( ( ) => readonly DevTool [ ] ) | null = null ;
4040
4141 public setup (
4242 core : CoreSetup ,
@@ -49,7 +49,7 @@ export class DevToolsPlugin implements Plugin {
4949 if ( ! this . getSortedDevTools ) {
5050 throw new Error ( 'not started yet' ) ;
5151 }
52- const { renderApp } = await import ( './render_app ' ) ;
52+ const { renderApp } = await import ( './application ' ) ;
5353 return renderApp (
5454 params . element ,
5555 appMountContext ,
@@ -60,7 +60,7 @@ export class DevToolsPlugin implements Plugin {
6060 } ) ;
6161 }
6262
63- start ( core : CoreStart , { newPlatformDevTools } : DevToolsPluginStartDependencies ) {
63+ public start ( core : CoreStart , { newPlatformDevTools } : DevToolsPluginStartDependencies ) {
6464 this . getSortedDevTools = newPlatformDevTools . getSortedDevTools ;
6565 if ( this . getSortedDevTools ( ) . length === 0 ) {
6666 core . chrome . navLinks . update ( 'kibana:dev_tools' , {
Original file line number Diff line number Diff line change 1+ # Dev tools plugin
2+
3+ The ui/registry/dev_tools is removed in favor of the ` dev_tools ` plugin which exposes a register method in the setup contract.
4+ Registering app works mostly the same as registering apps in core.application.register.
5+ Routing will be handled by the id of the dev tool - your dev tool will be mounted when the URL matches ` /app/kibana#/dev_tools/<YOUR ID> ` .
6+ This API doesn't support angular, for registering angular dev tools, bootstrap a local module on mount into the given HTML element.
7+
8+ During the migration this plugin exposes the registered dev tools in the start contract. This is necessary to keep the dev tools app
9+ which is still living in the legacy platform working and will be removed once everything is moved over to the new platform. It should
10+ not be used by other plugins.
11+
12+ ## Example registration
13+
14+ ``` ts
15+ // For legacy plugins
16+ import { npSetup } from ' ui/new_platform' ;
17+ npSetup .plugins .dev_tools .register (/* same details here */ );
18+
19+ // For new plugins: first add 'dev_tools' to the list of `optionalPlugins`
20+ // in your kibana.json file. Then access the plugin directly in `setup`:
21+
22+ class MyPlugin {
23+ setup(core , plugins ) {
24+ if (plugins .dev_tools ) {
25+ plugins .dev_tools .register (/* same details here. */ );
26+ }
27+ }
28+ }
29+ ```
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export interface DevToolsStart {
4343 * becomes an implementation detail.
4444 * @deprecated
4545 */
46- getSortedDevTools : ( ) => DevTool [ ] ;
46+ getSortedDevTools : ( ) => readonly DevTool [ ] ;
4747}
4848
4949/**
@@ -87,21 +87,27 @@ export interface DevTool {
8787}
8888
8989export class DevToolsPlugin implements Plugin < DevToolsSetup , DevToolsStart > {
90- private devTools : DevTool [ ] = [ ] ;
90+ private readonly devTools = new Map < string , DevTool > ( ) ;
9191
92- private getSortedDevTools ( ) {
93- return sortBy ( this . devTools , 'order' ) ;
92+ private getSortedDevTools ( ) : readonly DevTool [ ] {
93+ return sortBy ( [ ... this . devTools . values ( ) ] , 'order' ) ;
9494 }
9595
9696 public setup ( core : CoreSetup ) {
9797 return {
9898 register : ( devTool : DevTool ) => {
99- this . devTools . push ( devTool ) ;
99+ if ( this . devTools . has ( devTool . id ) ) {
100+ throw new Error (
101+ `Dev tool with id [${ devTool . id } ] has already been registered. Use a unique id.`
102+ ) ;
103+ }
104+
105+ this . devTools . set ( devTool . id , devTool ) ;
100106 } ,
101107 } ;
102108 }
103109
104- start ( ) {
110+ public start ( ) {
105111 return {
106112 getSortedDevTools : this . getSortedDevTools . bind ( this ) ,
107113 } ;
You can’t perform that action at this time.
0 commit comments