-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(dashboards): copy filters, variables, breakdown_colors, and data_color_theme_id when duplicating dashboards #42898
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(dashboards): copy filters, variables, breakdown_colors, and data_color_theme_id when duplicating dashboards #42898
Conversation
9140336 to
a62a07f
Compare
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.
2 files reviewed, no comments
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 adds functionality to copy dashboard filters when duplicating a dashboard, addressing the inconvenience of manually setting many filters on a duplicate. The implementation fetches filters from the source dashboard unless explicitly overridden in the request.
Key Changes:
- Modified dashboard duplication logic to copy filters from the source dashboard by default
- Added conditional logic to allow explicit filter override when provided in the request
- Refactored
existing_dashboardfetching to occur earlier in the create flow for reuse
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| posthog/api/dashboards/dashboard.py | Implements filter copying logic by fetching the source dashboard earlier and copying its filters when duplicating, unless explicit filters are provided in the request |
| posthog/api/test/dashboards/test_dashboard.py | Adds two test cases to verify filters are copied during duplication and that explicit filters override source filters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…wn_colors, and data_color_theme_id during dashboard duplication
a62a07f to
c93161b
Compare
|
Would you also please be able to fix the linter errors 🙏 ? Additionally, I think that merging master will help resolve some of the failing CI jobs as from a few spotchecks they did not appear to be related to your changes! |
c93161b to
49007e8
Compare
…wn_colors, and data_color_theme_id during dashboard duplication
…wn_colors, and data_color_theme_id during dashboard duplication
49007e8 to
8da2e81
Compare
vdekrijger
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.
Thanks for fixing this!
…color_theme_id when duplicating dashboards (#42898)
Problem
Currently, when duplicating dashboards, filter selections and other configuration settings are not included. This is inconvenient if there are many filters and the duplicate dashboard only needs a few changes.
Changes
Added logic to duplicate dashboard filters, variables, breakdown_colors, and data_color_theme_id along with the dashboard unless those values were included with the request. If explicit values are provided in the request, they override the source dashboard values.
Also refactored existing_dashboard variable initialization for clarity per PR feedback.
How did you test this code?
Added 9 automated tests to ensure all fields are copied correctly from the existing dashboard record to the duplicate, and that explicit values override source values. Also, ran all existing automated tests with no regressions.