[v9.5.x] Library panels: Ensure pagination controls are always correctly displayed (#66279)

Library panels: Ensure pagination controls are always correctly displayed (#65283)

correctly count library panels in the general folder

(cherry picked from commit fda38de293)

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2023-04-11 16:35:28 +03:00
committed by GitHub
co-authored by Ashley Harrison
parent 345909d74b
commit 1ef8c02d19
+13 -2
View File
@@ -409,8 +409,19 @@ func (l *LibraryElementService) getAllLibraryElements(c context.Context, signedI
var libraryElements []model.LibraryElement
countBuilder := db.SQLBuilder{}
countBuilder.Write("SELECT * FROM library_element AS le")
countBuilder.Write(" INNER JOIN dashboard AS dashboard on le.folder_id = dashboard.id")
if folderFilter.includeGeneralFolder {
countBuilder.Write(selectLibraryElementDTOWithMeta)
countBuilder.Write(getFromLibraryElementDTOWithMeta(l.SQLStore.GetDialect()))
countBuilder.Write(` WHERE le.org_id=? AND le.folder_id=0`, signedInUser.OrgID)
writeKindSQL(query, &countBuilder)
writeSearchStringSQL(query, l.SQLStore, &countBuilder)
writeExcludeSQL(query, &countBuilder)
writeTypeFilterSQL(typeFilter, &countBuilder)
countBuilder.Write(" UNION ")
}
countBuilder.Write(selectLibraryElementDTOWithMeta)
countBuilder.Write(getFromLibraryElementDTOWithMeta(l.SQLStore.GetDialect()))
countBuilder.Write(" INNER JOIN dashboard AS dashboard on le.folder_id = dashboard.id and le.folder_id<>0")
countBuilder.Write(` WHERE le.org_id=?`, signedInUser.OrgID)
writeKindSQL(query, &countBuilder)
writeSearchStringSQL(query, l.SQLStore, &countBuilder)