-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(ui): displaying variable list default values #17097
Conversation
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.
Going to add some tests here to ensure that this is stable
@asalem1 is this ready for review or should i wait for you to fix the e2e tests? |
@hoorayimhelping not quite yet unfortunately. I managed to update and add some tests, but I'm currently trying to add some individual tests for the utility functions I created and bumping into some uncaught existing issues that I'm looking to smooth over. I'll DM you when the PR is ready to go :D |
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.
Unit tests and selectors please 😄
const values = getTimeMachineValues(state, ownProps.variableID) | ||
const {variableID} = ownProps | ||
let values: VariableValues | ||
if (variableID.includes('timeRange') || variableID.includes('windowPeriod')) { |
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 code is a perfect example of something that should live inside a selector and unit tested. Shoot, it could even go inside the getTimeMachineValues
selector. Generally, anytime I'm doing a whole bunch of logic inside of mstp
I like to ask myself "should this go into a selector?"
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.
Sounds good to me
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.
Nice work man. Some suggestions below. Nothing blocking.
@@ -48,7 +48,7 @@ const VariableToolbar: FunctionComponent<OwnProps & StateProps> = ({ | |||
} | |||
|
|||
const mstp = (state: AppState): StateProps => { | |||
const variables = extractVariablesList(state) | |||
const variables = extractVariablesListWithDefaults(state) |
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.
const variables = extractVariablesListWithDefaults(state) | |
const variables = getVariables(state) |
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.
I'd rather keep this as is since:
- We already have an oats generated API call by that name
- Default variables (like windowPeriod, timeRangeStart, timeRangeStop) are never returned when we currently deal with anything
getVariable
related.
@@ -53,3 +56,24 @@ describe('getTimeRangeVars', () => { | |||
}) | |||
}) | |||
}) | |||
|
|||
describe('getTimeRangeAsVariable', () => { |
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.
💃
88d42eb
to
5d7ba4e
Compare
{dropdownItems.length === 1 && ( | ||
<Dropdown | ||
button={button} | ||
style={{width: '200px'}} | ||
menu={menu} | ||
testID="variable--tooltip-dropdown" | ||
/> | ||
)} |
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.
Added this piece of logic after speaking to a user and them mentioning that dropdowns with only 1 option are confusing since they'd expect them to have more than 1 option
146d954
to
06b41dc
Compare
3016f07
to
8c05771
Compare
Closes #16058
Problem
Variable list was showing only created variables and not showing default variables
Solution
Default variables are populated whenever the query runs, so the solution involved calculating the default variables whenever the variable list was rendered & whenever the variable tooltip was being toggled. Here's how it looks like in action: