Skip to content

Commit

Permalink
Add searchDeepLinks for Dev Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Apr 12, 2021
1 parent e8aed5e commit 9fb9c4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/plugins/dev_tools/public/dev_tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { ReactNode } from 'react';
import { AppMount } from 'src/core/public';

/**
Expand All @@ -26,8 +27,9 @@ export class DevToolApp {
/**
* The human readable name of the dev tool. Should be internationalized.
* This will be used as a label in the tab above the actual tool.
* May also be a ReactNode.
*/
public readonly title: string;
public readonly title: ReactNode;
public readonly mount: AppMount;

/**
Expand Down Expand Up @@ -55,7 +57,7 @@ export class DevToolApp {

constructor(
id: string,
title: string,
title: ReactNode,
mount: AppMount,
enableRouting: boolean,
order: number,
Expand Down
16 changes: 15 additions & 1 deletion src/plugins/dev_tools/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { BehaviorSubject } from 'rxjs';
import { Plugin, CoreSetup, AppMountParameters } from 'src/core/public';
import { Plugin, CoreSetup, AppMountParameters, AppSearchDeepLink } from 'src/core/public';
import { AppUpdater } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { sortBy } from 'lodash';
Expand Down Expand Up @@ -84,6 +84,20 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup, void> {
public start() {
if (this.getSortedDevTools().length === 0) {
this.appStateUpdater.next(() => ({ navLinkStatus: AppNavLinkStatus.hidden }));
} else {
this.appStateUpdater.next(() => {
const deepLinks: AppSearchDeepLink[] = [...this.devTools.values()]
.filter(
// Some tools do not use a string title, so we filter those out
(tool) => !tool.enableRouting && !tool.isDisabled() && typeof tool.title === 'string'
)
.map((tool) => ({
id: tool.id,
title: tool.title as string,
path: `#/${tool.id}`,
}));
return { meta: { searchDeepLinks: deepLinks } };
});
}
}

Expand Down

0 comments on commit 9fb9c4d

Please sign in to comment.