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