@@ -6,18 +6,46 @@ package setting
66import (
77 "net/http"
88
9+ repo_model "code.gitea.io/gitea/models/repo"
10+ unit_model "code.gitea.io/gitea/models/unit"
911 "code.gitea.io/gitea/modules/base"
1012 "code.gitea.io/gitea/services/context"
1113)
1214
1315const (
14- tplRepoActionsGeneral base.TplName = "repo/settings/actions"
16+ tplRepoActionsGeneralSettings base.TplName = "repo/settings/actions"
1517)
1618
17- func ActionsGeneral (ctx * context.Context ) {
19+ func ActionsGeneralSettings (ctx * context.Context ) {
1820 ctx .Data ["Title" ] = ctx .Tr ("actions.general" )
1921 ctx .Data ["PageType" ] = "general"
2022 ctx .Data ["PageIsActionsSettingsGeneral" ] = true
2123
22- ctx .HTML (http .StatusOK , tplRepoActionsGeneral )
24+ actionsUnit , err := ctx .Repo .Repository .GetUnit (ctx , unit_model .TypeActions )
25+ if err != nil {
26+ ctx .ServerError ("GetUnit" , err )
27+ return
28+ }
29+ actionsCfg := actionsUnit .ActionsConfig ()
30+
31+ ctx .Data ["AccessibleFromOtherRepos" ] = actionsCfg .AccessbleFromOtherRepos
32+
33+ ctx .HTML (http .StatusOK , tplRepoActionsGeneralSettings )
34+ }
35+
36+ func ActionsGeneralSettingsPost (ctx * context.Context ) {
37+ actionsUnit , err := ctx .Repo .Repository .GetUnit (ctx , unit_model .TypeActions )
38+ if err != nil {
39+ ctx .ServerError ("GetUnit" , err )
40+ return
41+ }
42+ actionsCfg := actionsUnit .ActionsConfig ()
43+ actionsCfg .AccessbleFromOtherRepos = ctx .FormBool ("actions_accessible_from_other_repositories" )
44+
45+ if err := repo_model .UpdateRepoUnit (ctx , actionsUnit ); err != nil {
46+ ctx .ServerError ("UpdateRepoUnit" , err )
47+ return
48+ }
49+
50+ ctx .Redirect (ctx .Repo .RepoLink + "/settings/actions/general" )
2351}
0 commit comments