mirror of
https://github.com/grafana/grafana.git
synced 2025-01-16 19:52:33 -06:00
c21e45e428
* Search: display metadata * Search: update SortPicker icon * Search: display folder meta data * Search: reset sort picker on layout change * Search: align tags in Card component * Search: replace hyphen with dash * Search: preserve sort state on layout change * Search: update tests * Search: fix tests * Update pkg/services/search/hits.go Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com> * Update public/app/features/search/components/SearchItem.tsx Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com> * Update public/app/features/search/components/SearchItem.tsx Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com> * Update public/app/features/search/types.ts Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com> * Search: fix type error * Search: add General folder name and adjust icon margin Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package search
|
|
|
|
import "strings"
|
|
|
|
type HitType string
|
|
|
|
const (
|
|
DashHitDB HitType = "dash-db"
|
|
DashHitHome HitType = "dash-home"
|
|
DashHitFolder HitType = "dash-folder"
|
|
)
|
|
|
|
type Hit struct {
|
|
ID int64 `json:"id"`
|
|
UID string `json:"uid"`
|
|
Title string `json:"title"`
|
|
URI string `json:"uri"`
|
|
URL string `json:"url"`
|
|
Slug string `json:"slug"`
|
|
Type HitType `json:"type"`
|
|
Tags []string `json:"tags"`
|
|
IsStarred bool `json:"isStarred"`
|
|
FolderID int64 `json:"folderId,omitempty"`
|
|
FolderUID string `json:"folderUid,omitempty"`
|
|
FolderTitle string `json:"folderTitle,omitempty"`
|
|
FolderURL string `json:"folderUrl,omitempty"`
|
|
SortMeta int64 `json:"sortMeta"`
|
|
SortMetaName string `json:"sortMetaName,omitempty"`
|
|
}
|
|
|
|
type HitList []*Hit
|
|
|
|
func (s HitList) Len() int { return len(s) }
|
|
func (s HitList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|
func (s HitList) Less(i, j int) bool {
|
|
if s[i].Type == "dash-folder" && s[j].Type == "dash-db" {
|
|
return true
|
|
}
|
|
|
|
if s[i].Type == "dash-db" && s[j].Type == "dash-folder" {
|
|
return false
|
|
}
|
|
|
|
return strings.ToLower(s[i].Title) < strings.ToLower(s[j].Title)
|
|
}
|