CloudMigrations: Improvements to backend (#91012)

* E2C: Add stat rollup to MigrationSummary

* fix report event url

* open form in new page

* sort folders by heirarchy

* undo accidental commit

* remove another commit

* make folder sorting dynamic

---------

Co-authored-by: joshhunt <josh@trtr.co>
This commit is contained in:
Michael Mandrus
2024-07-29 13:55:22 -04:00
committed by GitHub
parent 9d639278f4
commit a6088e4ee4
3 changed files with 67 additions and 1 deletions

View File

@ -384,6 +384,29 @@ func Test_DeletedDashboardsNotMigrated(t *testing.T) {
assert.Equal(t, 1, dashCount)
}
// Implementation inspired by ChatGPT, OpenAI's language model.
func Test_SortFolders(t *testing.T) {
folders := []folder.CreateFolderCommand{
{UID: "a", ParentUID: "", Title: "Root"},
{UID: "b", ParentUID: "a", Title: "Child of Root"},
{UID: "c", ParentUID: "b", Title: "Child of b"},
{UID: "d", ParentUID: "a", Title: "Another Child of Root"},
{UID: "e", ParentUID: "", Title: "Another Root"},
}
expected := []folder.CreateFolderCommand{
{UID: "a", ParentUID: "", Title: "Root"},
{UID: "e", ParentUID: "", Title: "Another Root"},
{UID: "b", ParentUID: "a", Title: "Child of Root"},
{UID: "d", ParentUID: "a", Title: "Another Child of Root"},
{UID: "c", ParentUID: "b", Title: "Child of b"},
}
sortedFolders := sortFolders(folders)
require.Equal(t, expected, sortedFolders)
}
func ctxWithSignedInUser() context.Context {
c := &contextmodel.ReqContext{
SignedInUser: &user.SignedInUser{OrgID: 1},