-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Refresh query when parameters update #3737
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.
A lot of the changes are in the query view code, but this functionality need to be applied in all the places where we use parameters (dashboards for example). So most of the changes need to be encapsulated in a single place.
Here's a suggestion --
Feels like the "value updated" should be a property/event of the parameter UI. The single parameter UI will notify the <Parameters>
component, which will notify its parent about the updated values. The parent will handle refreshing the data. When the change is applied, the query.parameters
already holds the new values (so Query#getQueryResult
doesn't need to change).
Each type of parameter will have its own logic of when to apply the change and notify parent: dropdowns and date pickers upon selection, while input fields when clicking on Apply.
Maybe we should wait with introducing debounce until we implement the regular functionality and then decide where debounce belongs in this flow.
Thanks for the comments @arikfr, I've imagined this would be applied to other places where Parameters is used. I thought about doing as you mentioned before, the main reason I went with more logic in the
Well, I agree that the second one is not ideal as we would repeat a lot of logic across components, so I'm moving to 1. Gonna make it work first without this functionality, then find a way to handle it. In any case, this is sort of what I had in mind. Regarding debounce, NP, I'm more using it for testing, later we figure out where it should be. |
@gabrieldutra I don't think the component need to expose a method, but rather it should use the same data model object that the parent component will use. Also, not sure that executing a query should apply the new inputs. It's probably simpler to have the parent components see the old value until it's applied by the input component. This should make implementation simpler and makes sense UX wise. |
@gabrieldutra these are very cool suggestions.
My tendency is to do something similar to the UI in param editor: So perhaps something like this: That when clicked turns to this: |
@ranbena there is no need for edit button, as this is an input field... Having the buttons outside of the control does indeed solve some issues, but is it clear what it will do? Although I wonder if we should implement this UI: (including static label for value until edited) 🤔 I'll sleep on it. @kravets-levko @rauchy wdyt? |
I meant for this "edit" button to swap the "cog" (should keep it cog tho), and when |
Oh, I see now. Well, the cog only visible for the query editor in edit mode, so not sure if I would bother with moving it or changing it. My concern that it won't be intuitive what this confirm/cancel button do. But it seems like the simplest solution for now, so maybe worth starting with it and iterating from there. @gabrieldutra wdyt? |
I still find the word "Apply" more descriptive and easy to understand than an icon. |
I did validate this for different resolutions, but I share the same concern.
If the button will be added in the "same place" as the input (not in a popover) I think it's better not to have a cancel button. Seems simpler without it + I don't think it adds much in this case. Regarding Static label (or Popover): the idea is interesting, but it adds a new step to the process. I mean, when editing 1 parameter it's fine, but when editing 5 this may get annoying. Also, it wouldn't be possible to use only the keyboard when editing more than 1 parameter. I agree with @rauchy that the word "Apply" is more intuitive. Perhaps explore it without it being within the input? |
My thoughts after reviewing this again and playing with the current version:
It seems that the only issue are the spinners for numbers -- I wasn't that attached to them, so don't mind them going away. If we get feedback they were useful, we can explore other options. But for now I think that your current implementation is good 👌 Let's move on ⏩ and get this implemented :) |
I'll have to work on a different approach to it anyway, following @ranbena's comment, I've just tested it on Firefox: Remove the border from the input and put it in a |
Good call. Let's finish the functionality, add debounce where needed and do the FF fix in a follow up PR so we can release this already. While the bouncing inputs are annoying, it's still better than current behavior. |
I've updated this to include the Apply Button in the other places. @arikfr, is anything missing for this to be done in terms of functionality? If not, this can be open for review 🙂 The best place to put debounce seemed to be the |
@ranbena, I've updated the styling after considering your comments :). What did you base Should it be 5px instead to fit top & bottom of Apply Button's position?
This is sort of an edge case if you consider that when you go on typing it automatically goes to the caret position, I think if there is an easy solution we should do. I'll see what I find for this.
I think the idea is to have some time to apply more parameters without executing the query multiple times (although the 1 sec I let for tests seems not to be enough ^^) |
Looking good. 4px comes from the button's distance from top and bottom. For visual consistency it should be 4px from all sides.
With absolute positioning it should be
👍
Why is it needed though? Doesn't the previous execution get cancelled on re-execution? |
@gabrieldutra just noticed that if you keep typing, Chrome will automatically scroll to caret. So can leave as is. |
Well I can tell you the user experience now is soooo much better :)
Nice!
@arikfr how does it work? |
We deduplicate executions of the same query multiple times, i.e. if the query already executes and you execute it again, it will "join" the previous execution. So in the above case, because you didn't change the values, it was all one execution. Indeed the idea here was to avoid multiple executions when you want to update several parameters. But thinking about it, I see that debounce is not enough -- what needs to happen is more complex: if you start editing another parameter, we should wait with execution. Let's roll out without debounce, and improve this based on feedback from users and our experience using this. |
Is this ready in terms of implementation? |
A sidenote on debounce and UX: Similar to the dashboard save debounce implementation. |
Considering the last comments, yes. I do have a concern about slow queries, but I think it's safe to go through "Let's roll out without debounce, and improve this based on feedback from users and our experience using this.".
This is sort of why I was keeping with 1 sec of debounce only, but definitively better without debounce or with a visual indication. |
onChange={onSelect} | ||
/> | ||
<div | ||
className={classNames('parameter-input-number', { 'parameter-input-number--apply-button': showApplyButton })} |
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.
When it comes to element state, I tend to favor describing the state rather than it's impact (cause that usually changes as app progresses) so instead of classname parameter-input-number--apply-button
I'd go with input-dirty
. And if it's a bool, I'd even ditch classnames and do a data-dirty="true"
attribute on the element.
For your consideration 👨💻
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.
Oh, this is just to have the apply button on/off 🤦♂️
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.
Hmm so I would have these as two separate attributes actually.
Where does $ctrl.applyButton
determined? When is it false
?
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.
Found it - hardcoded to true
. Then perhaps this prop can be removed and code simplified?
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.
When is it
false
?
ParameterMappingInput
🙂 (e.g: in the Add Widget Dialog). Also I thought it could be interesting to support it without the Apply Button.
Regarding the css, yes, it's to turn on/off the appearing of the apply button on the input. I tried to follow BEM naming convention on that, but yes, I can use a data attribute instead. It will actually look better than this classNames
syntax.
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.
BTW, it was Cypress that made me realize that the Apply Button would affect the Add Widget Dialog 😁
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 tried to follow BEM naming convention on that
Maybe we should have a conversation on whether we want to keep using BEM.
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.
Updated 👍
Maybe we should have a conversation on whether we want to keep using BEM.
This was actually the only case where I was applying BEM (modifiers like --apply-button
). But I preferred as @ranbena suggested data-dirty
. I think BEM is sort of deprecated for Redash already, just need to update the docs if that's really the case.
Another sidenote - the reason I prefer an icon to textual label in this case ("apply") is that some day we'll incorporate i18n, and this won't do 🔮 |
🤔 fair point. Let's keep it as is for now with Apply and revisit in the future. I feel like the whole UI for parameters is due for deeper UX work. One option is to have it in a non editable form when presenting and have a proper UI for editing. Here's an example from Intercom: And when editing: About an alternative to debounce, we could have a dropdown next to the Apply.
|
Date Range parameters don't seem to update on dashboards. See example here: https://deploy-preview-3737--redash-preview.netlify.com/dashboard/legacy-parameters-dashboard?p_dateparam=2019-01-21&p_AlbumId=2001-01-20&p_time_frame.start=2019-01-03&p_time_frame.end=2019-01-11&p_param1=title1&p_date%20range.start=2019-05-24&p_date%20range.end=2019-05-27. |
Actually none of the parameters are updating in there, it seems that |
}, | ||
controller($scope) { | ||
this.setValue = (value) => { | ||
this.param.setValue(value); | ||
$scope.$applyAsync(); | ||
$scope.$apply(); |
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.
@arikfr changing $applyAsync
to $apply
here did the trick for the parameters not working on dashboards. What happens is that dashboards depends on Url Parameters to be updated (it's a $watch
that does it) and the refresh was being triggered before.
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.
Luckily soon we will get rid of all these crap 😎
🤩 |
* Add touch state to parameters and autoupdate query * Use values change event instead of $watch * Remove getQueryResultDebounced * Add Apply button * Remove Input Number spinners for Parameters * Make Apply Button optional * Update share_embed_spec * Change debounce to the Parameters component * Remove unnecessary click on Execute query * Add apply button to the remaining places * Update dashboard_spec * Use onKeyUp for InputNumber * Simplify onParametersValuesChanged * Update DateTime onChange function * Don't apply when modifier key is pressed * Remove refresh Button from Parameters * Update apply button styling * Update apply right distance * Remove debounce for testing * Use data-dirty instead of classNames for styling * Make sure $apply runs before calling onChange
What type of PR is this? (check all applicable)
Description
This is a work on #2316.
So far, I've added a touch state to Query Parameters and it now refreshes query results whenever a parameter is modified (debounce already added). Next step will be to add an "Apply" button for input fields while refining UX.
Related Tickets & Documents
#2316
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
Not yet 😴