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

[Lens] Make open in discover drilldown work #131237

Merged
merged 17 commits into from
May 9, 2022

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Apr 29, 2022

Fixes #122631
Fixes #60227

Adds a drilldown "open in discover" to Lens panels - only config option is whether or not discover is opened in a new tab.
Screenshot 2022-05-02 at 12 23 44
Screenshot 2022-05-02 at 12 23 55
Screenshot 2022-05-02 at 12 24 05

The drilldown becomes active for the filter trigger and basically does the same thing as the panel action "Open in Discover", but it takes the context of the filter click into account as well

Tech details

As it's sharing almost all logic with the existing action, I moved these parts into open_in_discover helpers, which are called from the drilldown as well as the action definition, with the following additions:

  • "Open in new tab" can be configured
  • filters and timerange are passed in and spread into the locator call along with the filters and timerange from getViewUnderlyingData

To be able to only show the drilldown in the form flyout for Lens embeddables, I added an isConfigurable callback to both the drilldown and actionfactory interfaces and call it before rendering the keypad menu to only show it in case the current embeddable is a Lens embeddable.

Open question

Which icon to use? The screenshots are outdated, I went with discoverApp but I'm not sure - it would be nice to stay consistent with the panel action but the icon only makes sense for "open in new tab"

@flash1293 flash1293 added release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens backport:skip This commit does not require backporting v8.3.0 and removed skip-ci labels May 2, 2022
@flash1293 flash1293 marked this pull request as ready for review May 2, 2022 14:08
@flash1293 flash1293 requested a review from a team as a code owner May 2, 2022 14:08
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

@stratoula
Copy link
Contributor

@elasticmachine merge upstream

@stratoula
Copy link
Contributor

@flash1293 I create a drilldown with the open in new tab switch off
image

but when I use it , it opens Discover in a new tab. Am I missing something?

@flash1293
Copy link
Contributor Author

@stratoula Good catch, something I missed during refactoring. SHould be fixed now.

@stratoula
Copy link
Contributor

@flash1293 it is fixed thanx! Another question. I can see the new drilldown on aggregation based visualizations.
image

I can configure it, but it doesn't work (which makes sense). Can we enable this only for Lens panels?

@flash1293
Copy link
Contributor Author

That's a good point @stratoula. @ghudgins what do think about this? Would it be OK if the drilldown is showing up even if the panel won't be able to handle it?

@flash1293 flash1293 requested a review from a team as a code owner May 3, 2022 10:37
@flash1293
Copy link
Contributor Author

So, I looked into how this drilldown (which will only work in the Lens context) can be ignored otherwise and it's not that hard to add a callback for it. @vadimkibana what do you think about this extension? I'm sure it will be useful for other things as well.

Copy link
Contributor

@drewdaemon drewdaemon left a comment

Choose a reason for hiding this comment

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

Nice work! Left a couple of questions. Code review only.

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

This works great Joe! I find it super useful to be able to add drilldowns specific per embeddable type so my +1 on this approach!

@vadimkibana vadimkibana mentioned this pull request May 5, 2022
6 tasks
@vadimkibana
Copy link
Contributor

Shall we use Discover icon?

image

@vadimkibana
Copy link
Contributor

I guess it closes this issue: #60227

@flash1293
Copy link
Contributor Author

@vadimkibana I changed it to the discover icon in the code already, the screenshots are outdated.

@@ -14,14 +14,17 @@ export const ActionFactoryPicker: React.FC = ({}) => {
const drilldowns = useDrilldownManager();
const factory = drilldowns.useActionFactory();
const context = React.useMemo(() => drilldowns.getActionFactoryContext(), [drilldowns]);
const applicableFactories = drilldowns.deps.actionFactories.filter((actionFactory) =>
actionFactory.isConfigurable(context)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be

Suggested change
actionFactory.isConfigurable(context)
actionFactory.isCompatible(context)

and we would not need the new isConfigurable property? Or am I missing something. What is the difference between isCompatible and isConfigurable for the action factory?

Copy link
Contributor

Choose a reason for hiding this comment

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

@vadimkibana what do you think about this extension? I'm sure it will be useful for other things as well.

I'm trying to understand how isConfigurable is different from the existing isCompatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure about the semantics of isCompatible in this place, but it seems like it's coming from here

* Returns a promise that resolves to true if this item is compatible given

  • in this case it's a pretty good fit. Will adjust

@flash1293
Copy link
Contributor Author

@vadimkibana Found a solution I'm happy with - most of the logic is in the state manager now. Could you check out the PR again?

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 765 767 +2

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
uiActionsEnhanced 141 142 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
uiActionsEnhanced 126.7KB 127.1KB +472.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 30.3KB 32.5KB +2.1KB
uiActionsEnhanced 22.3KB 22.3KB +23.0B
total +2.2KB
Unknown metric groups

API count

id before after diff
uiActionsEnhanced 203 205 +2

ESLint disabled line counts

id before after diff
lens 29 30 +1

References to deprecated APIs

id before after diff
lens 14 20 +6

Total ESLint disabled count

id before after diff
lens 31 32 +1

History

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

@flash1293 flash1293 merged commit a8017df into elastic:main May 9, 2022
kertal pushed a commit to kertal/kibana that referenced this pull request May 24, 2022
* make open in discover drilldown work

* cleanup and tests

* fix test

* fix icon

* fix type

* fix open in new tab

* fix open in new tab

* fix test

* make it possible to filter out drilldowns from list based on context

* review comments

* remove isConfigurable from the actionfactory

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] "Show underlying data" drilldown action Dashboard-to-Discover drilldown
7 participants