mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-21 13:38:00 +02:00
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
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user