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] Trigger picker #74751

Merged
merged 15 commits into from
Aug 17, 2020
Merged

[Drilldowns] Trigger picker #74751

merged 15 commits into from
Aug 17, 2020

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Aug 11, 2020

Summary

Closes: #59569
Latest designs: #59569 (comment)
Part of: #42845
Needed for URL drilldown

Feature description

Please note, until we introduce new drilldowns (URL drilldown), user won't see any of those changes.

To play with it using example drilldowns start kibana with --run-examples flag

From dev perspective

When defining a drilldown now developer also has to specify list of triggers the drilldown supports.
Drilldown's execution context should match trigger's context, otherwise typescript will fail.

Example of hello world drilldown which works only for SELECT_RANGE_TRIGGER:

export class DashboardHelloWorldOnlyRangeSelectDrilldown
  implements Drilldown<Config, typeof SELECT_RANGE_TRIGGER, RangeSelectContext>{
 
  supportedTriggers(): Array<typeof SELECT_RANGE_TRIGGER> {
    return [SELECT_RANGE_TRIGGER];
  }

  public readonly execute = async (config: Config, context: RangeSelectContext) => {
    alert(`Hello, ${config.name}, your selected range: ${JSON.stringify(context.data.range)}`);
  };
}

SELECT_RANGE_TRIGGER is required to be repeated in 2 different places:

  1. In interfaces definition as a generic. This needed for proper typescript type checks.
  2. As a returned value in supportedTriggers. This will actually be used in runtime.

From user perspective

Triggers listed on a drilldown and triggers supported by embeddable type now properly work with each other:

Consider following scenarios:

Registed drilldowns Supported triggers on current embeddable drilldowns available? list of drilldown type to pick from Available triggers Is trigger picker shown?
None VALUE_CLICK false - - -
Drilldown (A) with only VALUE_CLICK support RANGE_SELECT false - - -
Drilldown (A) with only VALUE_CLICK support VALUE_CLICK true [A] VALUE_CLICK false (trigger auto picked)
Drilldown (A) with only VALUE_CLICK support, Drilldown (B) with only RANGE_SELECT support, Drilldown (C) with both VALUE_CLICK and RANGE_SELECT support VALUE_CLICK true [A, C] VALUE_CLICK false (trigger auto picked)
Drilldown (A) with only VALUE_CLICK support VALUE_CLICK, RANGE_SELECT true [A] VALUE_CLICK false (trigger auto picked)
Drilldown (A) with both VALUE_CLICK and RANGE_SELECT support VALUE_CLICK, RANGE_SELECT true [A] VALUE_CLICK, RANGE_SELECT true

With trigger picker:

Screenshot 2020-08-11 at 13 13 01

No trigger picker (trigger auto picked because only 1 was available):

Screenshot 2020-08-11 at 13 13 11

Please note: Dashboard-to-dashboard drilldown user experience didn't change

Screenshot 2020-08-11 at 13 13 20

Even-though dashboard to dashboard drilldown can be trigged both by bursting over chart or clicking on a point in a chart, user doesn't have to specify what interaction wants to attach a dashboard drilldown to.
This is because dashboard drilldown uses different high-level trigger (APPLY_FILTER_TRIGGER)

TODO:

  • More unit tests (I'll pick this up after first rounds of review)
  • i18n everywhere
  • Discuss tooltip and help link about triggers

@Dosant Dosant added Feature:Drilldowns Embeddable panel Drilldowns Team:AppArch v7.10.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes labels Aug 11, 2020
@Dosant Dosant marked this pull request as ready for review August 11, 2020 15:47
@Dosant Dosant requested a review from a team August 11, 2020 15:47
@Dosant Dosant requested a review from a team as a code owner August 11, 2020 15:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did a quick look over the code, LGTM

Copy link
Contributor

@streamich streamich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on Chrome, LGTM. I would try to use string[] type instead of SupportedTriggers to simplify types. Also see next comment about popup title.

"Apply filter" popup title now appears (popup should be without title):

image

When creating a "Say hello only for range select" drilldown for the first time saw the message below, not sure if that is expected.

image

Then created that type of drilldown two times and both succeeded.

Maybe in the future when a drilldown supports multiple triggers we could show the trigger picker:

image

@Dosant
Copy link
Contributor Author

Dosant commented Aug 13, 2020

@streamich, regarding error probably you this wasn't a clean es run? so some older Drilldowns data was there?
I didn't bother with migrations for example drilldown types. but this shouldn't happen without --run-example

…icker

# Conflicts:
#	src/plugins/ui_actions/public/service/ui_actions_execution_service.ts
#	x-pack/examples/ui_actions_enhanced_examples/public/dashboard_to_url_drilldown/index.tsx
#	x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts
Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on chrome. Changing triggers works correctly, and actions with only one trigger don't show the trigger picker as expected.

One small thing I noticed, is some inconsistencies in the mapping between supported triggers on embeddables, and the supported triggers on actions. For instance:

  • A vislib bar chart where the x-axis uses a terms aggregation. In this case, the embeddable doesn't allow brushing, but still allows the 'range select' drilldowns to be added. When you add a drilldown in this state, it is impossible to trigger it.

I see that the embeddable is configured to support the brushing action, due to the date histogram functionality. I am wondering if it's even possible to get this level of granularity, where an embeddable's triggers change based on its configuration.

Overall, this issue shouldn't get in the way of merging this PR! LGTM

@Dosant
Copy link
Contributor Author

Dosant commented Aug 17, 2020

@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented Aug 17, 2020

@ThomThomson, good catch. Now supported triggers are static depending on a vis type: https://github.com/elastic/kibana/blob/master/src/plugins/vis_type_vislib/public/histogram.ts#L55
Not sure how much effort it would be to make it dynamic depending on actual configuration. I though it worth creating an issue for: #75141

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
dashboardEnhanced 29 +1 28
uiActionsEnhanced 129 +67 62
total +68

page load bundle size

id value diff baseline
dashboardEnhanced 185.6KB +2.7KB 183.0KB
uiActions 214.9KB +1.3KB 213.6KB
uiActionsEnhanced 160.3KB +28.7KB 131.6KB
total +32.6KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@Dosant Dosant merged commit 3c5f2e7 into elastic:master Aug 17, 2020
Dosant added a commit to Dosant/kibana that referenced this pull request Aug 18, 2020
Drilldowns now support trigger picker. It allows to create a drilldown and specify which trigger it should be attached to.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Dosant added a commit that referenced this pull request Aug 19, 2020
Drilldowns now support trigger picker. It allows to create a drilldown and specify which trigger it should be attached to.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Drilldowns Embeddable panel Drilldowns release_note:skip Skip the PR/issue when compiling release notes v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trigger selection
6 participants