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

[Drilldows] Url Drilldown basic template helpers #80500

Merged
merged 9 commits into from
Oct 19, 2020

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Oct 14, 2020

Summary

close #77758

New helpers

Provides a basic list of string manipulation helpers for URL Drilldown templating:

Helper Description
formatNumber A wrapper around elastic/numeral-js. Allows to format number, currencies, bytes and etc... {{formatNumber value "0.0"}}
lowercase transform a string to lowercase string
uppercase transform a string to uppercase string
trim
trimLeft
trimRight
left {{left "12345" 3}} -> "123"
right {{right "12345" 3}} -> "345"
mid {{mid "12345" 1 3}} -> "234"
concat concatenates list of values into a string: {{concat value1 ";" value2 }}
replace Can be used to replace a substring with another substring. Replaces all occurrences. {{replace "Label:Feature:Something" "Label:" ""}} -> "Feature:Something"
split Splits a string using a splitter character {{split "Label:Feature:Something" ":"}} -> ["Label", "Feature", "Something"]

Checklist

Delete any items that are not applicable to this PR.

  • Documentation was added for features that require explanation or tutorials - Will add use facing documentation when we agree with the list
  • Unit or functional tests were updated or added to match the most common scenarios

For maintainers

@Dosant Dosant added enhancement New value added to drive a business result Feature:Drilldowns Embeddable panel Drilldowns release_note:enhancement v7.11.0 Team:AppArch labels Oct 14, 2020
@Dosant Dosant changed the title Dev/drilldowns/url drilldown helpers [Drilldows] Url Drilldown basic template helpers Oct 14, 2020
@Dosant Dosant added the v8.0.0 label Oct 14, 2020
@Dosant Dosant marked this pull request as ready for review October 14, 2020 14:28
@Dosant Dosant requested a review from a team as a code owner October 14, 2020 14:28
@elasticmachine
Copy link
Contributor

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

@elastic-jb
Copy link

This is a great set to handle most simple string manipulations. I think we may want to still consider a way for a developer to register a custom helper if it's useful for them, but that is a separate goal.

@Dosant
Copy link
Contributor Author

Dosant commented Oct 14, 2020

a way for a developer to register a custom helper if it's useful for them, but that is a separate goal.

@elastic-jb 👍 this is tracked here: #78404

@elastic-jb
Copy link

I think we need the change for event.row (79157) to make use of the numeric formatting. I can't create a drilldown on a table that only has an aggregation, and if I add a terms aggregation to act on, I can't access the 2nd column value. That does bring up a point though. Even if I have a single column table with an aggregation, I would expect the context menu to display and allow me to send that single value. There is no way to do it right now.

@Dosant
Copy link
Contributor Author

Dosant commented Oct 15, 2020

@elastic-jb,

That does bring up a point though. Even if I have a single column table with an aggregation, I would expect the context menu to display and allow me to send that single value. There is no way to do it right now.

Correct,
That is because for Drilldowns triggers we reused what already existed for filters.
We didn't create a filter from an aggregated value from a table, so drill-downs inherited this limitation :(
I think this has to be improved in scope of #78289 which we planned for 7.11 work.

Regarding the current pr and helpers: this future table-vis work doesn't block helpers.

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.

LGTM.

@Dosant
Copy link
Contributor Author

Dosant commented Oct 16, 2020

I removed matched because using regex as part of an API was a bad idea in a first place. If anyone would really want to have something like this this would be possible with extensions: #78404

Instead of match I added replace which allows to replace or remove a substring.

@elastic-jb
Copy link

Anton, the example I was thinking of was something like if I have a field that has "47.766201,-122.257057" stored as a single string field, it would be useful if I could have something that's kind of a cross between split and event.row so I could express that I want to use the value before the comma as a parameter, and the value after the comma as a separate parameter to send them to an API that requires them separately.

Copy link

@elastic-jb elastic-jb left a comment

Choose a reason for hiding this comment

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

Dropping match and adding replace makes sense. I think we have a good core here.

@Dosant
Copy link
Contributor Author

Dosant commented Oct 19, 2020

@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented Oct 19, 2020

Anton, the example I was thinking of was something like if I have a field that has "47.766201,-122.257057" stored as a single string field, it would be useful if I could have something that's kind of a cross between split and event.row so I could express that I want to use the value before the comma as a parameter, and the value after the comma as a separate parameter to send them to an API that requires them separately.

@elastic-jb, I added split 👍

@Dosant
Copy link
Contributor Author

Dosant commented Oct 19, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

page load bundle size

id before after diff
uiActionsEnhanced 327.3KB 330.4KB +3.0KB

History

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Drilldowns Embeddable panel Drilldowns release_note:enhancement v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Drilldowns] URL Drilldown template helpers
5 participants