@@ -1134,12 +1134,12 @@ func NewIssuePost(ctx *context.Context) {
1134
1134
}
1135
1135
1136
1136
if ctx .HasError () {
1137
- ctx .HTML ( http . StatusOK , tplIssueNew )
1137
+ ctx .JSONError ( ctx . GetErrMsg () )
1138
1138
return
1139
1139
}
1140
1140
1141
1141
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" ))
1143
1143
return
1144
1144
}
1145
1145
@@ -1184,9 +1184,9 @@ func NewIssuePost(ctx *context.Context) {
1184
1184
1185
1185
log .Trace ("Issue created: %d/%d" , repo .ID , issue .ID )
1186
1186
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 ))
1188
1188
} else {
1189
- ctx .Redirect (issue .Link ())
1189
+ ctx .JSONRedirect (issue .Link ())
1190
1190
}
1191
1191
}
1192
1192
@@ -2777,8 +2777,7 @@ func NewComment(ctx *context.Context) {
2777
2777
}
2778
2778
2779
2779
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" ))
2782
2781
return
2783
2782
}
2784
2783
@@ -2788,8 +2787,7 @@ func NewComment(ctx *context.Context) {
2788
2787
}
2789
2788
2790
2789
if ctx .HasError () {
2791
- ctx .Flash .Error (ctx .Data ["ErrorMsg" ].(string ))
2792
- ctx .Redirect (issue .Link ())
2790
+ ctx .JSONError (ctx .GetErrMsg ())
2793
2791
return
2794
2792
}
2795
2793
@@ -2809,8 +2807,7 @@ func NewComment(ctx *context.Context) {
2809
2807
pr , err = issues_model .GetUnmergedPullRequest (ctx , pull .HeadRepoID , pull .BaseRepoID , pull .HeadBranch , pull .BaseBranch , pull .Flow )
2810
2808
if err != nil {
2811
2809
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" ))
2814
2811
return
2815
2812
}
2816
2813
}
@@ -2841,8 +2838,7 @@ func NewComment(ctx *context.Context) {
2841
2838
}
2842
2839
if ok := git .IsBranchExist (ctx , pull .HeadRepo .RepoPath (), pull .BaseBranch ); ! ok {
2843
2840
// 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." )
2846
2842
return
2847
2843
}
2848
2844
headBranchRef := pull .GetGitHeadBranchRefName ()
@@ -2882,11 +2878,9 @@ func NewComment(ctx *context.Context) {
2882
2878
2883
2879
if issues_model .IsErrDependenciesLeft (err ) {
2884
2880
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" ))
2887
2882
} 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" ))
2890
2884
}
2891
2885
return
2892
2886
}
@@ -2899,7 +2893,6 @@ func NewComment(ctx *context.Context) {
2899
2893
log .Trace ("Issue [%d] status changed to closed: %v" , issue .ID , issue .IsClosed )
2900
2894
}
2901
2895
}
2902
-
2903
2896
}
2904
2897
2905
2898
// Redirect to comment hashtag if there is any actual content.
@@ -2908,9 +2901,9 @@ func NewComment(ctx *context.Context) {
2908
2901
typeName = "pulls"
2909
2902
}
2910
2903
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 ()))
2912
2905
} 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 ))
2914
2907
}
2915
2908
}()
2916
2909
0 commit comments