@@ -1134,12 +1134,12 @@ func NewIssuePost(ctx *context.Context) {
11341134 }
11351135
11361136 if ctx .HasError () {
1137- ctx .HTML ( http . StatusOK , tplIssueNew )
1137+ ctx .JSONError ( ctx . GetErrMsg () )
11381138 return
11391139 }
11401140
11411141 if util .IsEmptyString (form .Title ) {
1142- ctx .RenderWithErr (ctx .Tr ("repo.issues.new.title_empty" ), tplIssueNew , form )
1142+ ctx .JSONError (ctx .Tr ("repo.issues.new.title_empty" ))
11431143 return
11441144 }
11451145
@@ -1184,9 +1184,9 @@ func NewIssuePost(ctx *context.Context) {
11841184
11851185 log .Trace ("Issue created: %d/%d" , repo .ID , issue .ID )
11861186 if ctx .FormString ("redirect_after_creation" ) == "project" && projectID > 0 {
1187- ctx .Redirect (ctx .Repo .RepoLink + "/projects/" + strconv .FormatInt (projectID , 10 ))
1187+ ctx .JSONRedirect (ctx .Repo .RepoLink + "/projects/" + strconv .FormatInt (projectID , 10 ))
11881188 } else {
1189- ctx .Redirect (issue .Link ())
1189+ ctx .JSONRedirect (issue .Link ())
11901190 }
11911191}
11921192
@@ -2777,8 +2777,7 @@ func NewComment(ctx *context.Context) {
27772777 }
27782778
27792779 if issue .IsLocked && ! ctx .Repo .CanWriteIssuesOrPulls (issue .IsPull ) && ! ctx .Doer .IsAdmin {
2780- ctx .Flash .Error (ctx .Tr ("repo.issues.comment_on_locked" ))
2781- ctx .Redirect (issue .Link ())
2780+ ctx .JSONError (ctx .Tr ("repo.issues.comment_on_locked" ))
27822781 return
27832782 }
27842783
@@ -2788,8 +2787,7 @@ func NewComment(ctx *context.Context) {
27882787 }
27892788
27902789 if ctx .HasError () {
2791- ctx .Flash .Error (ctx .Data ["ErrorMsg" ].(string ))
2792- ctx .Redirect (issue .Link ())
2790+ ctx .JSONError (ctx .GetErrMsg ())
27932791 return
27942792 }
27952793
@@ -2809,8 +2807,7 @@ func NewComment(ctx *context.Context) {
28092807 pr , err = issues_model .GetUnmergedPullRequest (ctx , pull .HeadRepoID , pull .BaseRepoID , pull .HeadBranch , pull .BaseBranch , pull .Flow )
28102808 if err != nil {
28112809 if ! issues_model .IsErrPullRequestNotExist (err ) {
2812- ctx .Flash .Error (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
2813- ctx .Redirect (fmt .Sprintf ("%s/pulls/%d" , ctx .Repo .RepoLink , pull .Index ))
2810+ ctx .JSONError (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
28142811 return
28152812 }
28162813 }
@@ -2841,8 +2838,7 @@ func NewComment(ctx *context.Context) {
28412838 }
28422839 if ok := git .IsBranchExist (ctx , pull .HeadRepo .RepoPath (), pull .BaseBranch ); ! ok {
28432840 // todo localize
2844- ctx .Flash .Error ("The origin branch is delete, cannot reopen." )
2845- ctx .Redirect (fmt .Sprintf ("%s/pulls/%d" , ctx .Repo .RepoLink , pull .Index ))
2841+ ctx .JSONError ("The origin branch is delete, cannot reopen." )
28462842 return
28472843 }
28482844 headBranchRef := pull .GetGitHeadBranchRefName ()
@@ -2882,11 +2878,9 @@ func NewComment(ctx *context.Context) {
28822878
28832879 if issues_model .IsErrDependenciesLeft (err ) {
28842880 if issue .IsPull {
2885- ctx .Flash .Error (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
2886- ctx .Redirect (fmt .Sprintf ("%s/pulls/%d" , ctx .Repo .RepoLink , issue .Index ))
2881+ ctx .JSONError (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
28872882 } else {
2888- ctx .Flash .Error (ctx .Tr ("repo.issues.dependency.issue_close_blocked" ))
2889- ctx .Redirect (fmt .Sprintf ("%s/issues/%d" , ctx .Repo .RepoLink , issue .Index ))
2883+ ctx .JSONError (ctx .Tr ("repo.issues.dependency.issue_close_blocked" ))
28902884 }
28912885 return
28922886 }
@@ -2899,7 +2893,6 @@ func NewComment(ctx *context.Context) {
28992893 log .Trace ("Issue [%d] status changed to closed: %v" , issue .ID , issue .IsClosed )
29002894 }
29012895 }
2902-
29032896 }
29042897
29052898 // Redirect to comment hashtag if there is any actual content.
@@ -2908,9 +2901,9 @@ func NewComment(ctx *context.Context) {
29082901 typeName = "pulls"
29092902 }
29102903 if comment != nil {
2911- ctx .Redirect (fmt .Sprintf ("%s/%s/%d#%s" , ctx .Repo .RepoLink , typeName , issue .Index , comment .HashTag ()))
2904+ ctx .JSONRedirect (fmt .Sprintf ("%s/%s/%d#%s" , ctx .Repo .RepoLink , typeName , issue .Index , comment .HashTag ()))
29122905 } else {
2913- ctx .Redirect (fmt .Sprintf ("%s/%s/%d" , ctx .Repo .RepoLink , typeName , issue .Index ))
2906+ ctx .JSONRedirect (fmt .Sprintf ("%s/%s/%d" , ctx .Repo .RepoLink , typeName , issue .Index ))
29142907 }
29152908 }()
29162909
0 commit comments