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

Fix rendering of formatted value #52991

Closed
wants to merge 22 commits into from
Closed

Fix rendering of formatted value #52991

wants to merge 22 commits into from

Conversation

gospodarsky
Copy link
Contributor

@gospodarsky gospodarsky commented Dec 13, 2019

Summary

To #35235

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@gospodarsky gospodarsky self-assigned this Dec 13, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

History

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

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

merge conflict between base and head

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

Tested and excited to confirm that it works! However, I do think we need to rearrange some of these items. I tend to agree with @alexwizp that the modifications to htmlConvert make it less intuitive, and I actually think the problem lies in a different place...

From what I can tell, the problem is not that we need to set the url params on the field formatter class and then override them later, it's that in the pipeline_helpers/utilities we are expecting the format.convert() on line 171 to accept 4 arguments like they do in index_patterns/format_hit.

If you add a debugger to the html content type here and compare the same results in Discover and Visualize/Dashboards, you will see what I'm talking about. Discover doesn't use the pipeline_helpers/utilities, and instead the formatter getConverterFor is called directly from the index patterns via format_hit, and all 4 args are preserved. But pipeline_helpers/utilities uses convert directly, and then the parsedUrl that is provided does not actually get passed all the way through.

So while the proposed changes here do technically fix the problem, they are really just a workaround. I see two possible ways to approach this:

  1. We can change pipeline_helpers/utilities to use getConverterFor instead of convert (one-line change; I tested this locally and it works.
  2. We fix the FieldFormat convert method so that it accepts more args and applies them correctly (i.e. matching the HtmlContextTypeConvert type).

Option 2 feels like the "right" answer to me since it would fix the problem for anybody using convert... But this also makes it a bit more risky and would require careful testing. I'm also open to Option 1, though if we went that route it would be good to document this as a follow-up task to investigate later. Curious to hear your thoughts on this.

Lastly, we should definitely add a functional test for this specific case. Really all this needs to do is adjust one of the fields in the index pattern to be url-based (perhaps IP field since that's what was originally presented in the parent issue for this), then navigate to both discover and visualize and verify that the relevant html element is in fact a link. The reason I think a functional test is crucial is because this is a very specific feature that I know does not get tested manually very often, and could easily regress in the future. The field formatter pipeline utilities are also in need of more unit tests in general, but I think a functional test will suffice for this particular issue.

Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

see comments above

@alexwizp alexwizp self-requested a review December 17, 2019 15:50
Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

Approved by mistake

@alexwizp alexwizp self-requested a review December 17, 2019 15:51
@elasticmachine
Copy link
Contributor

💔 Build Failed

History

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

@gospodarsky
Copy link
Contributor Author

Resolved in #53265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants