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

DataLinks: Fixes datalinks with onClick and variables in url not being interpolated #86253

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

gng0
Copy link

@gng0 gng0 commented Apr 16, 2024

Added the replaceVariables method to be used on the link url when an onClick handler is provided.
Fixed a unit test and added another test for this fix. More details in the issue

Fixes #86242

@gng0 gng0 requested review from a team as code owners April 16, 2024 00:08
@gng0 gng0 requested review from tskarhed, JoaoSilvaGrafana and leventebalogh and removed request for a team April 16, 2024 00:08
@CLAassistant
Copy link

CLAassistant commented Apr 16, 2024

CLA assistant check
All committers have signed the CLA.

@grafana-pr-automation grafana-pr-automation bot added area/frontend pr/external This PR is from external contributor labels Apr 16, 2024
@gng0 gng0 changed the title grafana-data package: Replace data link variables in url with onClick handler grafana-data package: Fix data link variables not being replaced in url with onClick handler Apr 16, 2024
@gng0 gng0 changed the title grafana-data package: Fix data link variables not being replaced in url with onClick handler Grafana-data package: Fix data link variables not being replaced in url with onClick handler Apr 16, 2024
@torkelo torkelo added this to the 11.1.x milestone Apr 23, 2024
@torkelo
Copy link
Member

torkelo commented Apr 23, 2024

Thanks for contributing and fixing this!

@torkelo torkelo changed the title Grafana-data package: Fix data link variables not being replaced in url with onClick handler DataLinks: Fixes datalinks with onClick and variables in url not being interpolated Apr 23, 2024
@torkelo torkelo modified the milestone: 11.1.x Apr 25, 2024
Copy link
Member

@axelavargas axelavargas left a comment

Choose a reason for hiding this comment

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

@gng0 thank you for contributing to Grafana 🙌🏾 . I see some failures in our CI, can you update your branch with the latest main?

🙏🏾

@gng0
Copy link
Author

gng0 commented May 2, 2024

Done! @axelavargas

@gng0
Copy link
Author

gng0 commented May 12, 2024

Hi @torkelo, just wanted to follow up on the continuous-integration/drone/pr build which is pending. The details links me to a page mentioning - "Build is blocked, please, contact repo admin in order to proceed"

Copy link
Member

@axelavargas axelavargas left a comment

Choose a reason for hiding this comment

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

Hey @gng0, I checked the code and noticed some missing href processing in the approach :), I left a comment.

I will be keeping an eye on this PR, as soon as the change is implemented, I will approve :)

@@ -470,7 +470,7 @@ export const getLinksSupplier =

if (link.onClick) {
linkModel = {
href: link.url,
href: replaceVariables(link.url, dataLinkScopedVars, VariableFormatID.UriEncode),
Copy link
Member

Choose a reason for hiding this comment

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

Hey @gng0 👋🏾, thanks for contributing to this change 🙌🏾 . Can you refactor this part to contain the same href processing we do in the else condition?

.....
  if (href) {
    href = locationUtil.assureBaseUrl(href.replace(/\n/g, ''));
    href = replaceVariables(href, dataLinkScopedVars, VariableFormatID.UriEncode);
    href = locationUtil.processUrl(href);

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for catching that @axelavargas
I've just made the change!

Copy link
Member

@axelavargas axelavargas left a comment

Choose a reason for hiding this comment

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

🥳

@axelavargas
Copy link
Member

🤔 the CI is failing again, prettier issues:

Output of the CI

yarn run prettier:check
[warn] packages/grafana-data/src/field/fieldOverrides.ts
[warn] Code style issues found in the above file. Run Prettier to fix.

@ivanortegaalba
Copy link
Contributor

Hi @gng0,

The prettier formatting probably doesn't happen because you don't have the pre-commit hooks configured :)

https://github.com/grafana/grafana/blob/main/contribute/developer-guide.md#configure-precommit-hooks

Can I ask you to give a check, run prettier on the pushed code so we can merge? I can't push to your fork to fix it 😄

Thank you!

@gng0
Copy link
Author

gng0 commented May 19, 2024

@axelavargas @ivanortegaalba just bumping this 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend pr/external This PR is from external contributor
Projects
Status: 🔍 In review
Development

Successfully merging this pull request may close these issues.

grafana-data package: Links with onClick method and scopedVars have incorrect href
5 participants