kibana/examples/ui_actions_explorer/public/plugin.tsx
Tim Sullivan e4a32f8f3c
[SharedUX] Remove usage of deprecated React rendering utilities (#180516)
## Summary

Partially addresses https://github.com/elastic/kibana-team/issues/805

Follows https://github.com/elastic/kibana/pull/180003

These changes come up from searching in the code and finding where
certain kinds of deprecated AppEx-SharedUX modules are imported.
**Reviewers: Please interact with critical paths through the UI
components touched in this PR, ESPECIALLY in terms of testing dark mode
and i18n.**

This focuses on code within AppEx-SharedUX. [Reporting changes are
separate](https://github.com/elastic/kibana/pull/).

<img width="1107" alt="image"
src="c0d2ce08-ac35-45a7-8192-0b2256fceb0e">

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
2024-04-17 07:52:41 -07:00

95 lines
3.1 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { UiActionsStart, UiActionsSetup } from '@kbn/ui-actions-plugin/public';
import { Plugin, CoreSetup, AppMountParameters } from '@kbn/core/public';
import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';
import {
PHONE_TRIGGER,
USER_TRIGGER,
COUNTRY_TRIGGER,
lookUpWeatherAction,
viewInMapsAction,
createEditUserAction,
makePhoneCallAction,
showcasePluggability,
createTriggerPhoneTriggerAction,
} from './actions/actions';
import image from './ui_actions.png';
interface StartDeps {
uiActions: UiActionsStart;
}
interface SetupDeps {
uiActions: UiActionsSetup;
developerExamples: DeveloperExamplesSetup;
}
export class UiActionsExplorerPlugin implements Plugin<void, void, {}, StartDeps> {
public setup(core: CoreSetup<StartDeps>, deps: SetupDeps) {
deps.uiActions.registerTrigger({
id: COUNTRY_TRIGGER,
});
deps.uiActions.registerTrigger({
id: PHONE_TRIGGER,
});
deps.uiActions.registerTrigger({
id: USER_TRIGGER,
});
const startServices = core.getStartServices();
deps.uiActions.addTriggerAction(
USER_TRIGGER,
createTriggerPhoneTriggerAction(async () => (await startServices)[1].uiActions)
);
deps.uiActions.addTriggerAction(
USER_TRIGGER,
createEditUserAction(async () => (await startServices)[0])
);
deps.uiActions.addTriggerAction(COUNTRY_TRIGGER, viewInMapsAction);
deps.uiActions.addTriggerAction(COUNTRY_TRIGGER, lookUpWeatherAction);
deps.uiActions.addTriggerAction(COUNTRY_TRIGGER, showcasePluggability);
deps.uiActions.addTriggerAction(PHONE_TRIGGER, makePhoneCallAction);
deps.uiActions.addTriggerAction(PHONE_TRIGGER, showcasePluggability);
deps.uiActions.addTriggerAction(USER_TRIGGER, showcasePluggability);
core.application.register({
id: 'uiActionsExplorer',
title: 'Ui Actions Explorer',
visibleIn: [],
async mount(params: AppMountParameters) {
const [coreStart, depsStart] = await core.getStartServices();
const { renderApp } = await import('./app');
return renderApp({ uiActionsStartService: depsStart.uiActions, core: coreStart }, params);
},
});
deps.developerExamples.register({
appId: 'uiActionsExplorer',
title: 'Actions & Triggers',
description: `Learn how to extent Kibana's UI event system with actions and triggers. In the screen shot, plugins extend dashboard panels by attaching new actions to PANEL_BADGE_TRIGGER and CONTEXT_MENU_TRIGGER triggers.`,
image,
links: [
{
label: 'README',
href: 'https://github.com/elastic/kibana/blob/main/src/plugins/ui_actions/README.asciidoc',
iconType: 'logoGithub',
size: 's',
target: '_blank',
},
],
});
}
public start() {}
public stop() {}
}