[search] set folder; case insensitive sort (#98335)

* [search] set folder
* sort case insensitive
* fix test
This commit is contained in:
Scott Lepper 2025-01-02 14:58:42 -05:00 committed by GitHub
parent 5a2344ed0c
commit 83bcd86d18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 5 deletions

View File

@ -166,8 +166,8 @@ func NewIndexableDocument(key *ResourceKey, rv int64, obj utils.GrafanaMetaAcces
Key: key,
Kind: key.Resource,
RV: rv,
Title: title, // We always want *something* to display
TitleSort: title,
Title: title, // We always want *something* to display
TitleSort: strings.ToLower(title), // Lowercase for case-insensitive sorting
Labels: obj.GetLabels(),
Folder: obj.GetFolder(),
CreatedBy: obj.GetCreatedBy(),

View File

@ -8,7 +8,7 @@
"kind": "dashboards",
"rv": 1234,
"title": "Test title",
"title_sort": "Test title",
"title_sort": "test title",
"description": "test description",
"tags": [
"a",

View File

@ -8,7 +8,7 @@
"kind": "dashboards",
"rv": 1234,
"title": "Test AAA",
"title_sort": "Test AAA",
"title_sort": "test aaa",
"created": 1731336353000,
"createdBy": "user:t000000001",
"repository": {

View File

@ -8,7 +8,7 @@
"kind": "dashboards",
"rv": 1234,
"title": "Test AAA",
"title_sort": "Test AAA",
"title_sort": "test aaa",
"created": 1706690655000,
"createdBy": "user:abc",
"repository": {

View File

@ -206,6 +206,10 @@ export class UnifiedSearcher implements GrafanaSearcher {
uri += `?query=${encodeURIComponent(query.query ?? '*')}`;
uri += `&limit=${query.limit ?? pageSize}`;
if (!isEmpty(query.location)) {
uri += `&folder=${query.location}`;
}
if (query.kind) {
// filter resource types
uri += '&' + query.kind.map((kind) => `type=${kind}`).join('&');