mirror of
https://github.com/go-gitea/gitea.git
synced 2025-05-18 00:49:09 -04:00
feat: support disable bots completely
This commit is contained in:
parent
ab69fdc6fe
commit
b2745bff43
@ -799,6 +799,7 @@ func Contexter(ctx context.Context) func(next http.Handler) http.Handler {
|
||||
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
|
||||
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
|
||||
ctx.Data["DisableStars"] = setting.Repository.DisableStars
|
||||
ctx.Data["EnableBots"] = setting.Bots.Enabled
|
||||
|
||||
ctx.Data["ManifestData"] = setting.ManifestData
|
||||
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/bots"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
@ -24,6 +25,11 @@ const (
|
||||
|
||||
// MustEnableBots check if bots are enabled in settings
|
||||
func MustEnableBots(ctx *context.Context) {
|
||||
if !setting.Bots.Enabled {
|
||||
ctx.NotFound("MustEnableBots", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if unit.TypeBots.UnitGlobalDisabled() {
|
||||
ctx.NotFound("MustEnableBots", nil)
|
||||
return
|
||||
|
@ -629,7 +629,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
m.Get("/reset_registration_token", admin.ResetRunnerRegistrationToken)
|
||||
m.Combo("/{runnerid}").Get(admin.EditRunner).Post(bindIgnErr(forms.EditRunnerForm{}), admin.EditRunnerPost)
|
||||
m.Post("/{runnerid}/delete", admin.DeleteRunnerPost)
|
||||
})
|
||||
}, bots.MustEnableBots)
|
||||
}, func(ctx *context.Context) {
|
||||
ctx.Data["EnableOAuth2"] = setting.OAuth2.Enable
|
||||
ctx.Data["EnablePackages"] = setting.Packages.Enabled
|
||||
@ -792,7 +792,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
Post(bindIgnErr(forms.EditRunnerForm{}), org.RunnersEditPost)
|
||||
m.Post("/{runnerid}/delete", org.RunnerDeletePost)
|
||||
m.Get("/reset_registration_token", org.ResetRunnerRegistrationToken)
|
||||
})
|
||||
}, bots.MustEnableBots)
|
||||
|
||||
m.Group("/secrets", func() {
|
||||
m.Get("", org.Secrets)
|
||||
@ -800,11 +800,6 @@ func RegisterRoutes(m *web.Route) {
|
||||
m.Post("/delete", org.SecretsDelete)
|
||||
})
|
||||
|
||||
m.Group("/runners", func() {
|
||||
m.Get("", org.Runners)
|
||||
m.Get("/reset_registration_token", org.ResetRunnerRegistrationToken)
|
||||
})
|
||||
|
||||
m.Route("/delete", "GET,POST", org.SettingsDelete)
|
||||
|
||||
m.Group("/packages", func() {
|
||||
@ -965,7 +960,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
Post(bindIgnErr(forms.EditRunnerForm{}), repo.RunnersEditPost)
|
||||
m.Post("/{runnerid}/delete", repo.RunnerDeletePost)
|
||||
m.Get("/reset_registration_token", repo.ResetRunnerRegistrationToken)
|
||||
})
|
||||
}, bots.MustEnableBots)
|
||||
}, func(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettings"] = true
|
||||
ctx.Data["LFSStartServer"] = setting.LFS.StartServer
|
||||
|
@ -33,9 +33,11 @@
|
||||
{{.locale.Tr "settings.applications"}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{if .EnableBots}}
|
||||
<a class="{{if .PageIsAdminRunners}}active{{end}} item" href="{{AppSubUrl}}/admin/runners">
|
||||
{{.locale.Tr "admin.runners"}}
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="{{if .PageIsAdminConfig}}active{{end}} item" href="{{AppSubUrl}}/admin/config">
|
||||
{{.locale.Tr "admin.config"}}
|
||||
</a>
|
||||
|
@ -22,9 +22,11 @@
|
||||
{{.locale.Tr "packages.title"}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{if .EnableBots}}
|
||||
<a class="{{if .PageIsOrgSettingsRunners}}active{{end}} item" href="{{.OrgLink}}/settings/runners">
|
||||
{{.locale.Tr "repo.runners"}}
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="{{if .PageIsOrgSettingsSecrets}}active{{end}} item" href="{{.OrgLink}}/settings/secrets">
|
||||
{{.locale.Tr "org.settings.secrets"}}
|
||||
</a>
|
||||
|
@ -183,7 +183,7 @@
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
{{if and (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}}
|
||||
{{if and .EnableBots (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}}
|
||||
<a class="{{if .PageIsBots}}active{{end}} item" href="{{.RepoLink}}/bots">
|
||||
{{svg "octicon-play"}} {{.locale.Tr "repo.bots"}}
|
||||
{{if .Repository.NumOpenRuns}}
|
||||
|
@ -32,8 +32,10 @@
|
||||
{{.locale.Tr "repo.settings.lfs"}}
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="{{if .PageIsSettingsRunners}}active{{end}} item" href="{{.RepoLink}}/settings/runners">
|
||||
{{.locale.Tr "repo.settings.runners"}}
|
||||
</a>
|
||||
{{if and .EnableBots (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}}
|
||||
<a class="{{if .PageIsSettingsRunners}}active{{end}} item" href="{{.RepoLink}}/settings/runners">
|
||||
{{.locale.Tr "repo.settings.runners"}}
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -420,18 +420,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{$isBotsEnabled := .Repository.UnitEnabled $.UnitTypeBots}}
|
||||
<div class="inline field">
|
||||
<label>{{.locale.Tr "repo.bots"}}</label>
|
||||
{{if .UnitTypeBots.UnitGlobalDisabled}}
|
||||
<div class="ui checkbox tooltip disabled" data-content="{{.locale.Tr "repo.unit_disabled"}}">
|
||||
{{else}}
|
||||
<div class="ui checkbox">
|
||||
{{end}}
|
||||
<input class="enable-system" name="enable_bots" type="checkbox" {{if $isBotsEnabled}}checked{{end}}>
|
||||
<label>{{.locale.Tr "repo.settings.bots_desc"}}</label>
|
||||
{{if .EnableBots }}
|
||||
{{$isBotsEnabled := .Repository.UnitEnabled $.UnitTypeBots}}
|
||||
<div class="inline field">
|
||||
<label>{{.locale.Tr "repo.bots"}}</label>
|
||||
{{if .UnitTypeBots.UnitGlobalDisabled}}
|
||||
<div class="ui checkbox tooltip disabled" data-content="{{.locale.Tr "repo.unit_disabled"}}">
|
||||
{{else}}
|
||||
<div class="ui checkbox">
|
||||
{{end}}
|
||||
<input class="enable-system" name="enable_bots" type="checkbox" {{if $isBotsEnabled}}checked{{end}}>
|
||||
<label>{{.locale.Tr "repo.settings.bots_desc"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if not .IsMirror}}
|
||||
<div class="ui divider"></div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user