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:
Daniel Lee
2017-03-27 14:36:28 +02:00
parent d10d897d65
commit 1248728d7f
15 changed files with 306 additions and 45 deletions

View File

@@ -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 {

View File

@@ -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)
})
})
})
}

View File

@@ -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
}