refactor: rename to actions

This commit is contained in:
Jason Song
2022-12-06 15:16:25 +08:00
parent 56368f3963
commit 223782ca4c
50 changed files with 247 additions and 247 deletions
+13 -13
View File
@@ -18,33 +18,33 @@ import (
)
const (
tplListBots base.TplName = "repo/bots/list"
tplViewBuild base.TplName = "repo/bots/view"
tplListActions base.TplName = "repo/actions/list"
tplViewActions base.TplName = "repo/actions/view"
)
// MustEnableBots check if bots are enabled in settings
func MustEnableBots(ctx *context.Context) {
if !setting.Bots.Enabled {
ctx.NotFound("MustEnableBots", nil)
// MustEnableActions check if actions are enabled in settings
func MustEnableActions(ctx *context.Context) {
if !setting.Actions.Enabled {
ctx.NotFound("MustEnableActions", nil)
return
}
if unit.TypeBots.UnitGlobalDisabled() {
ctx.NotFound("MustEnableBots", nil)
if unit.TypeActions.UnitGlobalDisabled() {
ctx.NotFound("MustEnableActions", nil)
return
}
if ctx.Repo.Repository != nil {
if !ctx.Repo.CanRead(unit.TypeBots) {
ctx.NotFound("MustEnableBots", nil)
if !ctx.Repo.CanRead(unit.TypeActions) {
ctx.NotFound("MustEnableActions", nil)
return
}
}
}
func List(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.bots")
ctx.Data["PageIsBots"] = true
ctx.Data["Title"] = ctx.Tr("repo.actions")
ctx.Data["PageIsActions"] = true
defaultBranch, err := ctx.Repo.GitRepo.GetDefaultBranch()
if err != nil {
@@ -129,5 +129,5 @@ func List(ctx *context.Context) {
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplListBots)
ctx.HTML(http.StatusOK, tplListActions)
}
+2 -2
View File
@@ -24,7 +24,7 @@ import (
)
func View(ctx *context_module.Context) {
ctx.Data["PageIsBots"] = true
ctx.Data["PageIsActions"] = true
runIndex := ctx.ParamsInt64("run")
jobIndex := ctx.ParamsInt64("job")
ctx.Data["RunIndex"] = runIndex
@@ -37,7 +37,7 @@ func View(ctx *context_module.Context) {
run := job.Run
ctx.Data["Build"] = run
ctx.HTML(http.StatusOK, tplViewBuild)
ctx.HTML(http.StatusOK, tplViewActions)
}
type ViewRequest struct {
+3 -3
View File
@@ -164,7 +164,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
return
}
if ctx.IsBasicAuth && ctx.Data["IsApiToken"] != true && ctx.Data["IsBotToken"] != true {
if ctx.IsBasicAuth && ctx.Data["IsApiToken"] != true && ctx.Data["IsActionsToken"] != true {
_, err = auth.GetTwoFactorByUID(ctx.Doer.ID)
if err == nil {
// TODO: This response should be changed to "invalid credentials" for security reasons once the expectation behind it (creating an app token to authenticate) is properly documented
@@ -187,8 +187,8 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
accessMode = perm.AccessModeRead
}
if ctx.Data["IsBotToken"] == true {
taskID := ctx.Data["BotTaskID"].(int64)
if ctx.Data["IsActionsToken"] == true {
taskID := ctx.Data["ActionsTaskID"].(int64)
task, err := actions_model.GetTaskByID(ctx, taskID)
if err != nil {
ctx.ServerError("GetTaskByID", err)
+4 -4
View File
@@ -489,13 +489,13 @@ func SettingsPost(ctx *context.Context) {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePackages)
}
if form.EnableBots && !unit_model.TypeBots.UnitGlobalDisabled() {
if form.EnableActions && !unit_model.TypeActions.UnitGlobalDisabled() {
units = append(units, repo_model.RepoUnit{
RepoID: repo.ID,
Type: unit_model.TypeBots,
Type: unit_model.TypeActions,
})
} else if !unit_model.TypeBots.UnitGlobalDisabled() {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeBots)
} else if !unit_model.TypeActions.UnitGlobalDisabled() {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeActions)
}
if form.EnablePulls && !unit_model.TypePullRequests.UnitGlobalDisabled() {