mirror of
https://github.com/go-gitea/gitea
synced 2025-01-09 22:55:59 +01:00
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"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/services/context"
|
|
)
|
|
|
|
const tplRepoActionsGeneralSettings base.TplName = "repo/settings/actions"
|
|
|
|
func ActionsGeneralSettings(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("actions.general")
|
|
ctx.Data["PageType"] = "general"
|
|
ctx.Data["PageIsActionsSettingsGeneral"] = true
|
|
|
|
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")
|
|
}
|