mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
feat(runner): finish org runners ui
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -60,7 +61,7 @@ func RunnersList(ctx *context.Context, tplName base.TplName, opts bots_model.Fin
|
||||
ctx.HTML(http.StatusOK, tplName)
|
||||
}
|
||||
|
||||
func RunnerDetails(ctx *context.Context, tplName base.TplName, runnerID int64) {
|
||||
func RunnerDetails(ctx *context.Context, tplName base.TplName, runnerID int64, ownerID int64, repoID int64) {
|
||||
runner, err := bots_model.GetRunnerByID(runnerID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunnerByID", err)
|
||||
@@ -70,6 +71,11 @@ func RunnerDetails(ctx *context.Context, tplName base.TplName, runnerID int64) {
|
||||
ctx.ServerError("LoadAttributes", err)
|
||||
return
|
||||
}
|
||||
if !runner.Editable(ownerID, repoID) {
|
||||
err = errors.New("no permission to edit this runner")
|
||||
ctx.NotFound("RunnerDetails", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Runner"] = runner
|
||||
|
||||
@@ -79,13 +85,18 @@ func RunnerDetails(ctx *context.Context, tplName base.TplName, runnerID int64) {
|
||||
}
|
||||
|
||||
// RunnerDetailsEditPost response for edit runner details
|
||||
func RunnerDetailsEditPost(ctx *context.Context, runnerID int64, redirectTo string) {
|
||||
func RunnerDetailsEditPost(ctx *context.Context, runnerID int64, ownerID int64, repoID int64, redirectTo string) {
|
||||
runner, err := bots_model.GetRunnerByID(runnerID)
|
||||
if err != nil {
|
||||
log.Warn("RunnerDetailsEditPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL)
|
||||
ctx.ServerError("RunnerDetailsEditPost.GetRunnerByID", err)
|
||||
return
|
||||
}
|
||||
if !runner.Editable(ownerID, repoID) {
|
||||
err = errors.New("no permission to edit this runner")
|
||||
ctx.NotFound("RunnerDetailsEditPost.Editable", err)
|
||||
return
|
||||
}
|
||||
|
||||
form := web.GetForm(ctx).(*forms.EditRunnerForm)
|
||||
runner.Description = form.Description
|
||||
|
||||
Reference in New Issue
Block a user