From ef89e75d0eb232e98ca7a7ef278b8681c7f4fe50 Mon Sep 17 00:00:00 2001 From: 赵智超 <1012112796@qq.com> Date: Tue, 7 Apr 2020 00:33:34 +0800 Subject: add request review from specific reviewers feature in pull request (#10756) * add request review feature in pull request add a way to notify specific reviewers to review like github , by add or delet a special type review . The acton is is similar to Assign , so many code reuse the function and items of Assignee, but the meaning and result is different. The Permission style is is similar to github, that only writer can add a review request from Reviewers, but the poster can recall and remove a review request after a reviwer has revied even if he don't have Write Premission. only manager , the poster and reviewer of a request review can remove it. The reviewers can be requested to review contain all readers for private repo , for public, contain all writers and watchers. The offical Review Request will block merge if Reject can block it. an other change: add ui otify for Assignees. Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lauris BH Signed-off-by: a1012112796 <1012112796@qq.com> * new change * add placeholder string * do some changes follow #10238 to add review requests num on lists also change icon for review requests to eye Co-authored-by: Lauris BH --- templates/repo/issue/list.tmpl | 21 ++++-- templates/repo/issue/milestone_issues.tmpl | 21 ++++-- templates/repo/issue/view_content/comments.tmpl | 22 +++++- templates/repo/issue/view_content/pull.tmpl | 22 +++++- templates/repo/issue/view_content/sidebar.tmpl | 91 +++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 12 deletions(-) (limited to 'templates/repo') diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 05018bacdd..4fe0aaa00d 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -271,14 +271,25 @@ {{if .IsPull}} {{$approveOfficial := call $approvalCounts .ID "approve"}} {{$rejectOfficial := call $approvalCounts .ID "reject"}} - {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}} + {{$waitingOfficial := call $approvalCounts .ID "waiting"}} + {{if gt $approveOfficial 0}} {{svg "octicon-check" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} - {{if or (gt $rejectOfficial 0)}} - {{svg "octicon-x" 16}} - {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} - {{end}} + {{end}} + + {{if gt $rejectOfficial 0}} + {{svg "octicon-request-changes" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + + {{end}} + + {{if gt $waitingOfficial 0}} + {{svg "octicon-eye" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n") $waitingOfficial}} + + {{end}} + {{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}} {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} {{end}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index d144a97f14..5307c05733 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -241,14 +241,25 @@ {{if .IsPull}} {{$approveOfficial := call $approvalCounts .ID "approve"}} {{$rejectOfficial := call $approvalCounts .ID "reject"}} - {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}} + {{$waitingOfficial := call $approvalCounts .ID "waiting"}} + {{if gt $approveOfficial 0}} {{svg "octicon-check" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} - {{if or (gt $rejectOfficial 0)}} - {{svg "octicon-x" 16}} - {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} - {{end}} + {{end}} + + {{if gt $rejectOfficial 0}} + {{svg "octicon-request-changes" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + + {{end}} + + {{if gt $waitingOfficial 0}} + {{svg "octicon-eye" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n") $waitingOfficial}} + + {{end}} + {{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}} {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} {{end}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index bb8188def9..022e96a02e 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -7,7 +7,7 @@ 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE, 18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE, 22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED, 25 = TARGET_BRANCH_CHANGED, - 26 = DELETE_TIME_MANUAL --> + 26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST --> {{if eq .Type 0}}
{{if .OriginalAuthor }} @@ -468,5 +468,25 @@ {{.Content}}
+ {{else if eq .Type 27}} +
+ {{svg "octicon-eye" 16}} + + + + + {{.Poster.GetDisplayName}} + {{if .RemovedAssignee}} + {{if eq .PosterID .AssigneeID}} + {{$.i18n.Tr "repo.issues.review.remove_review_request_self" $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.review.remove_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}} + {{end}} + {{else}} + {{$.i18n.Tr "repo.issues.review.add_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}} + {{end}} + +
+ {{end}} {{end}} diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index c7cf737b34..09c7cd1d9f 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -10,7 +10,25 @@ + {{- else if eq .Type 4}}yellow + {{else}}grey{{end}}"> + + {{$canChoose := false}} + {{if eq .Type 4}} + {{if or (eq .ReviewerID $.SignedUserID) $.Permission.IsAdmin}} + {{$canChoose = true}} + {{end}} + {{else}} + {{if and (or $.IsIssuePoster $.CanChooseReviewer) (not (eq $.SignedUserID .ReviewerID))}} + {{$canChoose = true}} + {{end}} + {{end}} + + {{if $canChoose }} + + {{svg "octicon-sync" 16}} + + {{end}} {{svg (printf "octicon-%s" .Type.Icon) 16}} {{if .Stale}} @@ -28,6 +46,8 @@ {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}} {{else if eq .Type 3}} {{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}} + {{else if eq .Type 4}} + {{$.i18n.Tr "repo.issues.review.wait" $createdStr | Safe}} {{else}} {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}} {{end}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 2aed8f3158..941141b55f 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -2,6 +2,97 @@
{{template "repo/issue/branch_selector_field" .}} + {{if .Issue.IsPull }} + + + + +
+ {{.i18n.Tr "repo.issues.new.no_reviewers"}} +
+ {{range .PullReviewers}} +
+  {{.Reviewer.GetDisplayName}} + + + {{$canChoose := false}} + {{if eq .Type 4}} + {{if or (eq .ReviewerID $.SignedUserID) $.Permission.IsAdmin}} + {{$canChoose = true}} + {{end}} + {{else}} + {{if and (or $.IsIssuePoster $.CanChooseReviewer) (not (eq $.SignedUserID .ReviewerID))}} + {{$canChoose = true}} + {{end}} + {{end}} + + {{if $canChoose}} + + {{svg "octicon-sync" 16}} + + {{end}} + {{svg (printf "octicon-%s" .Type.Icon) 16}} + +
+ {{end}} +
+
+ + {{end}} + +
+