-
Notifications
You must be signed in to change notification settings - Fork 349
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: Auto Complete promql legend on select not getting proper value with { #3523
Conversation
c88eebb
to
5b076a3
Compare
5b076a3
to
d2accf6
Compare
d2accf6
to
11a816c
Compare
b7fb4ed
to
b7ac470
Compare
WalkthroughThis change in Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
// Find the index of the last opening brace '{' | ||
const openingBraceIndex = inputValue.lastIndexOf("{"); | ||
const newValue = | ||
inputValue.slice(0, openingBraceIndex + 1) + option + "}"; | ||
return newValue; | ||
|
||
//if { is not present add it at the start and than return | ||
if (openingBraceIndex === -1) { | ||
const newValue = | ||
"{" + inputValue.slice(0, openingBraceIndex + 1) + option + "}"; | ||
return newValue; | ||
} else { | ||
const newValue = | ||
inputValue.slice(0, openingBraceIndex + 1) + option + "}"; | ||
return newValue; | ||
} |
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.
Ensure correct handling of the opening brace in PromQL legends.
The logic for appending the opening brace {
seems incorrect. The inputValue.slice(0, openingBraceIndex + 1)
will always result in {
because openingBraceIndex
is -1
when the brace is not present. This could lead to unexpected results. Consider simplifying the logic to ensure the brace is added only when missing.
- const newValue = "{" + inputValue.slice(0, openingBraceIndex + 1) + option + "}";
+ const newValue = openingBraceIndex === -1 ? "{" + option + "}" : inputValue.slice(0, openingBraceIndex + 1) + option + "}";
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// Find the index of the last opening brace '{' | |
const openingBraceIndex = inputValue.lastIndexOf("{"); | |
const newValue = | |
inputValue.slice(0, openingBraceIndex + 1) + option + "}"; | |
return newValue; | |
//if { is not present add it at the start and than return | |
if (openingBraceIndex === -1) { | |
const newValue = | |
"{" + inputValue.slice(0, openingBraceIndex + 1) + option + "}"; | |
return newValue; | |
} else { | |
const newValue = | |
inputValue.slice(0, openingBraceIndex + 1) + option + "}"; | |
return newValue; | |
} | |
// Find the index of the last opening brace '{' | |
const openingBraceIndex = inputValue.lastIndexOf("{"); | |
//if { is not present add it at the start and than return | |
if (openingBraceIndex === -1) { | |
const newValue = "{" + option + "}"; | |
return newValue; | |
} else { | |
const newValue = | |
inputValue.slice(0, openingBraceIndex + 1) + option + "}"; | |
return newValue; | |
} |
472d697
to
8abb74e
Compare
bce4679
to
3e42178
Compare
3e42178
to
5b58020
Compare
…ith { (#3523) When a user directly selects anything from the dropdown, it incorrectly puts the value in the Legend config in dashboard's add panel config for PromQL. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved input handling in the configuration panel to ensure proper formatting of values. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
When a user directly selects anything from the dropdown, it incorrectly puts the value in the Legend config in dashboard's add panel config for PromQL.
Summary by CodeRabbit