dashboards: render correct link for folder when searching for dashboards (#10763)

Fixes #10761
This commit is contained in:
Marcus Efraimsson
2018-02-05 13:23:24 +01:00
committed by Torkel Ödegaard
parent 20feb123c9
commit a879dd8c0c
7 changed files with 26 additions and 12 deletions
+6 -1
View File
@@ -245,6 +245,7 @@ type DashboardSearchProjection struct {
Term string
IsFolder bool
FolderId int64
FolderUid string
FolderSlug string
FolderTitle string
}
@@ -323,11 +324,15 @@ func makeQueryResult(query *search.FindPersistedDashboardsQuery, res []Dashboard
Url: m.GetDashboardFolderUrl(item.IsFolder, item.Uid, item.Slug),
Type: getHitType(item),
FolderId: item.FolderId,
FolderUid: item.FolderUid,
FolderTitle: item.FolderTitle,
FolderSlug: item.FolderSlug,
Tags: []string{},
}
if item.FolderId > 0 {
hit.FolderUrl = m.GetFolderUrl(item.FolderUid, item.FolderSlug)
}
query.Result = append(query.Result, hit)
hits[item.Id] = hit
}
+5
View File
@@ -147,6 +147,7 @@ func TestDashboardDataAccess(t *testing.T) {
hit := query.Result[0]
So(hit.Type, ShouldEqual, search.DashHitFolder)
So(hit.Url, ShouldEqual, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.Uid, savedFolder.Slug))
So(hit.FolderTitle, ShouldEqual, "")
})
Convey("Should be able to search for a dashboard folder's children", func() {
@@ -163,6 +164,10 @@ func TestDashboardDataAccess(t *testing.T) {
hit := query.Result[0]
So(hit.Id, ShouldEqual, savedDash.Id)
So(hit.Url, ShouldEqual, fmt.Sprintf("/d/%s/%s", savedDash.Uid, savedDash.Slug))
So(hit.FolderId, ShouldEqual, savedFolder.Id)
So(hit.FolderUid, ShouldEqual, savedFolder.Uid)
So(hit.FolderTitle, ShouldEqual, savedFolder.Title)
So(hit.FolderUrl, ShouldEqual, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.Uid, savedFolder.Slug))
})
Convey("Should be able to search for dashboard by dashboard ids", func() {
+1
View File
@@ -107,6 +107,7 @@ func (sb *SearchBuilder) buildSelect() {
dashboard_tag.term,
dashboard.is_folder,
dashboard.folder_id,
folder.uid as folder_uid,
folder.slug as folder_slug,
folder.title as folder_title
FROM `)