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

[FieldFormatters] Add support for {{rawValue}} in URL label template #188973

Closed
jughosta opened this issue Jul 23, 2024 · 3 comments · Fixed by #204192
Closed

[FieldFormatters] Add support for {{rawValue}} in URL label template #188973

jughosta opened this issue Jul 23, 2024 · 3 comments · Fixed by #204192
Assignees
Labels
:DataDiscovery/fix-it-week enhancement New value added to drive a business result Feature:FieldFormatters impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. papercut Small "burr" in the product that we should fix. Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.

Comments

@jughosta
Copy link
Contributor

When defining a URL template, it's possible to use {{rawValue}} for unescaped value. But if {{rawValue}} is entered into Label template input, it results in missing label for the link.

Current workaround is to use {{value}} variable for the link label:
Screenshot 2024-07-23 at 17 01 02

But it's confusing that {{rawValue}} variable is not available for the label template and {{value}} works as {{rawValue}}.

private formatLabel(value: string, url?: string): string {
const template = this.param('labelTemplate');
if (url == null) url = this.formatUrl(value);
if (!template) return url;
return this.compileTemplate(template)({
value,
url,
});
}
private formatUrl(value: string): string {
const template = this.param('urlTemplate');
if (!template) return value;
return this.compileTemplate(template)({
value: encodeURIComponent(value),
rawValue: value,
});
}

@jughosta jughosta added enhancement New value added to drive a business result Feature:FieldFormatters Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. labels Jul 23, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@kertal kertal added the impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. label Jul 23, 2024
@davismcphee davismcphee added the papercut Small "burr" in the product that we should fix. label Nov 14, 2024
@kowalczyk-krzysztof kowalczyk-krzysztof self-assigned this Dec 11, 2024
@kowalczyk-krzysztof
Copy link
Member

@jughosta What's the desired behavior here? From what I understand, {{value}} for label works the same as {{rawValue}} for url.

Should the current behavior be kept and an alias get added so label has both {{value}} and {{rawValue}} doing the same thing? Or should {{value}} behavior get changed (to match url perhaps?) and {{rawValue}} would replace it?

@jughosta
Copy link
Contributor Author

Hi @kowalczyk-krzysztof,

Thanks for looking into it!

I think we can't simply change the existing behaviour for {{value}} as it would break the already configured links.

Adding support for {{rawValue}} too to use the unescaped value for the label would be great so users at least don't get surprised (as currently entering {{rawValue}} would result in no label at all).

kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Dec 13, 2024
## Summary

This PR adds support for ``{{rawValue}}`` in url label.

Closes: elastic#188973
(cherry picked from commit f0d3a44)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Dec 13, 2024
## Summary

This PR adds support for ``{{rawValue}}`` in url label.

Closes: elastic#188973
(cherry picked from commit f0d3a44)
kibanamachine added a commit that referenced this issue Dec 13, 2024
… (#204271)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[FieldFormatters] Add support for rawValue in url label
(#204192)](#204192)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Krzysztof
Kowalczyk","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-13T17:39:05Z","message":"[FieldFormatters]
Add support for rawValue in url label (#204192)\n\n##
Summary\r\n\r\nThis PR adds support for ```` in url
label.\r\n\r\nCloses:
#188973","sha":"f0d3a448eafab076b474a4aef1281be07ed680db","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Feature:FieldFormatters","v9.0.0","Team:DataDiscovery","backport:prev-minor"],"title":"[FieldFormatters]
Add support for rawValue in url
label","number":204192,"url":"https://github.com/elastic/kibana/pull/204192","mergeCommit":{"message":"[FieldFormatters]
Add support for rawValue in url label (#204192)\n\n##
Summary\r\n\r\nThis PR adds support for ```` in url
label.\r\n\r\nCloses:
#188973","sha":"f0d3a448eafab076b474a4aef1281be07ed680db"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204192","number":204192,"mergeCommit":{"message":"[FieldFormatters]
Add support for rawValue in url label (#204192)\n\n##
Summary\r\n\r\nThis PR adds support for ```` in url
label.\r\n\r\nCloses:
#188973","sha":"f0d3a448eafab076b474a4aef1281be07ed680db"}}]}]
BACKPORT-->

Co-authored-by: Krzysztof Kowalczyk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:DataDiscovery/fix-it-week enhancement New value added to drive a business result Feature:FieldFormatters impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. papercut Small "burr" in the product that we should fix. Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants