mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
WIP: rough prototype of dashboard folders
Breaks some stuff like selected dash in the search result. In dashboard search, if the user is not searching then the result is returned as a tree structure. No ACL's or user group ux yet.
This commit is contained in:
@@ -44,6 +44,7 @@ func searchHandler(query *Query) error {
|
||||
IsStarred: query.IsStarred,
|
||||
OrgId: query.OrgId,
|
||||
DashboardIds: query.DashboardIds,
|
||||
BrowseMode: query.BrowseMode,
|
||||
}
|
||||
|
||||
if err := bus.Dispatch(&dashQuery); err != nil {
|
||||
|
||||
@@ -19,6 +19,9 @@ func TestSearch(t *testing.T) {
|
||||
&Hit{Id: 16, Title: "CCAA", Tags: []string{"BB", "AA"}},
|
||||
&Hit{Id: 10, Title: "AABB", Tags: []string{"CC", "AA"}},
|
||||
&Hit{Id: 15, Title: "BBAA", Tags: []string{"EE", "AA", "BB"}},
|
||||
&Hit{Id: 17, Title: "FOLDER", Dashboards: []Hit{
|
||||
{Id: 18, Title: "ZZAA", Tags: []string{"ZZ"}},
|
||||
}},
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -57,5 +60,17 @@ func TestSearch(t *testing.T) {
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Convey("That returns result in browse mode", func() {
|
||||
query.BrowseMode = true
|
||||
err := searchHandler(&query)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Convey("should return correct results", func() {
|
||||
So(query.Result[3].Title, ShouldEqual, "FOLDER")
|
||||
So(len(query.Result[3].Dashboards), ShouldEqual, 1)
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,15 +7,18 @@ const (
|
||||
DashHitHome HitType = "dash-home"
|
||||
DashHitJson HitType = "dash-json"
|
||||
DashHitScripted HitType = "dash-scripted"
|
||||
DashHitFolder HitType = "dash-folder"
|
||||
)
|
||||
|
||||
type Hit struct {
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Uri string `json:"uri"`
|
||||
Type HitType `json:"type"`
|
||||
Tags []string `json:"tags"`
|
||||
IsStarred bool `json:"isStarred"`
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Uri string `json:"uri"`
|
||||
Type HitType `json:"type"`
|
||||
Tags []string `json:"tags"`
|
||||
IsStarred bool `json:"isStarred"`
|
||||
ParentId int64 `json:"parentId"`
|
||||
Dashboards []Hit `json:"dashboards"`
|
||||
}
|
||||
|
||||
type HitList []*Hit
|
||||
@@ -32,6 +35,7 @@ type Query struct {
|
||||
Limit int
|
||||
IsStarred bool
|
||||
DashboardIds []int
|
||||
BrowseMode bool
|
||||
|
||||
Result HitList
|
||||
}
|
||||
@@ -42,6 +46,7 @@ type FindPersistedDashboardsQuery struct {
|
||||
UserId int64
|
||||
IsStarred bool
|
||||
DashboardIds []int
|
||||
BrowseMode bool
|
||||
|
||||
Result HitList
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user