kibana/x-pack/examples/ui_actions_enhanced_examples
Tiago Costa 0eeaafa722
chore(NA): move into single pkg json (#80015)
* chore(NA): update gitignore to include first changes from moving into a single package.json

* chore(NA): update gitignore

* chore(NA): move all the dependencies into the single package.json and apply changes to bootstrap

* chore(NA): fix types problems after the single package json

* chore(NA): include code to find the dependencies used across the code

* chore(NA): introduce pure lockfile for install dependencies on build

* chore(NA): update clean task to not delete anything from xpack node_modules

* chore(NA): update gitignore to remove development temporary rules

* chore(NA): update notice file

* chore(NA): update jest snapshots

* chore(NA): fix whitelisted licenses to include a new specify form of an already included one

* chore(NA): remove check lockfile symlinks from child projects

* chore(NA): fix eslint and add missing declared deps on single pkg json

* chore(NA): correctly update notice

* chore(NA): fix failing jest test for storyshots.test.tsx

* chore(NA): fix cypress multi reporter path

* chore(NA): fix Project tests check

* chore(NA): fix problem with logic to detect used dependes on oss build

* chore(NA): include correct x-pack plugins dep discovery

* chore(NA): discover entries under dynamic requires on vis_type_timelion

* chore(NA): remove canvas

* test(NA): fix jest unit tests

* chore(NA): remove double react declaration from storyshot test file

* chore(NA): try removing isOSS check

* chore(NA): support for plugin development

* chore(NA): update logic to fix unit tests and typechecking

* chore(NA): support to run npm scripts in child kbn projects across all envs

* chore(NA): support github checks reporter on x-pack and remove cpy types as the package correctly provides them

* chore(NA): update cpy version

* chore(NA): include last kbn pm changes

* chore(NA): update style on build_production_projects.ts

* chore(NA): remove any cast fom telemetry opt in stats

* chore(NA): remove del and re-use rm -rf again

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-02 21:18:52 +00:00
..
public Upgrade EUI to v30.1.1 (#81499) 2020-10-30 16:18:27 -06:00
.eslintrc.json
kibana.json Drilldowns in examples (#75640) 2020-10-05 16:31:30 +02:00
package.json chore(NA): move into single pkg json (#80015) 2020-11-02 21:18:52 +00:00
README.md Drilldowns in examples (#75640) 2020-10-05 16:31:30 +02:00
tsconfig.json TS project references for share plugin (#82051) 2020-10-30 08:38:08 -05:00

Ui actions enhanced examples

To run this example plugin, use the command yarn start --run-examples.

Drilldown examples

This plugin holds few examples on how to add drilldown types to dashboard. See ./public/drilldowns/ folder.

To play with drilldowns, open any dashboard, click "Edit" to put it in edit mode. Now when opening context menu of dashboard panels you should see "Create drilldown" option.

image

Once you click "Create drilldown" you should be able to see drilldowns added by this sample plugin.

image

dashboard_hello_world_drilldown

dashboard_hello_world_drilldown is the most basic "hello world" example showing how a drilldown can be built, all in one file.

dashboard_to_url_drilldown

dashboard_to_url_drilldown is a good starting point for build a drilldown that navigates somewhere externally.

One can see how middle-click or Ctrl + click behavior could be supported using getHref field.

dashboard_to_discover_drilldown

dashboard_to_discover_drilldown shows how a real-world drilldown could look like.

Drilldown Manager examples

Drilldown Manager is a collectio of code and React components that allows you to add drilldowns to any app. To see examples of how drilldows can be added to your app, run Kibana with --run-examples flag:

yarn start --run-examples

Then go to "Developer examples" and "UI Actions Enhanced", where you can see examples where Drilldown Manager is used outside of the Dashboard app:

image

These examples show how you can create your custom UI Actions triggers and add drilldowns to them, or use an embeddable in your app and add drilldows to it.

Trigger examples

The /public/triggers folder shows how you can create custom triggers for your app. Triggers are things that trigger some action in UI, like "user click".

Once you have defined your triggers, you need to register them in your plugin:

export class MyPlugin implements Plugin {
  public setup(core, { uiActionsEnhanced: uiActions }: SetupDependencies) {
    uiActions.registerTrigger(myTrigger);
  }
}

app1_hello_world_drilldown

app1_hello_world_drilldown is a basic example that shows how you can add the most basic drilldown to your custom trigger.

appx_to_dashboard_drilldown

app1_to_dashboard_drilldown and app2_to_dashboard_drilldown show how the Dashboard drilldown can be used in other apps, outside of Dashboard.

Basically you define it:

type Trigger = typeof MY_TRIGGER_TRIGGER;
type Context = MyAppClickContext;

export class App1ToDashboardDrilldown extends AbstractDashboardDrilldown<Trigger> {
  public readonly supportedTriggers = () => [MY_TRIGGER] as Trigger[];

  protected async getURL(config: Config, context: Context): Promise<KibanaURL> {
    return 'https://...';
  }
}

and then you register it in your plugin:

export class MyPlugin implements Plugin {
  public setup(core, { uiActionsEnhanced: uiActions }: SetupDependencies) {
    const drilldown = new App2ToDashboardDrilldown(/* You can pass in dependencies here. */);
    uiActions.registerDrilldown(drilldown);
  }
}