Skip to content

Commit

Permalink
[Drilldowns] URL drilldown MVP (#75450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant authored Sep 4, 2020
1 parent 70b4b89 commit e7d80e7
Show file tree
Hide file tree
Showing 43 changed files with 1,836 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export const selectRangeTrigger: Trigger<'SELECT_RANGE_TRIGGER'> = {
defaultMessage: 'Range selection',
}),
description: i18n.translate('uiActions.triggers.selectRangeDescription', {
defaultMessage: 'Select a group of values',
defaultMessage: 'A range of values on the visualization',
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export const valueClickTrigger: Trigger<'VALUE_CLICK_TRIGGER'> = {
defaultMessage: 'Single click',
}),
description: i18n.translate('uiActions.triggers.valueClickDescription', {
defaultMessage: 'A single point clicked on a visualization',
defaultMessage: 'A single point on the visualization',
}),
};

This file was deleted.

2 changes: 0 additions & 2 deletions x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
AdvancedUiActionsStart,
} from '../../../../x-pack/plugins/ui_actions_enhanced/public';
import { DashboardHelloWorldDrilldown } from './dashboard_hello_world_drilldown';
import { DashboardToUrlDrilldown } from './dashboard_to_url_drilldown';
import { DashboardToDiscoverDrilldown } from './dashboard_to_discover_drilldown';
import { createStartServicesGetter } from '../../../../src/plugins/kibana_utils/public';
import { DiscoverSetup, DiscoverStart } from '../../../../src/plugins/discover/public';
Expand Down Expand Up @@ -39,7 +38,6 @@ export class UiActionsEnhancedExamplesPlugin

uiActions.registerDrilldown(new DashboardHelloWorldDrilldown());
uiActions.registerDrilldown(new DashboardHelloWorldOnlyRangeSelectDrilldown());
uiActions.registerDrilldown(new DashboardToUrlDrilldown());
uiActions.registerDrilldown(new DashboardToDiscoverDrilldown({ start }));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class FlyoutCreateDrilldownAction implements ActionByType<typeof OPEN_FLY
viewMode={'create'}
dynamicActionManager={embeddable.enhancements.dynamicActions}
supportedTriggers={ensureNestedTriggers(embeddable.supportedTriggers())}
placeContext={{ embeddable }}
/>
),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class FlyoutEditDrilldownAction implements ActionByType<typeof OPEN_FLYOU
viewMode={'manage'}
dynamicActionManager={embeddable.enhancements.dynamicActions}
supportedTriggers={ensureNestedTriggers(embeddable.supportedTriggers())}
placeContext={{ embeddable }}
/>
),
{
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/embeddable_enhanced/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["embeddable", "uiActionsEnhanced"]
"requiredPlugins": ["embeddable", "kibanaReact", "uiActions", "uiActionsEnhanced"],
"requiredBundles": ["kibanaUtils"]
}
7 changes: 7 additions & 0 deletions x-pack/plugins/embeddable_enhanced/public/drilldowns/index.ts
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 './url_drilldown';
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Basic url drilldown implementation

Url drilldown allows navigating to external URL or to internal kibana URL.
By using variables in url template result url can be dynamic and depend on user's interaction.

URL drilldown has 3 sources for variables:

- Global static variables like, for example, `kibanaUrl`. Such variables won’t change depending on a place where url drilldown is used.
- Context variables are dynamic and different depending on where drilldown is created and used.
- Event variables depend on a trigger context. These variables are dynamically extracted from the action context when drilldown is executed.

Difference between `event` and `context` variables, is that real `context` variables are available during drilldown creation (e.g. embeddable panel),
but `event` variables mapped from trigger context. Since there is no trigger context during drilldown creation, we have to provide some _mock_ variables for validating and previewing the URL.

In current implementation url drilldown has to be used inside the embeddable and with `ValueClickTrigger` or `RangeSelectTrigger`.

- `context` variables extracted from `embeddable`
- `event` variables extracted from `trigger` context

In future this basic url drilldown implementation would allow injecting more variables into `context` (e.g. `dashboard` app specific variables) and would allow providing support for new trigger types from outside.
This extensibility improvements are tracked here: https://github.com/elastic/kibana/issues/55324

In case a solution app has a use case for url drilldown that has to be different from current basic implementation and
just extending variables list is not enough, then recommendation is to create own custom url drilldown and reuse building blocks from `ui_actions_enhanced`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 { i18n } from '@kbn/i18n';

export const txtUrlDrilldownDisplayName = i18n.translate(
'xpack.embeddableEnhanced.drilldowns.urlDrilldownDisplayName',
{
defaultMessage: 'Go to URL',
}
);
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 { UrlDrilldown } from './url_drilldown';
Loading

0 comments on commit e7d80e7

Please sign in to comment.