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

Drilldowns in examples #75640

Merged
merged 75 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ae8da5a
feat: 🎸 add telemetry for in-chart "Explore underlying data"
streamich Aug 6, 2020
23f7154
feat: 🎸 add telemetry for in-chart "Explore underlying data"
streamich Aug 6, 2020
8e81488
Merge remote-tracking branch 'origin/master'
streamich Aug 18, 2020
838425a
refactor: 💡 move all drilldowns into a sub-folder
streamich Aug 18, 2020
8291550
feat: 🎸 setup example app section for ui_actions_enhanced
streamich Aug 18, 2020
bea92df
feat: 🎸 set up Drilldown Manager section
streamich Aug 18, 2020
c3933c0
feat: 🎸 open drilldown manager from example plugin
streamich Aug 18, 2020
d1dd1a2
refactor: 💡 rename supportedTriggers -> triggers prop
streamich Aug 18, 2020
1e81346
feat: 🎸 show dev warning if triggers prop is empty
streamich Aug 18, 2020
d80cce4
refactor: 💡 rename "supportedTriggers" -> "triggers" props
streamich Aug 18, 2020
7933266
feat: 🎸 open and close drilldown manager from example plugin
streamich Aug 18, 2020
ca46f4c
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Aug 19, 2020
a80b461
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Aug 19, 2020
705008d
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Aug 20, 2020
0a0438c
feat: 🎸 add sample ML job trigger
streamich Aug 20, 2020
49153c5
feat: 🎸 add sample ML URL drilldown
streamich Aug 20, 2020
2c9ddae
refactor: 💡 move KibanaURL to share plugin
streamich Aug 20, 2020
2ce9d09
refactor: 💡 add index file to ml drilldown
streamich Aug 20, 2020
664cec2
feat: 🎸 add AbstractDashboardDrilldown
streamich Aug 20, 2020
3da8c9b
refactor: 💡 make dashboard drilldown use abstract drilldown
streamich Aug 20, 2020
2505558
refactor: 💡 rename dashboard drilldown to embeddable drilldown
streamich Aug 20, 2020
0e0b469
feat: 🎸 add Dashboard drilldown to sample plugin
streamich Aug 20, 2020
f54260b
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Aug 21, 2020
a64e714
feat: 🎸 open dashboard drilldown in list view
streamich Aug 21, 2020
2d03893
feat: 🎸 add drilldown execute button
streamich Aug 21, 2020
abf6700
refactor: 💡 move drilldown React hooks into /hooks folder
streamich Aug 21, 2020
ee9c77a
test: 💍 fix tests after renaming triggers
streamich Aug 21, 2020
3399275
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Aug 21, 2020
0c6ebb4
chore: 🤖 populate "requireBundles"
streamich Aug 21, 2020
334e26e
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Aug 27, 2020
e1f9095
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 10, 2020
a935a2f
chore: 🤖 catch up with master
streamich Sep 16, 2020
70960f0
fix: 🐛 fix TypeScript errors
streamich Sep 16, 2020
8cc1723
fix: 🐛 fix Kibana plugin dependency
streamich Sep 16, 2020
cf02239
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 18, 2020
5b9dfa2
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 22, 2020
8569cbf
chore: 🤖 remoe unused import
streamich Sep 22, 2020
9a40779
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 23, 2020
bfa7306
feat: 🎸 persist drilldown manager state across app navigations
streamich Sep 23, 2020
f870258
refactor: 💡 move no-embeddable example into a seprate file
streamich Sep 23, 2020
af3664f
feat: 🎸 set up example with embeddable
streamich Sep 23, 2020
a718494
feat: 🎸 improve embeddable example
streamich Sep 23, 2020
fabcab6
refactor: 💡 rename without embeddable example
streamich Sep 23, 2020
07cb5dc
feat: 🎸 set up no-embeddable single click example
streamich Sep 23, 2020
9175ab9
feat: 🎸 add dashboard drilldown to single button example
streamich Sep 23, 2020
f19591f
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 23, 2020
f5c550b
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 24, 2020
05e0929
chore: 🤖 catch up with master
streamich Sep 28, 2020
e86a36a
fix: 🐛 remove unused margin
streamich Sep 28, 2020
5f0246f
fix: 🐛 make "Get more actions" translation static
streamich Sep 28, 2020
d8958b5
chore: 🤖 remove old dashboard drilldown definition
streamich Sep 28, 2020
595990c
refactor: 💡 rename samples to generic names
streamich Sep 28, 2020
1c5be9f
refactor: 💡 make app 1 example drilldown "hello world"
streamich Sep 28, 2020
1b8492c
chore: 🤖 remove unused required bundle
streamich Sep 28, 2020
ab5cc96
chore: 🤖 add dashboardEnhanced back
streamich Sep 28, 2020
cdf48c7
[kbn/optimizer] only build xpack examples when building xpack plugins
spalger Sep 28, 2020
d6b6f74
move alerting_example into x-pack/examples
spalger Sep 28, 2020
ead9885
remove filter for alertingExample plugin in oss plugins CI step
spalger Sep 28, 2020
ce654ee
revert unrelated change
spalger Sep 28, 2020
dd2ce1d
Merge remote-tracking branch 'spalger/fix/optimizer/no-xpack-examples…
streamich Sep 28, 2020
08dd6db
Merge branch 'master' into drilldowns-in-examples
elasticmachine Sep 29, 2020
7f4b8bc
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 29, 2020
be41664
fix: 🐛 use correct prop name
streamich Sep 29, 2020
d848d29
test: 💍 fix embeddable-to-dashboard drilldown mock
streamich Sep 29, 2020
83701c0
test: 💍 fix a test after refactor
streamich Sep 29, 2020
092496b
chore: 🤖 catch up with master
streamich Sep 29, 2020
d04d7fc
chore: 🤖 remove unused import
streamich Sep 29, 2020
9497d25
chore: 🤖 catch up with master
streamich Sep 30, 2020
8140373
chore: 🤖 add dashboard_enahcned to example plugin
streamich Sep 30, 2020
a2751ef
Merge remote-tracking branch 'upstream/master' into drilldowns-in-exa…
streamich Sep 30, 2020
0343d0e
chore: 🤖 address review comments
streamich Sep 30, 2020
3de04fe
feat: 🎸 add description to UI Actions Enhanced examples
streamich Sep 30, 2020
ee6769d
docs: ✏️ improve docs of example plugin
streamich Sep 30, 2020
0c5ac3b
chore: 🤖 catch up with master
streamich Oct 1, 2020
3eb5e27
Merge branch 'master' into drilldowns-in-examples
kibanamachine Oct 5, 2020
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
7 changes: 6 additions & 1 deletion src/plugins/dashboard/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export {
} from './application';
export { DashboardConstants, createDashboardEditUrl } from './dashboard_constants';

