Migrate test plugins ⇒ NP (kbn_tp_embeddable_explorer) (#64756)

* Migrated kbn_tp_embeddable_explorer to the new platform.

* Added discover as a dependency

* fixed types

* Updated typescript task

* revert previous commit

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Uladzislau Lasitsa 2020-05-07 14:15:37 +03:00 committed by GitHub
parent e723a8f916
commit 6ef45e17d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 122 additions and 251 deletions

View file

@ -1,39 +0,0 @@
/*
* 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 { Legacy } from 'kibana';
// eslint-disable-next-line import/no-default-export
export default function(kibana: any) {
return new kibana.Plugin({
require: ['kibana'],
uiExports: {
app: {
title: 'Embeddable Explorer',
order: 1,
main: 'plugins/kbn_tp_embeddable_explorer/np_ready/public/legacy',
},
},
init(server: Legacy.Server) {
server.injectUiAppVars('kbn_tp_embeddable_explorer', async () =>
server.getInjectedUiAppVars('kibana')
);
},
});
}

View file

@ -0,0 +1,16 @@
{
"id": "kbn_tp_embeddable_explorer",
"version": "0.0.1",
"kibanaVersion": "kibana",
"requiredPlugins": [
"visTypeMarkdown",
"visTypeVislib",
"data",
"embeddable",
"uiActions",
"inspector",
"discover"
],
"server": false,
"ui": true
}

View file

@ -24,7 +24,7 @@ import {
DASHBOARD_CONTAINER_TYPE,
DashboardContainer,
DashboardContainerInput,
} from '../../../../../../../../src/plugins/dashboard/public';
} from '../../../../../../src/plugins/dashboard/public';
import { dashboardInput } from './dashboard_input';

View file

@ -18,7 +18,7 @@
*/
import { ViewMode, CONTACT_CARD_EMBEDDABLE, HELLO_WORLD_EMBEDDABLE } from '../embeddable_api';
import { DashboardContainerInput } from '../../../../../../../../src/plugins/dashboard/public';
import { DashboardContainerInput } from '../../../../../../src/plugins/dashboard/public';
export const dashboardInput: DashboardContainerInput = {
panels: {

View file

@ -17,6 +17,9 @@
* under the License.
*/
export * from '../../../../../../../src/plugins/embeddable/public';
export * from '../../../../../../../src/plugins/embeddable/public/lib/test_samples';
export { HELLO_WORLD_EMBEDDABLE } from '../../../../../../../examples/embeddable_examples/public';
export * from '../../../../../src/plugins/embeddable/public';
export * from '../../../../../src/plugins/embeddable/public/lib/test_samples';
export {
HELLO_WORLD_EMBEDDABLE,
HelloWorldEmbeddableFactory,
} from '../../../../../examples/embeddable_examples/public';

View file

@ -1,20 +0,0 @@
/*
* 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 './np_ready/public/legacy';

View file

@ -1,10 +0,0 @@
{
"id": "kbn_tp_embeddable_explorer",
"version": "kibana",
"requiredPlugins": [
"embeddable",
"inspector"
],
"server": false,
"ui": true
}

View file

@ -1,3 +0,0 @@
<div id="embeddableExplorerRoot" class="application tab-dashboard"> ANGULAR STUFF!</div>

View file

@ -1,90 +0,0 @@
/*
* 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.
*/
/* eslint-disable @kbn/eslint/no-restricted-paths */
import 'ui/autoload/all';
import 'uiExports/interpreter';
import 'uiExports/embeddableFactories';
import 'uiExports/embeddableActions';
import 'uiExports/contextMenuActions';
import 'uiExports/devTools';
import 'uiExports/docViews';
import 'uiExports/embeddableActions';
import 'uiExports/fieldFormatEditors';
import 'uiExports/fieldFormats';
import 'uiExports/home';
import 'uiExports/indexManagement';
import 'uiExports/inspectorViews';
import 'uiExports/savedObjectTypes';
import 'uiExports/search';
import 'uiExports/shareContextMenuExtensions';
import 'uiExports/visTypes';
import 'uiExports/visualize';
import { npSetup, npStart } from 'ui/new_platform';
import { ExitFullScreenButton } from 'ui/exit_full_screen';
import uiRoutes from 'ui/routes';
// @ts-ignore
import { uiModules } from 'ui/modules';
/* eslint-enable @kbn/eslint/no-restricted-paths */
import template from './index.html';
import { plugin } from '.';
const pluginInstance = plugin({} as any);
export const setup = pluginInstance.setup(npSetup.core, {
embeddable: npSetup.plugins.embeddable,
inspector: npSetup.plugins.inspector,
__LEGACY: {
ExitFullScreenButton,
},
});
let rendered = false;
const onRenderCompleteListeners: Array<() => void> = [];
uiRoutes.enable();
uiRoutes.defaults(/\embeddable_explorer/, {});
uiRoutes.when('/', {
template,
controller($scope) {
$scope.$$postDigest(() => {
rendered = true;
onRenderCompleteListeners.forEach(listener => listener());
});
},
});
export const start = pluginInstance.start(npStart.core, {
embeddable: npStart.plugins.embeddable,
inspector: npStart.plugins.inspector,
uiActions: npStart.plugins.uiActions,
__LEGACY: {
ExitFullScreenButton,
onRenderComplete: (renderCompleteListener: () => void) => {
if (rendered) {
renderCompleteListener();
} else {
onRenderCompleteListeners.push(renderCompleteListener);
}
},
},
});

View file

@ -1,84 +0,0 @@
/*
* 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 React from 'react';
import ReactDOM from 'react-dom';
import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { UiActionsStart } from '../../../../../../../src/plugins/ui_actions/public';
import { createHelloWorldAction } from '../../../../../../../src/plugins/ui_actions/public/tests/test_samples';
import {
Start as InspectorStartContract,
Setup as InspectorSetupContract,
} from '../../../../../../../src/plugins/inspector/public';
import { CONTEXT_MENU_TRIGGER } from './embeddable_api';
const REACT_ROOT_ID = 'embeddableExplorerRoot';
import { SayHelloAction, createSendMessageAction } from './embeddable_api';
import { App } from './app';
import {
EmbeddableStart,
EmbeddableSetup,
} from '.../../../../../../../src/plugins/embeddable/public';
export interface SetupDependencies {
embeddable: EmbeddableSetup;
inspector: InspectorSetupContract;
__LEGACY: {
ExitFullScreenButton: React.ComponentType<any>;
};
}
interface StartDependencies {
embeddable: EmbeddableStart;
uiActions: UiActionsStart;
inspector: InspectorStartContract;
__LEGACY: {
ExitFullScreenButton: React.ComponentType<any>;
onRenderComplete: (onRenderComplete: () => void) => void;
};
}
export type EmbeddableExplorerSetup = void;
export type EmbeddableExplorerStart = void;
export class EmbeddableExplorerPublicPlugin
implements
Plugin<EmbeddableExplorerSetup, EmbeddableExplorerStart, SetupDependencies, StartDependencies> {
public setup(core: CoreSetup, setupDeps: SetupDependencies): EmbeddableExplorerSetup {}
public start(core: CoreStart, plugins: StartDependencies): EmbeddableExplorerStart {
const helloWorldAction = createHelloWorldAction(core.overlays);
const sayHelloAction = new SayHelloAction(alert);
const sendMessageAction = createSendMessageAction(core.overlays);
plugins.uiActions.registerAction(sayHelloAction);
plugins.uiActions.registerAction(sendMessageAction);
plugins.uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, helloWorldAction);
plugins.__LEGACY.onRenderComplete(() => {
const root = document.getElementById(REACT_ROOT_ID);
ReactDOM.render(<App embeddableServices={plugins.embeddable} />, root);
});
}
public stop() {}
}

View file

@ -0,0 +1,98 @@
/*
* 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 React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { CoreSetup, Plugin, AppMountParameters } from 'kibana/public';
import { UiActionsStart, UiActionsSetup } from '../../../../../src/plugins/ui_actions/public';
import { createHelloWorldAction } from '../../../../../src/plugins/ui_actions/public/tests/test_samples';
import {
Start as InspectorStartContract,
Setup as InspectorSetupContract,
} from '../../../../../src/plugins/inspector/public';
import { App } from './app';
import {
CONTEXT_MENU_TRIGGER,
CONTACT_CARD_EMBEDDABLE,
HELLO_WORLD_EMBEDDABLE,
HelloWorldEmbeddableFactory,
ContactCardEmbeddableFactory,
SayHelloAction,
createSendMessageAction,
} from './embeddable_api';
import {
EmbeddableStart,
EmbeddableSetup,
} from '.../../../../../../../src/plugins/embeddable/public';
export interface SetupDependencies {
embeddable: EmbeddableSetup;
inspector: InspectorSetupContract;
uiActions: UiActionsSetup;
}
interface StartDependencies {
embeddable: EmbeddableStart;
uiActions: UiActionsStart;
inspector: InspectorStartContract;
}
export type EmbeddableExplorerSetup = void;
export type EmbeddableExplorerStart = void;
export class EmbeddableExplorerPublicPlugin
implements
Plugin<EmbeddableExplorerSetup, EmbeddableExplorerStart, SetupDependencies, StartDependencies> {
public setup(core: CoreSetup, setupDeps: SetupDependencies): EmbeddableExplorerSetup {
const helloWorldAction = createHelloWorldAction({} as any);
const sayHelloAction = new SayHelloAction(alert);
const sendMessageAction = createSendMessageAction({} as any);
setupDeps.uiActions.registerAction(helloWorldAction);
setupDeps.uiActions.registerAction(sayHelloAction);
setupDeps.uiActions.registerAction(sendMessageAction);
setupDeps.uiActions.attachAction(CONTEXT_MENU_TRIGGER, helloWorldAction.id);
setupDeps.embeddable.registerEmbeddableFactory(
HELLO_WORLD_EMBEDDABLE,
new HelloWorldEmbeddableFactory()
);
setupDeps.embeddable.registerEmbeddableFactory(
CONTACT_CARD_EMBEDDABLE,
new ContactCardEmbeddableFactory((() => null) as any, {} as any)
);
core.application.register({
id: 'EmbeddableExplorer',
title: 'Embeddable Explorer',
async mount(params: AppMountParameters) {
const startPlugins = (await core.getStartServices())[1] as StartDependencies;
render(<App embeddableServices={startPlugins.embeddable} />, params.element);
return () => unmountComponentAtNode(params.element);
},
});
}
public start() {}
public stop() {}
}