Sort notification channels alphabetically (#37426)

Even without the ability to control the sort order or to filter, this notably improves usability for long lists of notification channels.

Partially fixes #20067.
This commit is contained in:
Jason Stangroome 2021-08-20 06:49:14 +10:00 committed by GitHub
parent 170d1bf954
commit 28784935b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -112,7 +112,7 @@ func GetAlertNotificationsWithUid(query *models.GetAlertNotificationsWithUidQuer
func GetAllAlertNotifications(query *models.GetAllAlertNotificationsQuery) error {
results := make([]*models.AlertNotification, 0)
if err := x.Where("org_id = ?", query.OrgId).Find(&results); err != nil {
if err := x.Where("org_id = ?", query.OrgId).Asc("name").Find(&results); err != nil {
return err
}

View File

@ -325,6 +325,10 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
err := GetAllAlertNotifications(query)
So(err, ShouldBeNil)
So(len(query.Result), ShouldEqual, 4)
So(query.Result[0].Name, ShouldEqual, cmd4.Name)
So(query.Result[1].Name, ShouldEqual, cmd1.Name)
So(query.Result[2].Name, ShouldEqual, cmd3.Name)
So(query.Result[3].Name, ShouldEqual, cmd2.Name)
})
})