-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Enhance dashboard parameter handling: persist updated values and apply saved parameters #7570
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
base: master
Are you sure you want to change the base?
Enhance dashboard parameter handling: persist updated values and apply saved parameters #7570
Conversation
…y saved parameters
|
I skipped the Restyled check to give the reviewer a chance to look at the code that was changed. I would recommend running |
|
Thank you for your PR ! I think the parameters should be saved only when "Done Editing" button is clicked, as the "Done Editing" button is for saving, and it makes the behavior of the Query Editor and the Dashboard Editor consistent. |
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.
Pull Request Overview
This PR implements the ability to persist dashboard parameter values when the Apply button is clicked. This addresses the need to maintain customized parameter values across dashboard sessions without requiring query cloning or static parameters. The implementation establishes a new parameter precedence order: URL parameters override dashboard-saved parameters, which in turn override query-defined default parameters.
- Introduces parameter value persistence in
dashboard.options.parameterValues - Implements
persistParameterValuesfunction to save parameter updates to the backend - Updates parameter loading to check for saved values before applying defaults
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| client/app/services/dashboard.js | Modified getParametersDefs to load saved parameter values from dashboard options and apply them before URL parameters |
| client/app/pages/dashboards/hooks/useDashboard.js | Added persistParameterValues function and integrated it into the refreshDashboard flow with error handling |
| client/app/pages/dashboards/DashboardPage.jsx | Fixed onParametersEdit to preserve existing dashboard options when updating parameter order |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .catch(error => { | ||
| console.error("Failed to persist parameter values:", error); | ||
| notification.error("Parameter values could not be saved. Your changes may not be persisted."); | ||
| }) | ||
| .then(() => loadDashboard(true, updatedParameters)) |
Copilot
AI
Nov 14, 2025
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.
The error in persistParameterValues is caught but the promise chain continues to loadDashboard even if persistence fails. This means the dashboard will refresh with new values that haven't been saved. Consider returning early or skipping the refresh if persistence fails to prevent showing unsaved state.
| .catch(error => { | |
| console.error("Failed to persist parameter values:", error); | |
| notification.error("Parameter values could not be saved. Your changes may not be persisted."); | |
| }) | |
| .then(() => loadDashboard(true, updatedParameters)) | |
| .then(() => { | |
| // Only refresh dashboard if persistence succeeded | |
| loadDashboard(true, updatedParameters); | |
| }) | |
| .catch(error => { | |
| console.error("Failed to persist parameter values:", error); | |
| notification.error("Parameter values could not be saved. Your changes may not be persisted."); | |
| // Do not refresh dashboard if persistence failed | |
| }) |
…iting and improve value update logic
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Promise.resolve(persistParameterValues(pendingValues)).catch(error => { | ||
| console.error("Failed to persist parameter values:", error); | ||
| notification.error("Parameter values could not be saved. Your changes may not be persisted."); | ||
| pendingParameterValuesRef.current = pendingValues; |
Copilot
AI
Nov 14, 2025
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.
The error handling here may not work as intended. The updateDashboard function (lines 68-96) catches errors but doesn't re-throw them, meaning the promise resolves successfully even when the save fails. As a result, this catch block will not execute for most failure scenarios (except for cases where Dashboard.save itself rejects), and users won't see the error message or have their pending values restored. Consider modifying the implementation to properly detect and handle save failures.
| pendingParameterValuesRef.current = pendingValues; | |
| pendingParameterValuesRef.current = pendingValues; | |
| throw error; |
| Promise.resolve(persistParameterValues(pendingValues)).catch(error => { | ||
| console.error("Failed to persist parameter values:", error); | ||
| notification.error("Parameter values could not be saved. Your changes may not be persisted."); | ||
| pendingParameterValuesRef.current = pendingValues; |
Copilot
AI
Nov 14, 2025
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.
There's a potential race condition if the user re-enters edit mode while a persist operation is still in flight. If the persist operation then fails and tries to restore values at line 271, it could overwrite the new edit session's (empty) pending values with old values from the previous session. Consider tracking an edit session ID or timestamp to ensure restored values belong to the current session.
|
Thank you for updating. |
Have you tested it? It saves changes only after "Done editing" button click. I had tried to find any other option to save params, but the only way I found is with that button. Also added some info to the PR message. |
|
Thank you ! And, I think |
…nce of current parameter values
|
@yoshiokatsuneo The logic is consistent with the queries. The parameters are updated in edit mode, but after clicking Apply Changes and then Done Editing. I have now simplified the code a little and removed it from |
|
Thank you for updating. The behavior looks good ! How about making it easier to understand ? |
…boardEditControl for improved parameter persistence
|
@yoshiokatsuneo I hope I understood you correctly. I'm not a developer and haven't explored the front-end code in depth, but I hope everything is okay now. |
yoshiokatsuneo
left a comment
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.
Thank you for the update !
I added comments.
| ); | ||
|
|
||
| const persistParameterValues = useCallback( | ||
| parameterValues => { |
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.
Can't we just save parameterValues ?
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'm not sure that it's possible right now. We must update options and there could be globalParamOrder key. With my approach we will save all the keys in this field.
…ters and merge parameter values for improved persistence
@yoshiokatsuneo I´ve pushed some changes again. Could you check it please? |
…d remove unnecessary checks for improved clarity
…s and streamline dashboard options merging
…g for improved clarity and functionality
What type of PR is this?
Description
Added support for saving dashboard parameters after clicking the Apply button. This is useful when using query templates and inserting them into different dashboards. Without this logic, there are two solutions: cloning queries or making parameters static.
Now they are used in the following order: url, dashboard parameters, query parameters.
How is this tested?
Related Tickets & Documents
Mobile & Desktop Screenshots/Recordings (if there are UI changes)