From 51c0644e41277dfb908b5666764c2919d9b680cb Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Mon, 17 Jun 2024 14:26:23 +0100 Subject: [PATCH] RestoreDashboards: add IsDeleted and PermanentlyDeleteDate to deleted search (#89283) RestoreDashboards: add IsDeleted and PermanentlyDeleteDate to deleted items in Search --- .../dashboards/service/dashboard_service.go | 4 ++- pkg/services/search/model/model.go | 34 ++++++++++--------- public/api-enterprise-spec.json | 10 ++++-- public/api-merged.json | 8 +++-- public/openapi3.json | 6 +++- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/pkg/services/dashboards/service/dashboard_service.go b/pkg/services/dashboards/service/dashboard_service.go index 7871776d224..c94d8b4df7f 100644 --- a/pkg/services/dashboards/service/dashboard_service.go +++ b/pkg/services/dashboards/service/dashboard_service.go @@ -741,7 +741,9 @@ func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashb hit.Tags = append(hit.Tags, item.Term) } if item.Deleted != nil { - hit.RemainingTrashAtAge = util.RemainingDaysUntil((*item.Deleted).Add(daysInTrash)) + deletedDate := (*item.Deleted).Add(daysInTrash) + hit.IsDeleted = true + hit.PermanentlyDeleteDate = &deletedDate } } return hitList diff --git a/pkg/services/search/model/model.go b/pkg/services/search/model/model.go index 5e3658c35a1..6b95d2a9448 100644 --- a/pkg/services/search/model/model.go +++ b/pkg/services/search/model/model.go @@ -2,6 +2,7 @@ package model import ( "strings" + "time" ) // FilterWhere limits the set of dashboard IDs to the dashboards for @@ -62,22 +63,23 @@ const ( ) 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"` // Deprecated: use FolderUID instead - FolderUID string `json:"folderUid,omitempty"` - FolderTitle string `json:"folderTitle,omitempty"` - FolderURL string `json:"folderUrl,omitempty"` - SortMeta int64 `json:"sortMeta"` - SortMetaName string `json:"sortMetaName,omitempty"` - RemainingTrashAtAge string `json:"remainingTrashAtAge,omitempty"` + 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"` // Deprecated: use FolderUID instead + FolderUID string `json:"folderUid,omitempty"` + FolderTitle string `json:"folderTitle,omitempty"` + FolderURL string `json:"folderUrl,omitempty"` + SortMeta int64 `json:"sortMeta"` + SortMetaName string `json:"sortMetaName,omitempty"` + IsDeleted bool `json:"isDeleted"` + PermanentlyDeleteDate *time.Time `json:"permanentlyDeleteDate,omitempty"` } type HitList []*Hit diff --git a/public/api-enterprise-spec.json b/public/api-enterprise-spec.json index 4dea1f5f8ba..4be1d3a41a6 100644 --- a/public/api-enterprise-spec.json +++ b/public/api-enterprise-spec.json @@ -4703,11 +4703,15 @@ "type": "integer", "format": "int64" }, + "isDeleted": { + "type": "boolean" + }, "isStarred": { "type": "boolean" }, - "remainingTrashAtAge": { - "type": "string" + "permanentlyDeleteDate": { + "type": "string", + "format": "date-time" }, "slug": { "type": "string" @@ -7049,6 +7053,7 @@ } }, "State": { + "description": "+enum", "type": "string" }, "Status": { @@ -7492,6 +7497,7 @@ } }, "Type": { + "description": "+enum", "type": "string" }, "TypeMeta": { diff --git a/public/api-merged.json b/public/api-merged.json index 81135377b88..26cf2ef2017 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -15815,11 +15815,15 @@ "type": "integer", "format": "int64" }, + "isDeleted": { + "type": "boolean" + }, "isStarred": { "type": "boolean" }, - "remainingTrashAtAge": { - "type": "string" + "permanentlyDeleteDate": { + "type": "string", + "format": "date-time" }, "slug": { "type": "string" diff --git a/public/openapi3.json b/public/openapi3.json index 592f747a06c..a00082e3deb 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -6194,10 +6194,14 @@ "format": "int64", "type": "integer" }, + "isDeleted": { + "type": "boolean" + }, "isStarred": { "type": "boolean" }, - "remainingTrashAtAge": { + "permanentlyDeleteDate": { + "format": "date-time", "type": "string" }, "slug": {