0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-30 07:54:52 +01:00
gitea/routers/web/repo/helper.go
HesterG 1454f9dafc
Add actor and status dropdowns to run list (#25118)
Part of #25042

1. Added actor and status dropdowns first in case something is offtrack
and PR is too large.

2. Also added "No results matched." and "The workflow has no runs yet.",
and "No results matched." will show if there is no filter results and
there is no workflows (with [reference to github
action](https://github.com/go-gitea/gitea/actions/workflows/files-changed.yml?query=actor%3AGiteaBot))

Demo:


https://github.com/go-gitea/gitea/assets/17645053/6e76292c-4c1f-450d-8b48-99944cfc920c


TODOs:

- [x] Get available status (same as those in `aggregateJobStatus`)
instead of getting from database
- [x] Use `JOIN` to get actors, actors order by name
- [x] Make self on top
2023-06-21 04:25:14 +00:00

24 lines
517 B
Go

// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package repo
import (
"sort"
"code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
)
func MakeSelfOnTop(ctx *context.Context, users []*user.User) []*user.User {
if ctx.Doer != nil {
sort.Slice(users, func(i, j int) bool {
if users[i].ID == users[j].ID {
return false
}
return users[i].ID == ctx.Doer.ID // if users[i] is self, put it before others, so less=true
})
}
return users
}