-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Prevent adding duplicate dashlet if present with same name and label #20375
Conversation
(Standard links)
|
$dashlet->name = $params['name'] ?? NULL; | ||
$dashlet->url = $params['url'] ?? NULL; | ||
$dashlet->url = $params['label'] ?? NULL; | ||
$dashlet->find(TRUE); |
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 understand the overall issue, but am wondering if this is a typo: setting $dashlet->url to equal $params['label'] ?
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 pointing this, was a typo on my end :/ Updated the patch now.
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.
Why would we search for existing dashlets by label? Labels are not guaranteed to be unique.
The existing code has this legacy quirk where even if you don't pass an id it will still attempt to update based on name
or url
. Removing the matching on url
feels like a good step forward. It removes half of the legacy behavior (which IMO would be nice to get rid of completely). But then this PR adds label
in, which feels like a step backwards toward more legacy behavior. Can we just do name matching only?
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 agree, updated the patch. Can you please check now?
|
Jenkins test this please |
This runs ok for me. And you can still have, e.g. two versions of the same civireport like chart and table as separate dashlets if you save a copy (separate report instance). |
Overview
Steps to replicate:
Before
There are duplicate dashlets under 'Available Dashlets'
After
Updates the existing dashlets.