-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[TSVB] Fix more than one empty labels in markdown breaks the values for all other labels #100432
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
Jenkins, test this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works great @Kunzetsov 👏
I noticed that we don't have any test case on the replace_vars.test.js
to test the empty labels scenarios.
Can you please add one? Thank you a lot!
Sure, I'll write tests. |
@elasticmachine merge upstream |
Jenkins, test this |
@@ -14,7 +14,8 @@ import { i18n } from '@kbn/i18n'; | |||
export function replaceVars(str, args = {}, vars = {}) { | |||
try { | |||
// we need add '[]' for emptyLabel because this value contains special characters. (https://handlebarsjs.com/guide/expressions.html#literal-segments) | |||
const template = handlebars.compile(str.replace(emptyLabel, `[${emptyLabel}]`), { | |||
// ''.split(...).join(...) as a save alternative of the replaceAll... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this comment is not needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I tested it locally and works fine with multiple variables based on empty labels.
Please merge in case of green ci. Thank you a lot for the test 👏
Jenkins, test this |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @Kunzetsov |
…or all other labels (elastic#100432) * Fixed multiple empty labels monitoring with []. * Fixed regexp group behavior and replaced by ''.replaceAll. * Changed ''.replaceAll with ''.split(...).join(...) * Added test for (empty) label case. * Removed not necessary comment. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…or all other labels (#100432) (#100548) * Fixed multiple empty labels monitoring with []. * Fixed regexp group behavior and replaced by ''.replaceAll. * Changed ''.replaceAll with ''.split(...).join(...) * Added test for (empty) label case. * Removed not necessary comment. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…or all other labels (elastic#100432) * Fixed multiple empty labels monitoring with []. * Fixed regexp group behavior and replaced by ''.replaceAll. * Changed ''.replaceAll with ''.split(...).join(...) * Added test for (empty) label case. * Removed not necessary comment. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…or all other labels (elastic#100432) * Fixed multiple empty labels monitoring with []. * Fixed regexp group behavior and replaced by ''.replaceAll. * Changed ''.replaceAll with ''.split(...).join(...) * Added test for (empty) label case. * Removed not necessary comment. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Fixes #98760.
When the user created a markdown with more than one variables based on empty labels, the markdown appeared broken.
This PR replaces single adding of brackets to empty label with global by using regexp.
Before:
After: