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

Shim dev tools #49349

Merged
merged 52 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
62f3164
centralize dependencies
flash1293 Oct 18, 2019
0bf00ae
move more stuff into kibana_services
flash1293 Oct 18, 2019
e72e51a
fix tests and dependency
flash1293 Oct 18, 2019
b42f417
bootstrap home via local application service
flash1293 Oct 19, 2019
0d2521e
fix routing for home app
flash1293 Oct 19, 2019
12fb70b
Merge remote-tracking branch 'upstream/master' into centralize-home
flash1293 Oct 21, 2019
af3ad7f
switch to dependency getter instead of direct exports
flash1293 Oct 21, 2019
a455322
Merge branch 'centralize-home' into local-application-service
flash1293 Oct 21, 2019
a1295d3
clean up
flash1293 Oct 21, 2019
082748a
add redirect functionality to local application service
flash1293 Oct 21, 2019
2bf3bf6
return early from route change handlers on dummy wrapper route
flash1293 Oct 21, 2019
398299c
fix jest tests
flash1293 Oct 21, 2019
822cdac
Merge remote-tracking branch 'upstream/master' into centralize-home
flash1293 Oct 22, 2019
4ea2e63
fix broken tests
flash1293 Oct 22, 2019
22c5588
Merge branch 'centralize-home' into local-application-service
flash1293 Oct 22, 2019
1bd6b3b
local application service
flash1293 Oct 22, 2019
c417060
fix mounting home several times
flash1293 Oct 22, 2019
48ecdf7
Merge branch 'master' into flash1293/local-application-service
elasticmachine Oct 24, 2019
2bc8856
started shimming dev tools and switching to new registry
flash1293 Oct 25, 2019
74fb184
Merge remote-tracking branch 'upstream/master' into flash1293/local-a…
flash1293 Oct 28, 2019
79a1a14
Merge branch 'flash1293/local-application-service' of github.com:flas…
flash1293 Oct 28, 2019
caa489a
Merge branch 'flash1293/local-application-service' into shim-dev_tools
flash1293 Oct 28, 2019
5195ebf
review fixes
flash1293 Oct 28, 2019
ebc5d96
move registry into new platform and honor ui capabilities
flash1293 Oct 28, 2019
cff57c2
document dev tools registry
flash1293 Oct 29, 2019
22ee254
Merge remote-tracking branch 'upstream/master' into shim-dev_tools
flash1293 Oct 30, 2019
6bc61a8
Merge remote-tracking branch 'upstream/master' into flash1293/local-a…
flash1293 Oct 30, 2019
a724d7b
review fixes
flash1293 Oct 30, 2019
5aedc62
decouple from home PR
flash1293 Oct 30, 2019
f7e3079
Merge branch 'flash1293/local-application-service' into shim-dev_tools
flash1293 Oct 30, 2019
23558e3
deangularize grokdebugger
flash1293 Oct 30, 2019
2717229
clean up grokdebugger and dev tools integration
flash1293 Oct 30, 2019
b455c15
Merge remote-tracking branch 'upstream/master' into shim-dev_tools
flash1293 Oct 31, 2019
fc08919
Merge remote-tracking branch 'upstream/master' into shim-dev_tools
flash1293 Nov 3, 2019
2c63955
Merge remote-tracking branch 'upstream/master' into shim-dev_tools
flash1293 Nov 3, 2019
6f2235c
finalize dev tools PR
flash1293 Nov 3, 2019
84b3e4b
add karma mock
flash1293 Nov 3, 2019
3f176f4
fix import
flash1293 Nov 4, 2019
8936fbb
Merge remote-tracking branch 'upstream/master' into shim-dev_tools
flash1293 Nov 4, 2019
0e6d46f
add data-test subj for dev toola
flash1293 Nov 4, 2019
e2a29ab
fix infra by avoiding route_setup import
flash1293 Nov 4, 2019
21ef98a
fix functional tests
flash1293 Nov 5, 2019
1aff48e
add todos
flash1293 Nov 5, 2019
1604156
move console feature registration to right place
flash1293 Nov 5, 2019
7ec64ba
fix translations
flash1293 Nov 5, 2019
2b26b78
Merge branch 'master' into shim-dev_tools
elasticmachine Nov 7, 2019
79a38a2
Merge remote-tracking branch 'upstream/master' into shim-dev_tools
flash1293 Nov 10, 2019
f93ceb0
do not render on redirect
flash1293 Nov 10, 2019
57e0197
Merge branch 'shim-dev_tools' of github.com:flash1293/kibana into shi…
flash1293 Nov 10, 2019
1d6faa6
Merge branch 'master' into shim-dev_tools
elasticmachine Nov 12, 2019
38498db
address review comments
flash1293 Nov 12, 2019
7017789
Merge branch 'master' into shim-dev_tools
elasticmachine Nov 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move registry into new platform and honor ui capabilities
  • Loading branch information
flash1293 committed Oct 28, 2019
commit ebc5d96856d329afc66d577079b0c8650bdc522e
6 changes: 4 additions & 2 deletions src/legacy/core_plugins/kibana/public/dev_tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { npSetup } from 'ui/new_platform';
import { npSetup, npStart } from 'ui/new_platform';
import { FeatureCatalogueRegistryProvider } from 'ui/registry/feature_catalogue';

import { DevToolsPlugin } from './plugin';
Expand All @@ -31,4 +31,6 @@ export const devToolsSetup = instance.setup(npSetup.core, {
FeatureCatalogueRegistryProvider,
},
});
instance.start();
instance.start(npStart.core, {
newPlatformDevTools: npStart.plugins.devTools,
});
42 changes: 12 additions & 30 deletions src/legacy/core_plugins/kibana/public/dev_tools/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* under the License.
*/

import { sortBy } from 'lodash';
import { App, CoreSetup, Plugin } from 'kibana/public';
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';

import { LocalApplicationService } from '../local_application_service';
import { DevTool, DevToolsStart } from '../../../../../plugins/dev_tools/public';

export interface DevToolsPluginSetupDependencies {
__LEGACY: {
Expand All @@ -31,27 +31,12 @@ export interface DevToolsPluginSetupDependencies {
};
}

export interface DevToolsSetup {
register: (devTool: DevTool) => void;
export interface DevToolsPluginStartDependencies {
newPlatformDevTools: DevToolsStart;
}

export interface DevTool {
id: string;
title: string;
mount: App['mount'];
disabled?: boolean;
tooltipContent?: string;
enableRouting: boolean;
order: number;
}

export class DevToolsPlugin implements Plugin<DevToolsSetup> {
private devTools: DevTool[] = [];

private getSortedDevTools() {
// TODO make sure this works
return sortBy(this.devTools, 'order');
}
export class DevToolsPlugin implements Plugin {
private getSortedDevTools: (() => DevTool[]) | null = null;

public setup(
core: CoreSetup,
Expand All @@ -78,8 +63,9 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup> {
id: 'dev_tools',
title: 'Dev Tools',
mount: async (appMountContext, params) => {
// TODO check capabilities whether this page is allowed to be rendered
// TODO badge and breadcrumb handling
if (!this.getSortedDevTools) {
throw new Error('not started yet');
}
const { renderApp } = await import('./render_app');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention, this module should live in ./application

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maryia-lapata @kertal we probably have to fix that in a few places ;)

return renderApp(
params.element,
Expand All @@ -89,13 +75,9 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup> {
);
},
});

return {
register: (devTool: DevTool) => {
this.devTools.push(devTool);
},
};
}

start() {}
start(core: CoreStart, { newPlatformDevTools }: DevToolsPluginStartDependencies) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start(core: CoreStart, { newPlatformDevTools }: DevToolsPluginStartDependencies) {
public start(core: CoreStart, { newPlatformDevTools }: DevToolsPluginStartDependencies) {

this.getSortedDevTools = newPlatformDevTools.getSortedDevTools;
}
}
39 changes: 37 additions & 2 deletions src/legacy/core_plugins/kibana/public/dev_tools/render_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/

import { I18nProvider } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { EuiTab, EuiTabs } from '@elastic/eui';
import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom';
import * as React from 'react';
import ReactDOM from 'react-dom';
import { useEffect, useRef } from 'react';

import { AppMountContext } from 'kibana/public';

import { DevTool } from './plugin';
import { DevTool } from '../../../../../plugins/dev_tools/public';

interface DevToolsWrapperProps {
devTools: DevTool[];
Expand Down Expand Up @@ -107,12 +107,47 @@ function DevToolsWrapper({
);
}

function redirectOnMissingCapabilities(appMountContext: AppMountContext) {
if (!appMountContext.core.application.capabilities.dev_tools.show) {
window.location.hash = '/home';
}
}

function setBadge(appMountContext: AppMountContext) {
if (appMountContext.core.application.capabilities.dev_tools.save) {
return;
}
appMountContext.core.chrome.setBadge({
text: i18n.translate('kbn.devTools.badge.readOnly.text', {
defaultMessage: 'Read only',
}),
tooltip: i18n.translate('kbn.devTools.badge.readOnly.tooltip', {
defaultMessage: 'Unable to save',
}),
iconType: 'glasses',
});
}

function setBreadcrumbs(appMountContext: AppMountContext) {
appMountContext.core.chrome.setBreadcrumbs([
{
text: i18n.translate('kbn.devTools.k7BreadcrumbsDevToolsLabel', {
defaultMessage: 'Dev Tools',
}),
href: '#/dev_tools',
},
]);
}

export function renderApp(
element: HTMLElement,
appMountContext: AppMountContext,
basePath: string,
devTools: DevTool[]
) {
redirectOnMissingCapabilities(appMountContext);
setBadge(appMountContext);
setBreadcrumbs(appMountContext);
ReactDOM.render(
<I18nProvider>
<Router>
Expand Down
3 changes: 3 additions & 0 deletions src/legacy/ui/public/new_platform/new_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ import {
Start as InspectorStart,
} from '../../../../plugins/inspector/public';
import { EuiUtilsStart } from '../../../../plugins/eui_utils/public';
import { DevToolsSetup, DevToolsStart } from '../../../../plugins/dev_tools/public';

export interface PluginsSetup {
data: ReturnType<DataPlugin['setup']>;
embeddable: EmbeddableSetup;
expressions: ReturnType<ExpressionsPlugin['setup']>;
inspector: InspectorSetup;
uiActions: IUiActionsSetup;
devTools: DevToolsSetup;
}

export interface PluginsStart {
Expand All @@ -44,6 +46,7 @@ export interface PluginsStart {
expressions: ReturnType<ExpressionsPlugin['start']>;
inspector: InspectorStart;
uiActions: IUiActionsStart;
devTools: DevToolsStart;
}

export const npSetup = {
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/dev_tools/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "devTools",
"version": "kibana",
"server": false,
"ui": true
}
27 changes: 27 additions & 0 deletions src/plugins/dev_tools/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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 { PluginInitializerContext } from 'kibana/public';
import { DevToolsPlugin } from './plugin';

export function plugin(initializerContext: PluginInitializerContext) {
return new DevToolsPlugin();
}

export * from './plugin';
62 changes: 62 additions & 0 deletions src/plugins/dev_tools/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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 { App, CoreSetup, Plugin } from 'kibana/public';
import { sortBy } from 'lodash';

export interface DevToolsSetup {
register: (devTool: DevTool) => void;
}

export interface DevToolsStart {
getSortedDevTools: () => DevTool[];
}

export interface DevTool {
id: string;
title: string;
mount: App['mount'];
disabled?: boolean;
tooltipContent?: string;
enableRouting: boolean;
order: number;
}

export class DevToolsPlugin implements Plugin<DevToolsSetup, DevToolsStart> {
private devTools: DevTool[] = [];

private getSortedDevTools() {
// TODO make sure this works
return sortBy(this.devTools, 'order');
}

public setup(core: CoreSetup) {
return {
register: (devTool: DevTool) => {
this.devTools.push(devTool);
},
};
}

start() {
return {
getSortedDevTools: this.getSortedDevTools.bind(this),
};
}
}