mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-22 05:15:22 +02:00
feat(runner): add repo runners ui pages
This commit is contained in:
parent
888b4c8313
commit
6a0614f4a5
@ -1,26 +1,63 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/url"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/webhook"
|
bots_model "code.gitea.io/gitea/models/bots"
|
||||||
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
|
"code.gitea.io/gitea/routers/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
tplRunners = "repo/settings/runners"
|
||||||
|
tplRunnerEdit = "repo/settings/runner_edit"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Runners render runners page
|
// Runners render runners page
|
||||||
func Runners(ctx *context.Context) {
|
func Runners(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings.hooks")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.runners")
|
||||||
ctx.Data["PageIsSettingsHooks"] = true
|
ctx.Data["PageIsSettingsRunners"] = true
|
||||||
ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks"
|
|
||||||
ctx.Data["BaseLinkNew"] = ctx.Repo.RepoLink + "/settings/hooks"
|
|
||||||
ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://docs.gitea.io/en-us/webhooks/")
|
|
||||||
|
|
||||||
ws, err := webhook.ListWebhooksByOpts(ctx, &webhook.ListWebhookOptions{RepoID: ctx.Repo.Repository.ID})
|
page := ctx.FormInt("page")
|
||||||
if err != nil {
|
if page <= 1 {
|
||||||
ctx.ServerError("GetWebhooksByRepoID", err)
|
page = 1
|
||||||
return
|
|
||||||
}
|
}
|
||||||
ctx.Data["Webhooks"] = ws
|
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, tplHooks)
|
opts := bots_model.FindRunnerOptions{
|
||||||
|
ListOptions: db.ListOptions{
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
common.RunnersList(ctx, tplRunners, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RunnersEdit(ctx *context.Context) {
|
||||||
|
ctx.Data["Title"] = ctx.Tr("repo.settings.runners")
|
||||||
|
ctx.Data["PageIsSettingsRunners"] = true
|
||||||
|
|
||||||
|
common.RunnerDetails(ctx, tplRunnerEdit,
|
||||||
|
ctx.ParamsInt64(":runnerid"), 0, ctx.Repo.Repository.ID,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RunnersEditPost(ctx *context.Context) {
|
||||||
|
ctx.Data["Title"] = ctx.Tr("repo.settings.runners")
|
||||||
|
ctx.Data["PageIsSettingsRunners"] = true
|
||||||
|
common.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"),
|
||||||
|
0, ctx.Repo.Repository.ID,
|
||||||
|
ctx.Repo.RepoLink+"/settings/runners/"+url.PathEscape(ctx.Params(":runnerid")))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResetRunnerRegistrationToken(ctx *context.Context) {
|
||||||
|
common.RunnerResetRegistrationToken(ctx,
|
||||||
|
0, ctx.Repo.Repository.ID,
|
||||||
|
ctx.Repo.RepoLink+"/settings/runners")
|
||||||
}
|
}
|
||||||
|
@ -967,6 +967,9 @@ func RegisterRoutes(m *web.Route) {
|
|||||||
|
|
||||||
m.Group("/runners", func() {
|
m.Group("/runners", func() {
|
||||||
m.Get("", repo.Runners)
|
m.Get("", repo.Runners)
|
||||||
|
m.Combo("/{runnerid}").Get(repo.RunnersEdit).
|
||||||
|
Post(bindIgnErr(forms.EditRunnerForm{}), repo.RunnersEditPost)
|
||||||
|
m.Get("/reset_registration_token", repo.ResetRunnerRegistrationToken)
|
||||||
})
|
})
|
||||||
|
|
||||||
}, func(ctx *context.Context) {
|
}, func(ctx *context.Context) {
|
||||||
|
9
templates/repo/settings/runner_edit.tmpl
Normal file
9
templates/repo/settings/runner_edit.tmpl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{{template "base/head" .}}
|
||||||
|
<div class="page-content repository settings webhooks">
|
||||||
|
{{template "repo/header" .}}
|
||||||
|
{{template "repo/settings/navbar" .}}
|
||||||
|
<div class="ui container">
|
||||||
|
{{template "runners/edit" .}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{template "base/footer" .}}
|
9
templates/repo/settings/runners.tmpl
Normal file
9
templates/repo/settings/runners.tmpl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{{template "base/head" .}}
|
||||||
|
<div class="page-content repository settings webhooks">
|
||||||
|
{{template "repo/header" .}}
|
||||||
|
{{template "repo/settings/navbar" .}}
|
||||||
|
<div class="ui container">
|
||||||
|
{{template "runners/list" .}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{template "base/footer" .}}
|
Loading…
x
Reference in New Issue
Block a user