50 lines
1.4 KiB
Go
Raw Normal View History

2024-11-19 17:34:06 +08:00
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package setting
import (
"net/http"
2024-11-20 13:03:23 +08:00
repo_model "code.gitea.io/gitea/models/repo"
unit_model "code.gitea.io/gitea/models/unit"
2024-11-19 17:34:06 +08:00
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/services/context"
)
2024-11-20 14:15:08 +08:00
const tplRepoActionsGeneralSettings base.TplName = "repo/settings/actions"
2024-11-19 17:34:06 +08:00
2024-11-20 13:03:23 +08:00
func ActionsGeneralSettings(ctx *context.Context) {
2024-11-19 17:34:06 +08:00
ctx.Data["Title"] = ctx.Tr("actions.general")
ctx.Data["PageType"] = "general"
ctx.Data["PageIsActionsSettingsGeneral"] = true
2024-11-20 13:03:23 +08:00
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")
2024-11-19 17:34:06 +08:00
}