From f1143562994d311d72c2ca6983576b8ad1325a8d Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Mon, 31 Aug 2020 19:26:45 +0800 Subject: [PATCH 1/5] Remove duplicate logic in initListSubmits Using the same logic to handle Choosing reviewers and assignees as choosing label. It's the first step of #10926. Signed-off-by: a1012112796 <1012112796@qq.com> --- routers/repo/issue.go | 14 +-- templates/repo/issue/view_content/pull.tmpl | 2 +- .../repo/issue/view_content/sidebar.tmpl | 8 +- web_src/js/index.js | 88 +++++++------------ 4 files changed, 44 insertions(+), 68 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index dabe0f6b0fe1..4bbc355027b5 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1516,10 +1516,11 @@ func updatePullReviewRequest(ctx *context.Context) { } reviewID := ctx.QueryInt64("id") - event := ctx.Query("is_add") + action := ctx.Query("action") - if event != "add" && event != "remove" { - ctx.ServerError("updatePullReviewRequest", fmt.Errorf("is_add should not be \"%s\"", event)) + // TODO: Not support 'clear' now + if action != "attach" && action != "detach" { + ctx.Status(403) return } @@ -1532,19 +1533,20 @@ func updatePullReviewRequest(ctx *context.Context) { return } - err = isLegalReviewRequest(reviewer, ctx.User, event == "add", issue) + err = isLegalReviewRequest(reviewer, ctx.User, action == "attach", issue) if err != nil { ctx.ServerError("isLegalRequestReview", err) return } - err = issue_service.ReviewRequest(issue, ctx.User, reviewer, event == "add") + err = issue_service.ReviewRequest(issue, ctx.User, reviewer, action == "attach") if err != nil { ctx.ServerError("ReviewRequest", err) return } } else { - ctx.ServerError("updatePullReviewRequest", fmt.Errorf("%d in %d is not Pull Request", issue.ID, issue.Repo.ID)) + ctx.Status(403) + return } } diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 94edc8b12662..b9254adeab1c 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -49,7 +49,7 @@ {{end}} {{if $canChoose }} - + {{svg "octicon-sync" 16}} {{end}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 71e84de2fa72..65d2cce7cba5 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -12,7 +12,7 @@ {{svg "octicon-gear" 16}} {{end}} -