aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/shared
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-07-26 14:04:01 +0800
committerGitHub <noreply@github.com>2023-07-26 06:04:01 +0000
commitdcd3a631288686a95cedbd4aa9cce245e896825d (patch)
treee8c726ec07c3cb54fc092d63d2713fee409ee7b4 /routers/web/shared
parent338d03ce2f05fcc49a577b58a6cfa6beb7996fd1 (diff)
downloadgitea-dcd3a631288686a95cedbd4aa9cce245e896825d.tar.gz
gitea-dcd3a631288686a95cedbd4aa9cce245e896825d.zip
Move web JSON functions to web context and simplify code (#26132)
The JSONRedirect/JSONOK/JSONError functions were put into "Base" context incorrectly, it would cause abuse. Actually, they are for "web context" only, so, move them to the correct place. And by the way, use them to simplify old code: +75 -196
Diffstat (limited to 'routers/web/shared')
-rw-r--r--routers/web/shared/actions/runners.go9
1 files changed, 2 insertions, 7 deletions
diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go
index 21e5a90d8f..eb84cc4a2e 100644
--- a/routers/web/shared/actions/runners.go
+++ b/routers/web/shared/actions/runners.go
@@ -5,7 +5,6 @@ package actions
import (
"errors"
- "net/http"
actions_model "code.gitea.io/gitea/models/actions"
"code.gitea.io/gitea/models/db"
@@ -160,9 +159,7 @@ func RunnerDeletePost(ctx *context.Context, runnerID int64,
log.Warn("DeleteRunnerPost.UpdateRunner failed: %v, url: %s", err, ctx.Req.URL)
ctx.Flash.Warning(ctx.Tr("actions.runners.delete_runner_failed"))
- ctx.JSON(http.StatusOK, map[string]any{
- "redirect": failedRedirectTo,
- })
+ ctx.JSONRedirect(failedRedirectTo)
return
}
@@ -170,7 +167,5 @@ func RunnerDeletePost(ctx *context.Context, runnerID int64,
ctx.Flash.Success(ctx.Tr("actions.runners.delete_runner_success"))
- ctx.JSON(http.StatusOK, map[string]any{
- "redirect": successRedirectTo,
- })
+ ctx.JSONRedirect(successRedirectTo)
}