mirror of
https://github.com/go-gitea/gitea
synced 2025-02-13 23:47:02 +01:00
add ActionsGeneralSettingsPost
This commit is contained in:
parent
833def96cf
commit
f73073df41
@ -6,18 +6,46 @@ package setting
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
|
unit_model "code.gitea.io/gitea/models/unit"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/services/context"
|
"code.gitea.io/gitea/services/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
tplRepoActionsGeneral base.TplName = "repo/settings/actions"
|
tplRepoActionsGeneralSettings base.TplName = "repo/settings/actions"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ActionsGeneral(ctx *context.Context) {
|
func ActionsGeneralSettings(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("actions.general")
|
ctx.Data["Title"] = ctx.Tr("actions.general")
|
||||||
ctx.Data["PageType"] = "general"
|
ctx.Data["PageType"] = "general"
|
||||||
ctx.Data["PageIsActionsSettingsGeneral"] = true
|
ctx.Data["PageIsActionsSettingsGeneral"] = true
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, tplRepoActionsGeneral)
|
actionsUnit, err := ctx.Repo.Repository.GetUnit(ctx, unit_model.TypeActions)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetUnit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
actionsCfg := actionsUnit.ActionsConfig()
|
||||||
|
|
||||||
|
ctx.Data["AccessibleFromOtherRepos"] = actionsCfg.AccessbleFromOtherRepos
|
||||||
|
|
||||||
|
ctx.HTML(http.StatusOK, tplRepoActionsGeneralSettings)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ActionsGeneralSettingsPost(ctx *context.Context) {
|
||||||
|
actionsUnit, err := ctx.Repo.Repository.GetUnit(ctx, unit_model.TypeActions)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetUnit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
actionsCfg := actionsUnit.ActionsConfig()
|
||||||
|
actionsCfg.AccessbleFromOtherRepos = ctx.FormBool("actions_accessible_from_other_repositories")
|
||||||
|
|
||||||
|
if err := repo_model.UpdateRepoUnit(ctx, actionsUnit); err != nil {
|
||||||
|
ctx.ServerError("UpdateRepoUnit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Redirect(ctx.Repo.RepoLink + "/settings/actions/general")
|
||||||
}
|
}
|
||||||
|
@ -1133,7 +1133,9 @@ func registerRoutes(m *web.Router) {
|
|||||||
addSettingsRunnersRoutes()
|
addSettingsRunnersRoutes()
|
||||||
addSettingsSecretsRoutes()
|
addSettingsSecretsRoutes()
|
||||||
addSettingsVariablesRoutes()
|
addSettingsVariablesRoutes()
|
||||||
m.Get("/general", repo_setting.ActionsGeneral)
|
m.Combo("/general").
|
||||||
|
Get(repo_setting.ActionsGeneralSettings).
|
||||||
|
Post(repo_setting.ActionsGeneralSettingsPost)
|
||||||
}, actions.MustEnableActions)
|
}, actions.MustEnableActions)
|
||||||
// the follow handler must be under "settings", otherwise this incomplete repo can't be accessed
|
// the follow handler must be under "settings", otherwise this incomplete repo can't be accessed
|
||||||
m.Group("/migrate", func() {
|
m.Group("/migrate", func() {
|
||||||
|
@ -3,14 +3,19 @@
|
|||||||
{{ctx.Locale.Tr "actions.general.settings"}}
|
{{ctx.Locale.Tr "actions.general.settings"}}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
<form class="ui form" method="post">
|
<form class="ui form" action="{{.Link}}" method="post">
|
||||||
|
{{.CsrfTokenHtml}}
|
||||||
<div id="actions_accessible_from_other_repositories_box" class="field">
|
<div id="actions_accessible_from_other_repositories_box" class="field">
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input id="actions_accessible_from_other_repositories" name="actions_accessible_from_other_repositories" type="checkbox">
|
<input id="actions_accessible_from_other_repositories" name="actions_accessible_from_other_repositories" type="checkbox" {{if .AccessibleFromOtherRepos}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "actions.general.actions_accessible_from_other_repositories" .Owner.Name}}</label>
|
<label>{{ctx.Locale.Tr "actions.general.actions_accessible_from_other_repositories" .Owner.Name}}</label>
|
||||||
<p class="help">{{ctx.Locale.Tr "actions.general.actions_accessible_from_other_repositories_desc" .Owner.Name}}</p>
|
<p class="help">{{ctx.Locale.Tr "actions.general.actions_accessible_from_other_repositories_desc" .Owner.Name}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="divider"></div>
|
||||||
|
<div class="field">
|
||||||
|
<button class="ui primary button">{{ctx.Locale.Tr "save"}}</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user