export { DashboardStart, DashboardUrlGenerator, DashboardFeatureFlagConfig } from './plugin';
export {
DashboardSetup,
DashboardStart,
DashboardUrlGenerator,
DashboardFeatureFlagConfig,
} from './plugin';
export {
DASHBOARD_APP_URL_GENERATOR,
createDashboardUrlGenerator,
Expand Down
17 changes: 4 additions & 13 deletions src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ interface StartDependencies {
savedObjects: SavedObjectsStart;
}

export type Setup = void;
export type DashboardSetup = void;

export interface DashboardStart {
getSavedDashboardLoader: () => SavedObjectLoader;
Expand Down Expand Up @@ -180,7 +180,7 @@ declare module '../../../plugins/ui_actions/public' {
}

export class DashboardPlugin
implements Plugin<Setup, DashboardStart, SetupDependencies, StartDependencies> {
implements Plugin<DashboardSetup, DashboardStart, SetupDependencies, StartDependencies> {
constructor(private initializerContext: PluginInitializerContext) {}

private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
Expand All @@ -193,17 +193,8 @@ export class DashboardPlugin

public setup(
core: CoreSetup<StartDependencies, DashboardStart>,
{
share,
uiActions,
embeddable,
home,
kibanaLegacy,
urlForwarding,
data,
usageCollection,
}: SetupDependencies
): Setup {
{ share, uiActions, embeddable, home, urlForwarding, data, usageCollection }: SetupDependencies
): DashboardSetup {
this.dashboardFeatureFlagConfig = this.initializerContext.config.get<
DashboardFeatureFlagConfig
>();
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/share/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ export {

import { SharePlugin } from './plugin';

export { KibanaURL } from './kibana_url';

export const plugin = () => new SharePlugin();
44 changes: 44 additions & 0 deletions src/plugins/share/public/kibana_url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.
*/

// TODO: Replace this logic with KibanaURL once it is available.
// https://github.com/elastic/kibana/issues/64497
export class KibanaURL {
public readonly path: string;
public readonly appName: string;
public readonly appPath: string;

constructor(path: string) {
const match = path.match(/^.*\/app\/([^\/#]+)(.+)$/);

if (!match) {
throw new Error('Unexpected URL path.');
}

const [, appName, appPath] = match;

if (!appName || !appPath) {
throw new Error('Could not parse URL path.');
}

this.path = path;
this.appName = appName;
this.appPath = appPath;
}
}
74 changes: 73 additions & 1 deletion x-pack/examples/ui_actions_enhanced_examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ 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.
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.
Expand Down Expand Up @@ -34,3 +35,74 @@ One can see how middle-click or Ctrl + click behavior could be supported using
### `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](https://user-images.githubusercontent.com/9773803/94044547-969a3400-fdce-11ea-826a-cbd0773a4000.png)

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:

```ts
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:

```ts
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:

```ts
export class MyPlugin implements Plugin {
public setup(core, { uiActionsEnhanced: uiActions }: SetupDependencies) {
const drilldown = new App2ToDashboardDrilldown(/* You can pass in dependencies here. */);
uiActions.registerDrilldown(drilldown);
}
}
```
15 changes: 13 additions & 2 deletions x-pack/examples/ui_actions_enhanced_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@
"configPath": ["ui_actions_enhanced_examples"],
"server": false,
"ui": true,
"requiredPlugins": ["uiActions","uiActionsEnhanced", "data", "discover"],
"requiredPlugins": [
"uiActions",
"uiActionsEnhanced",
"data",
"discover",
"dashboard",
"dashboardEnhanced",
"developerExamples"
],
"optionalPlugins": [],
"requiredBundles": [
"dashboardEnhanced",
streamich marked this conversation as resolved.
Show resolved Hide resolved
"embeddable",
"kibanaUtils",
"kibanaReact"
"kibanaReact",
"share"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as React from 'react';
import {
EuiPageBody,
EuiPageContent,
EuiPageContentBody,
EuiPageHeader,
EuiPageHeaderSection,
EuiTitle,
} from '@elastic/eui';

export interface PageProps {
title?: React.ReactNode;
}

export const Page: React.FC<PageProps> = ({ title = 'Untitled', children }) => {
return (
<EuiPageBody style={{ maxWidth: 1200, margin: '0 auto' }}>
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>{title}</h1>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageContent>
<EuiPageContentBody style={{ maxWidth: 800, margin: '0 auto' }}>
{children}
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export * from './section';
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { EuiTitle, EuiSpacer } from '@elastic/eui';

export interface Props {
title: React.ReactNode;
}

export const Section: React.FC<Props> = ({ title, children }) => {
return (
<section>
<EuiTitle size="m">
<h2>{title}</h2>
</EuiTitle>
<EuiSpacer />
{children}
</section>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { EuiPage } from '@elastic/eui';
import { Page } from '../../components/page';
import { DrilldownsManager } from '../drilldowns_manager';

export const App: React.FC = () => {
return (
<EuiPage>
<Page title={'UI Actions Enhanced'}>
<DrilldownsManager />
</Page>
</EuiPage>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export * from './app';
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiHorizontalRule } from '@elastic/eui';
import React from 'react';
import { Section } from '../../components/section/section';
import { SampleMlJob, SampleApp1ClickContext } from '../../triggers';
import { DrilldownsWithoutEmbeddableExample } from '../drilldowns_without_embeddable_example';
import { DrilldownsWithoutEmbeddableSingleButtonExample } from '../drilldowns_without_embeddable_single_button_example/drilldowns_without_embeddable_single_button_example';
import { DrilldownsWithEmbeddableExample } from '../drilldowns_with_embeddable_example';

export const job: SampleMlJob = {
job_id: '123',
job_type: 'anomaly_detector',
description: 'This is some ML job.',
};

export const context: SampleApp1ClickContext = { job };

export const DrilldownsManager: React.FC = () => {
return (
<div>
<Section title={'Drilldowns Manager'}>
<DrilldownsWithoutEmbeddableExample />

<EuiHorizontalRule margin="xxl" />

<DrilldownsWithoutEmbeddableSingleButtonExample />

<EuiHorizontalRule margin="xxl" />

<DrilldownsWithEmbeddableExample />
</Section>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export * from './drilldowns_manager';
Loading