mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-23 05:46:09 +02:00
fix: list runners
This commit is contained in:
parent
cc19ab5ced
commit
1c9288f3dd
@ -51,14 +51,13 @@ type ActionRunner struct {
|
||||
}
|
||||
|
||||
func (r *ActionRunner) OwnType() string {
|
||||
if r.OwnerID == 0 {
|
||||
return "Global"
|
||||
if r.RepoID != 0 {
|
||||
return fmt.Sprintf("Repo(%s)", r.Repo.FullName())
|
||||
}
|
||||
if r.RepoID == 0 {
|
||||
return r.Owner.Name
|
||||
if r.OwnerID != 0 {
|
||||
return fmt.Sprintf("Org(%s)", r.Owner.Name)
|
||||
}
|
||||
|
||||
return r.Repo.FullName()
|
||||
return "Global"
|
||||
}
|
||||
|
||||
func (r *ActionRunner) Status() runnerv1.RunnerStatus {
|
||||
@ -135,35 +134,35 @@ func init() {
|
||||
|
||||
type FindRunnerOptions struct {
|
||||
db.ListOptions
|
||||
RepoID int64
|
||||
OwnerID int64
|
||||
Sort string
|
||||
Filter string
|
||||
WithDeleted bool
|
||||
RepoID int64
|
||||
OwnerID int64
|
||||
Sort string
|
||||
Filter string
|
||||
WithAvailable bool // not only runners belong to, but also runners can be used
|
||||
}
|
||||
|
||||
func (opts FindRunnerOptions) toCond() builder.Cond {
|
||||
cond := builder.NewCond()
|
||||
|
||||
withGlobal := false
|
||||
if opts.RepoID > 0 {
|
||||
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
|
||||
withGlobal = true
|
||||
c := builder.NewCond().And(builder.Eq{"repo_id": opts.RepoID})
|
||||
if opts.WithAvailable {
|
||||
c = c.Or(builder.Eq{"owner_id": builder.Select("owner_id").From("repository").Where(builder.Eq{"id": opts.RepoID})})
|
||||
c = c.Or(builder.Eq{"repo_id": 0, "owner_id": 0})
|
||||
}
|
||||
cond = cond.And(c)
|
||||
}
|
||||
if opts.OwnerID > 0 {
|
||||
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
|
||||
withGlobal = true
|
||||
}
|
||||
if withGlobal {
|
||||
cond = cond.Or(builder.Eq{"repo_id": 0, "owner_id": 0})
|
||||
c := builder.NewCond().And(builder.Eq{"owner_id": opts.OwnerID})
|
||||
if opts.WithAvailable {
|
||||
c = c.Or(builder.Eq{"repo_id": 0, "owner_id": 0})
|
||||
}
|
||||
cond = cond.And(c)
|
||||
}
|
||||
|
||||
if opts.Filter != "" {
|
||||
cond = cond.And(builder.Like{"name", opts.Filter})
|
||||
}
|
||||
if !opts.WithDeleted {
|
||||
cond = cond.And(builder.IsNull{"deleted"})
|
||||
}
|
||||
return cond
|
||||
}
|
||||
|
||||
@ -181,10 +180,8 @@ func (opts FindRunnerOptions) toOrder() string {
|
||||
|
||||
func CountRunners(ctx context.Context, opts FindRunnerOptions) (int64, error) {
|
||||
return db.GetEngine(ctx).
|
||||
Table(ActionRunner{}).
|
||||
Where(opts.toCond()).
|
||||
OrderBy(opts.toOrder()).
|
||||
Count()
|
||||
Count(ActionRunner{})
|
||||
}
|
||||
|
||||
func FindRunners(ctx context.Context, opts FindRunnerOptions) (runners RunnerList, err error) {
|
||||
|
@ -36,11 +36,8 @@ func Runners(ctx *context.Context) {
|
||||
Page: page,
|
||||
PageSize: 100,
|
||||
},
|
||||
Sort: ctx.Req.URL.Query().Get("sort"),
|
||||
Filter: ctx.Req.URL.Query().Get("q"),
|
||||
WithDeleted: false,
|
||||
RepoID: 0,
|
||||
OwnerID: 0,
|
||||
Sort: ctx.Req.URL.Query().Get("sort"),
|
||||
Filter: ctx.Req.URL.Query().Get("q"),
|
||||
}
|
||||
|
||||
common.RunnersList(ctx, tplRunners, opts)
|
||||
|
@ -28,11 +28,10 @@ func Runners(ctx *context.Context) {
|
||||
Page: page,
|
||||
PageSize: 100,
|
||||
},
|
||||
Sort: ctx.Req.URL.Query().Get("sort"),
|
||||
Filter: ctx.Req.URL.Query().Get("q"),
|
||||
WithDeleted: false,
|
||||
RepoID: 0,
|
||||
OwnerID: ctx.Org.Organization.ID,
|
||||
Sort: ctx.Req.URL.Query().Get("sort"),
|
||||
Filter: ctx.Req.URL.Query().Get("q"),
|
||||
OwnerID: ctx.Org.Organization.ID,
|
||||
WithAvailable: true,
|
||||
}
|
||||
|
||||
common.RunnersList(ctx, tplSettingsRunners, opts)
|
||||
|
@ -32,11 +32,10 @@ func Runners(ctx *context.Context) {
|
||||
Page: page,
|
||||
PageSize: 100,
|
||||
},
|
||||
Sort: ctx.Req.URL.Query().Get("sort"),
|
||||
Filter: ctx.Req.URL.Query().Get("q"),
|
||||
WithDeleted: false,
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
OwnerID: 0,
|
||||
Sort: ctx.Req.URL.Query().Get("sort"),
|
||||
Filter: ctx.Req.URL.Query().Get("q"),
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
WithAvailable: true,
|
||||
}
|
||||
|
||||
common.RunnersList(ctx, tplRunners, opts)
|
||||
|
@ -434,7 +434,7 @@
|
||||
</div>
|
||||
|
||||
{{if .EnableActions}}
|
||||
{{$isActionsEnabled := .Repository.UnitEnabled $.UnitTypeActions}}
|
||||
{{$isActionsEnabled := .Repository.UnitEnabled $.Context $.UnitTypeActions}}
|
||||
<div class="inline field">
|
||||
<label>{{.locale.Tr "repo.actions"}}</label>
|
||||
{{if .UnitTypeActions.UnitGlobalDisabled}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user