Annotations: Use dashboard uids instead of dashboard ids (#106676)

This commit is contained in:
Stephanie Hingtgen
2025-06-13 13:59:24 -05:00
committed by GitHub
parent 47f3073ab8
commit a8886ad5ec
20 changed files with 410 additions and 228 deletions
+11 -10
View File
@@ -80,16 +80,17 @@ type AnnotationsDto struct {
}
type AnnotationEvent struct {
Id int64 `json:"id"`
DashboardId int64 `json:"dashboardId"`
PanelId int64 `json:"panelId"`
Tags []string `json:"tags"`
IsRegion bool `json:"isRegion"`
Text string `json:"text"`
Color string `json:"color"`
Time int64 `json:"time"`
TimeEnd int64 `json:"timeEnd"`
Source dashboard.AnnotationQuery `json:"source"`
Id int64 `json:"id"`
DashboardId int64 `json:"dashboardId"`
DashboardUID string `json:"dashboardUID"`
PanelId int64 `json:"panelId"`
Tags []string `json:"tags"`
IsRegion bool `json:"isRegion"`
Text string `json:"text"`
Color string `json:"color"`
Time int64 `json:"time"`
TimeEnd int64 `json:"timeEnd"`
Source dashboard.AnnotationQuery `json:"source"`
}
func (pd PublicDashboard) TableName() string {
@@ -55,7 +55,8 @@ func (pd *PublicDashboardServiceImpl) FindAnnotations(ctx context.Context, reqDT
annoQuery.Limit = anno.Target.Limit
annoQuery.MatchAny = anno.Target.MatchAny
if anno.Target.Type == "tags" {
annoQuery.DashboardID = 0
annoQuery.DashboardID = 0 // nolint: staticcheck
annoQuery.DashboardUID = ""
annoQuery.Tags = anno.Target.Tags
}
}
@@ -68,7 +69,7 @@ func (pd *PublicDashboardServiceImpl) FindAnnotations(ctx context.Context, reqDT
for _, item := range annotationItems {
event := models.AnnotationEvent{
Id: item.ID,
DashboardId: item.DashboardID,
DashboardId: item.DashboardID, // nolint: staticcheck
Tags: item.Tags,
IsRegion: item.TimeEnd > 0 && item.Time != item.TimeEnd,
Text: item.Text,
@@ -78,6 +79,10 @@ func (pd *PublicDashboardServiceImpl) FindAnnotations(ctx context.Context, reqDT
Source: anno,
}
if item.DashboardUID != nil {
event.DashboardUID = *item.DashboardUID
}
// We want dashboard annotations to reference the panel they're for. If no panelId is provided, they'll show up on all panels
// which is only intended for tag and org annotations.
if anno.Type != nil && *anno.Type == "dashboard" {