mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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 <lauris@nix.lv> 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 <lauris@nix.lv>
This commit is contained in:
		@@ -177,12 +177,13 @@ func (protectBranch *ProtectedBranch) GetGrantedApprovalsCount(pr *PullRequest)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MergeBlockedByRejectedReview returns true if merge is blocked by rejected reviews
 | 
					// MergeBlockedByRejectedReview returns true if merge is blocked by rejected reviews
 | 
				
			||||||
 | 
					// An official ReviewRequest should also block Merge like Reject
 | 
				
			||||||
func (protectBranch *ProtectedBranch) MergeBlockedByRejectedReview(pr *PullRequest) bool {
 | 
					func (protectBranch *ProtectedBranch) MergeBlockedByRejectedReview(pr *PullRequest) bool {
 | 
				
			||||||
	if !protectBranch.BlockOnRejectedReviews {
 | 
						if !protectBranch.BlockOnRejectedReviews {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	rejectExist, err := x.Where("issue_id = ?", pr.IssueID).
 | 
						rejectExist, err := x.Where("issue_id = ?", pr.IssueID).
 | 
				
			||||||
		And("type = ?", ReviewTypeReject).
 | 
							And("type in ( ?, ?)", ReviewTypeReject, ReviewTypeRequest).
 | 
				
			||||||
		And("official = ?", true).
 | 
							And("official = ?", true).
 | 
				
			||||||
		Exist(new(Review))
 | 
							Exist(new(Review))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,6 +86,8 @@ const (
 | 
				
			|||||||
	CommentTypeChangeTargetBranch
 | 
						CommentTypeChangeTargetBranch
 | 
				
			||||||
	// Delete time manual for time tracking
 | 
						// Delete time manual for time tracking
 | 
				
			||||||
	CommentTypeDeleteTimeManual
 | 
						CommentTypeDeleteTimeManual
 | 
				
			||||||
 | 
						// add or remove Request from one
 | 
				
			||||||
 | 
						CommentTypeReviewRequest
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CommentTag defines comment tag type
 | 
					// CommentTag defines comment tag type
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,64 +118,73 @@ func GetNotifications(opts FindNotificationOptions) (NotificationList, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateOrUpdateIssueNotifications creates an issue notification
 | 
					// CreateOrUpdateIssueNotifications creates an issue notification
 | 
				
			||||||
// for each watcher, or updates it if already exists
 | 
					// for each watcher, or updates it if already exists
 | 
				
			||||||
func CreateOrUpdateIssueNotifications(issueID, commentID int64, notificationAuthorID int64) error {
 | 
					// receiverID > 0 just send to reciver, else send to all watcher
 | 
				
			||||||
 | 
					func CreateOrUpdateIssueNotifications(issueID, commentID, notificationAuthorID, receiverID int64) error {
 | 
				
			||||||
	sess := x.NewSession()
 | 
						sess := x.NewSession()
 | 
				
			||||||
	defer sess.Close()
 | 
						defer sess.Close()
 | 
				
			||||||
	if err := sess.Begin(); err != nil {
 | 
						if err := sess.Begin(); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := createOrUpdateIssueNotifications(sess, issueID, commentID, notificationAuthorID); err != nil {
 | 
						if err := createOrUpdateIssueNotifications(sess, issueID, commentID, notificationAuthorID, receiverID); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return sess.Commit()
 | 
						return sess.Commit()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func createOrUpdateIssueNotifications(e Engine, issueID, commentID int64, notificationAuthorID int64) error {
 | 
					func createOrUpdateIssueNotifications(e Engine, issueID, commentID, notificationAuthorID, receiverID int64) error {
 | 
				
			||||||
	// init
 | 
						// init
 | 
				
			||||||
	toNotify := make(map[int64]struct{}, 32)
 | 
						var toNotify map[int64]struct{}
 | 
				
			||||||
	notifications, err := getNotificationsByIssueID(e, issueID)
 | 
						notifications, err := getNotificationsByIssueID(e, issueID)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	issue, err := getIssueByID(e, issueID)
 | 
						issue, err := getIssueByID(e, issueID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	issueWatches, err := getIssueWatchersIDs(e, issueID, true)
 | 
						if receiverID > 0 {
 | 
				
			||||||
	if err != nil {
 | 
							toNotify = make(map[int64]struct{}, 1)
 | 
				
			||||||
		return err
 | 
							toNotify[receiverID] = struct{}{}
 | 
				
			||||||
	}
 | 
						} else {
 | 
				
			||||||
	for _, id := range issueWatches {
 | 
							toNotify = make(map[int64]struct{}, 32)
 | 
				
			||||||
		toNotify[id] = struct{}{}
 | 
							issueWatches, err := getIssueWatchersIDs(e, issueID, true)
 | 
				
			||||||
	}
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							for _, id := range issueWatches {
 | 
				
			||||||
 | 
								toNotify[id] = struct{}{}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	repoWatches, err := getRepoWatchersIDs(e, issue.RepoID)
 | 
							repoWatches, err := getRepoWatchersIDs(e, issue.RepoID)
 | 
				
			||||||
	if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
		return err
 | 
								return err
 | 
				
			||||||
	}
 | 
							}
 | 
				
			||||||
	for _, id := range repoWatches {
 | 
							for _, id := range repoWatches {
 | 
				
			||||||
		toNotify[id] = struct{}{}
 | 
								toNotify[id] = struct{}{}
 | 
				
			||||||
	}
 | 
							}
 | 
				
			||||||
	issueParticipants, err := issue.getParticipantIDsByIssue(e)
 | 
							issueParticipants, err := issue.getParticipantIDsByIssue(e)
 | 
				
			||||||
	if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
		return err
 | 
								return err
 | 
				
			||||||
	}
 | 
							}
 | 
				
			||||||
	for _, id := range issueParticipants {
 | 
							for _, id := range issueParticipants {
 | 
				
			||||||
		toNotify[id] = struct{}{}
 | 
								toNotify[id] = struct{}{}
 | 
				
			||||||
	}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// dont notify user who cause notification
 | 
							// dont notify user who cause notification
 | 
				
			||||||
	delete(toNotify, notificationAuthorID)
 | 
							delete(toNotify, notificationAuthorID)
 | 
				
			||||||
	// explicit unwatch on issue
 | 
							// explicit unwatch on issue
 | 
				
			||||||
	issueUnWatches, err := getIssueWatchersIDs(e, issueID, false)
 | 
							issueUnWatches, err := getIssueWatchersIDs(e, issueID, false)
 | 
				
			||||||
	if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
		return err
 | 
								return err
 | 
				
			||||||
	}
 | 
							}
 | 
				
			||||||
	for _, id := range issueUnWatches {
 | 
							for _, id := range issueUnWatches {
 | 
				
			||||||
		delete(toNotify, id)
 | 
								delete(toNotify, id)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = issue.loadRepo(e)
 | 
						err = issue.loadRepo(e)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ func TestCreateOrUpdateIssueNotifications(t *testing.T) {
 | 
				
			|||||||
	assert.NoError(t, PrepareTestDatabase())
 | 
						assert.NoError(t, PrepareTestDatabase())
 | 
				
			||||||
	issue := AssertExistsAndLoadBean(t, &Issue{ID: 1}).(*Issue)
 | 
						issue := AssertExistsAndLoadBean(t, &Issue{ID: 1}).(*Issue)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assert.NoError(t, CreateOrUpdateIssueNotifications(issue.ID, 0, 2))
 | 
						assert.NoError(t, CreateOrUpdateIssueNotifications(issue.ID, 0, 2, 0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// User 9 is inactive, thus notifications for user 1 and 4 are created
 | 
						// User 9 is inactive, thus notifications for user 1 and 4 are created
 | 
				
			||||||
	notf := AssertExistsAndLoadBean(t, &Notification{UserID: 1, IssueID: issue.ID}).(*Notification)
 | 
						notf := AssertExistsAndLoadBean(t, &Notification{UserID: 1, IssueID: issue.ID}).(*Notification)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -622,6 +622,64 @@ func (repo *Repository) GetAssignees() (_ []*User, err error) {
 | 
				
			|||||||
	return repo.getAssignees(x)
 | 
						return repo.getAssignees(x)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (repo *Repository) getReviewersPrivate(e Engine, doerID, posterID int64) (users []*User, err error) {
 | 
				
			||||||
 | 
						users = make([]*User, 0, 20)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err = e.
 | 
				
			||||||
 | 
							SQL("SELECT * FROM `user` WHERE id in (SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? AND user_id NOT IN ( ?, ?)) ORDER BY name",
 | 
				
			||||||
 | 
								repo.ID, AccessModeRead,
 | 
				
			||||||
 | 
								doerID, posterID).
 | 
				
			||||||
 | 
							Find(&users); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return users, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (repo *Repository) getReviewersPublic(e Engine, doerID, posterID int64) (_ []*User, err error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						users := make([]*User, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const SQLCmd = "SELECT * FROM `user` WHERE id IN ( " +
 | 
				
			||||||
 | 
							"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? AND user_id NOT IN ( ?, ?) " +
 | 
				
			||||||
 | 
							"UNION " +
 | 
				
			||||||
 | 
							"SELECT user_id FROM `watch` WHERE repo_id = ? AND user_id NOT IN ( ?, ?) AND mode IN (?, ?) " +
 | 
				
			||||||
 | 
							") ORDER BY name"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err = e.
 | 
				
			||||||
 | 
							SQL(SQLCmd,
 | 
				
			||||||
 | 
								repo.ID, AccessModeRead, doerID, posterID,
 | 
				
			||||||
 | 
								repo.ID, doerID, posterID, RepoWatchModeNormal, RepoWatchModeAuto).
 | 
				
			||||||
 | 
							Find(&users); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return users, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (repo *Repository) getReviewers(e Engine, doerID, posterID int64) (users []*User, err error) {
 | 
				
			||||||
 | 
						if err = repo.getOwner(e); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if repo.IsPrivate ||
 | 
				
			||||||
 | 
							(repo.Owner.IsOrganization() && repo.Owner.Visibility == api.VisibleTypePrivate) {
 | 
				
			||||||
 | 
							users, err = repo.getReviewersPrivate(x, doerID, posterID)
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							users, err = repo.getReviewersPublic(x, doerID, posterID)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetReviewers get all users can be requested to review
 | 
				
			||||||
 | 
					// for private rpo , that return all users that have read access or higher to the repository.
 | 
				
			||||||
 | 
					// but for public rpo, that return all users that have write access or higher to the repository,
 | 
				
			||||||
 | 
					// and all repo watchers.
 | 
				
			||||||
 | 
					// TODO: may be we should hava a busy choice for users to block review request to them.
 | 
				
			||||||
 | 
					func (repo *Repository) GetReviewers(doerID, posterID int64) (_ []*User, err error) {
 | 
				
			||||||
 | 
						return repo.getReviewers(x, doerID, posterID)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetMilestoneByID returns the milestone belongs to repository by given ID.
 | 
					// GetMilestoneByID returns the milestone belongs to repository by given ID.
 | 
				
			||||||
func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error) {
 | 
					func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error) {
 | 
				
			||||||
	return GetMilestoneByRepoID(repo.ID, milestoneID)
 | 
						return GetMilestoneByRepoID(repo.ID, milestoneID)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										154
									
								
								models/review.go
									
									
									
									
									
								
							
							
						
						
									
										154
									
								
								models/review.go
									
									
									
									
									
								
							@@ -27,6 +27,8 @@ const (
 | 
				
			|||||||
	ReviewTypeComment
 | 
						ReviewTypeComment
 | 
				
			||||||
	// ReviewTypeReject gives feedback blocking merge
 | 
						// ReviewTypeReject gives feedback blocking merge
 | 
				
			||||||
	ReviewTypeReject
 | 
						ReviewTypeReject
 | 
				
			||||||
 | 
						// ReviewTypeRequest request review from others
 | 
				
			||||||
 | 
						ReviewTypeRequest
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Icon returns the corresponding icon for the review type
 | 
					// Icon returns the corresponding icon for the review type
 | 
				
			||||||
@@ -38,6 +40,8 @@ func (rt ReviewType) Icon() string {
 | 
				
			|||||||
		return "request-changes"
 | 
							return "request-changes"
 | 
				
			||||||
	case ReviewTypeComment:
 | 
						case ReviewTypeComment:
 | 
				
			||||||
		return "comment"
 | 
							return "comment"
 | 
				
			||||||
 | 
						case ReviewTypeRequest:
 | 
				
			||||||
 | 
							return "primitive-dot"
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return "comment"
 | 
							return "comment"
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -369,15 +373,15 @@ func GetReviewersByIssueID(issueID int64) (reviews []*Review, err error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Get latest review of each reviwer, sorted in order they were made
 | 
						// Get latest review of each reviwer, sorted in order they were made
 | 
				
			||||||
	if err := sess.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND type in (?, ?) GROUP BY issue_id, reviewer_id) ORDER BY review.updated_unix ASC",
 | 
						if err := sess.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND type in (?, ?, ?) GROUP BY issue_id, reviewer_id) ORDER BY review.updated_unix ASC",
 | 
				
			||||||
		issueID, ReviewTypeApprove, ReviewTypeReject).
 | 
							issueID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest).
 | 
				
			||||||
		Find(&reviewsUnfiltered); err != nil {
 | 
							Find(&reviewsUnfiltered); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Load reviewer and skip if user is deleted
 | 
						// Load reviewer and skip if user is deleted
 | 
				
			||||||
	for _, review := range reviewsUnfiltered {
 | 
						for _, review := range reviewsUnfiltered {
 | 
				
			||||||
		if err := review.loadReviewer(sess); err != nil {
 | 
							if err = review.loadReviewer(sess); err != nil {
 | 
				
			||||||
			if !IsErrUserNotExist(err) {
 | 
								if !IsErrUserNotExist(err) {
 | 
				
			||||||
				return nil, err
 | 
									return nil, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -389,6 +393,19 @@ func GetReviewersByIssueID(issueID int64) (reviews []*Review, err error) {
 | 
				
			|||||||
	return reviews, nil
 | 
						return reviews, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetReviewerByIssueIDAndUserID get the latest review of reviewer for a pull request
 | 
				
			||||||
 | 
					func GetReviewerByIssueIDAndUserID(issueID, userID int64) (review *Review, err error) {
 | 
				
			||||||
 | 
						review = new(Review)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if _, err := x.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_id = ? AND type in (?, ?, ?))",
 | 
				
			||||||
 | 
							issueID, userID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest).
 | 
				
			||||||
 | 
							Get(review); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MarkReviewsAsStale marks existing reviews as stale
 | 
					// MarkReviewsAsStale marks existing reviews as stale
 | 
				
			||||||
func MarkReviewsAsStale(issueID int64) (err error) {
 | 
					func MarkReviewsAsStale(issueID int64) (err error) {
 | 
				
			||||||
	_, err = x.Exec("UPDATE `review` SET stale=? WHERE issue_id=?", true, issueID)
 | 
						_, err = x.Exec("UPDATE `review` SET stale=? WHERE issue_id=?", true, issueID)
 | 
				
			||||||
@@ -442,3 +459,134 @@ func InsertReviews(reviews []*Review) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return sess.Commit()
 | 
						return sess.Commit()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// AddRewiewRequest add a review request from one reviewer
 | 
				
			||||||
 | 
					func AddRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Comment, err error) {
 | 
				
			||||||
 | 
						review, err := GetReviewerByIssueIDAndUserID(issue.ID, reviewer.ID)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// skip it when reviewer hase been request to review
 | 
				
			||||||
 | 
						if review != nil && review.Type == ReviewTypeRequest {
 | 
				
			||||||
 | 
							return nil, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sess := x.NewSession()
 | 
				
			||||||
 | 
						defer sess.Close()
 | 
				
			||||||
 | 
						if err := sess.Begin(); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var official bool
 | 
				
			||||||
 | 
						official, err = isOfficialReviewer(sess, issue, reviewer)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if !official {
 | 
				
			||||||
 | 
							official, err = isOfficialReviewer(sess, issue, doer)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if official {
 | 
				
			||||||
 | 
							if _, err := sess.Exec("UPDATE `review` SET official=? WHERE issue_id=? AND reviewer_id=?", false, issue.ID, reviewer.ID); err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = createReview(sess, CreateReviewOptions{
 | 
				
			||||||
 | 
							Type:     ReviewTypeRequest,
 | 
				
			||||||
 | 
							Issue:    issue,
 | 
				
			||||||
 | 
							Reviewer: reviewer,
 | 
				
			||||||
 | 
							Official: official,
 | 
				
			||||||
 | 
							Stale:    false,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						comment, err = createComment(sess, &CreateCommentOptions{
 | 
				
			||||||
 | 
							Type:            CommentTypeReviewRequest,
 | 
				
			||||||
 | 
							Doer:            doer,
 | 
				
			||||||
 | 
							Repo:            issue.Repo,
 | 
				
			||||||
 | 
							Issue:           issue,
 | 
				
			||||||
 | 
							RemovedAssignee: false,       // Use RemovedAssignee as !isRequest
 | 
				
			||||||
 | 
							AssigneeID:      reviewer.ID, // Use AssigneeID as reviewer ID
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return comment, sess.Commit()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//RemoveRewiewRequest remove a review request from one reviewer
 | 
				
			||||||
 | 
					func RemoveRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Comment, err error) {
 | 
				
			||||||
 | 
						review, err := GetReviewerByIssueIDAndUserID(issue.ID, reviewer.ID)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if review.Type != ReviewTypeRequest {
 | 
				
			||||||
 | 
							return nil, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sess := x.NewSession()
 | 
				
			||||||
 | 
						defer sess.Close()
 | 
				
			||||||
 | 
						if err := sess.Begin(); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = sess.Delete(review)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var official bool
 | 
				
			||||||
 | 
						official, err = isOfficialReviewer(sess, issue, reviewer)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if official {
 | 
				
			||||||
 | 
							// recalculate which is the latest official review from that user
 | 
				
			||||||
 | 
							var review *Review
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							review, err = GetReviewerByIssueIDAndUserID(issue.ID, reviewer.ID)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if review != nil {
 | 
				
			||||||
 | 
								if _, err := sess.Exec("UPDATE `review` SET official=? WHERE id=?", true, review.ID); err != nil {
 | 
				
			||||||
 | 
									return nil, err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						comment, err = CreateComment(&CreateCommentOptions{
 | 
				
			||||||
 | 
							Type:            CommentTypeReviewRequest,
 | 
				
			||||||
 | 
							Doer:            doer,
 | 
				
			||||||
 | 
							Repo:            issue.Repo,
 | 
				
			||||||
 | 
							Issue:           issue,
 | 
				
			||||||
 | 
							RemovedAssignee: true,        // Use RemovedAssignee as !isRequest
 | 
				
			||||||
 | 
							AssigneeID:      reviewer.ID, // Use AssigneeID as reviewer ID
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return comment, sess.Commit()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,7 +52,8 @@ func TestReviewType_Icon(t *testing.T) {
 | 
				
			|||||||
	assert.Equal(t, "request-changes", ReviewTypeReject.Icon())
 | 
						assert.Equal(t, "request-changes", ReviewTypeReject.Icon())
 | 
				
			||||||
	assert.Equal(t, "comment", ReviewTypeComment.Icon())
 | 
						assert.Equal(t, "comment", ReviewTypeComment.Icon())
 | 
				
			||||||
	assert.Equal(t, "comment", ReviewTypeUnknown.Icon())
 | 
						assert.Equal(t, "comment", ReviewTypeUnknown.Icon())
 | 
				
			||||||
	assert.Equal(t, "comment", ReviewType(4).Icon())
 | 
						assert.Equal(t, "primitive-dot", ReviewTypeRequest.Icon())
 | 
				
			||||||
 | 
						assert.Equal(t, "comment", ReviewType(6).Icon())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestFindReviews(t *testing.T) {
 | 
					func TestFindReviews(t *testing.T) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ type Notifier interface {
 | 
				
			|||||||
	NotifyIssueChangeStatus(*models.User, *models.Issue, *models.Comment, bool)
 | 
						NotifyIssueChangeStatus(*models.User, *models.Issue, *models.Comment, bool)
 | 
				
			||||||
	NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue, oldMilestoneID int64)
 | 
						NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue, oldMilestoneID int64)
 | 
				
			||||||
	NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment)
 | 
						NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment)
 | 
				
			||||||
 | 
						NotifyPullRewiewRequest(doer *models.User, issue *models.Issue, reviewer *models.User, isRequest bool, comment *models.Comment)
 | 
				
			||||||
	NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string)
 | 
						NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string)
 | 
				
			||||||
	NotifyIssueClearLabels(doer *models.User, issue *models.Issue)
 | 
						NotifyIssueClearLabels(doer *models.User, issue *models.Issue)
 | 
				
			||||||
	NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string)
 | 
						NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,6 +86,10 @@ func (*NullNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.I
 | 
				
			|||||||
func (*NullNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment) {
 | 
					func (*NullNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NotifyPullRewiewRequest places a place holder function
 | 
				
			||||||
 | 
					func (*NullNotifier) NotifyPullRewiewRequest(doer *models.User, issue *models.Issue, reviewer *models.User, isRequest bool, comment *models.Comment) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NotifyIssueClearLabels places a place holder function
 | 
					// NotifyIssueClearLabels places a place holder function
 | 
				
			||||||
func (*NullNotifier) NotifyIssueClearLabels(doer *models.User, issue *models.Issue) {
 | 
					func (*NullNotifier) NotifyIssueClearLabels(doer *models.User, issue *models.Issue) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -100,6 +100,13 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *model
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m *mailNotifier) NotifyPullRewiewRequest(doer *models.User, issue *models.Issue, reviewer *models.User, isRequest bool, comment *models.Comment) {
 | 
				
			||||||
 | 
						if isRequest && doer.ID != reviewer.ID && reviewer.EmailNotifications() == models.EmailNotificationsEnabled {
 | 
				
			||||||
 | 
							ct := fmt.Sprintf("Requested to review #%d.", issue.Index)
 | 
				
			||||||
 | 
							mailer.SendIssueAssignedMail(issue, doer, ct, comment, []string{reviewer.Email})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
 | 
					func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
 | 
				
			||||||
	if err := pr.LoadIssue(); err != nil {
 | 
						if err := pr.LoadIssue(); err != nil {
 | 
				
			||||||
		log.Error("pr.LoadIssue: %v", err)
 | 
							log.Error("pr.LoadIssue: %v", err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -150,6 +150,13 @@ func NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NotifyPullRewiewRequest notifies Request Review change
 | 
				
			||||||
 | 
					func NotifyPullRewiewRequest(doer *models.User, issue *models.Issue, reviewer *models.User, isRequest bool, comment *models.Comment) {
 | 
				
			||||||
 | 
						for _, notifier := range notifiers {
 | 
				
			||||||
 | 
							notifier.NotifyPullRewiewRequest(doer, issue, reviewer, isRequest, comment)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NotifyIssueClearLabels notifies clear labels to notifiers
 | 
					// NotifyIssueClearLabels notifies clear labels to notifiers
 | 
				
			||||||
func NotifyIssueClearLabels(doer *models.User, issue *models.Issue) {
 | 
					func NotifyIssueClearLabels(doer *models.User, issue *models.Issue) {
 | 
				
			||||||
	for _, notifier := range notifiers {
 | 
						for _, notifier := range notifiers {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,7 @@ type (
 | 
				
			|||||||
		IssueID              int64
 | 
							IssueID              int64
 | 
				
			||||||
		CommentID            int64
 | 
							CommentID            int64
 | 
				
			||||||
		NotificationAuthorID int64
 | 
							NotificationAuthorID int64
 | 
				
			||||||
 | 
							ReceiverID           int64 // 0 -- ALL Watcher
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -39,7 +40,7 @@ func NewNotifier() base.Notifier {
 | 
				
			|||||||
func (ns *notificationService) handle(data ...queue.Data) {
 | 
					func (ns *notificationService) handle(data ...queue.Data) {
 | 
				
			||||||
	for _, datum := range data {
 | 
						for _, datum := range data {
 | 
				
			||||||
		opts := datum.(issueNotificationOpts)
 | 
							opts := datum.(issueNotificationOpts)
 | 
				
			||||||
		if err := models.CreateOrUpdateIssueNotifications(opts.IssueID, opts.CommentID, opts.NotificationAuthorID); err != nil {
 | 
							if err := models.CreateOrUpdateIssueNotifications(opts.IssueID, opts.CommentID, opts.NotificationAuthorID, opts.ReceiverID); err != nil {
 | 
				
			||||||
			log.Error("Was unable to create issue notification: %v", err)
 | 
								log.Error("Was unable to create issue notification: %v", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -103,3 +104,35 @@ func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	_ = ns.issueQueue.Push(opts)
 | 
						_ = ns.issueQueue.Push(opts)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (ns *notificationService) NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment) {
 | 
				
			||||||
 | 
						if !removed {
 | 
				
			||||||
 | 
							var opts = issueNotificationOpts{
 | 
				
			||||||
 | 
								IssueID:              issue.ID,
 | 
				
			||||||
 | 
								NotificationAuthorID: doer.ID,
 | 
				
			||||||
 | 
								ReceiverID:           assignee.ID,
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if comment != nil {
 | 
				
			||||||
 | 
								opts.CommentID = comment.ID
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							_ = ns.issueQueue.Push(opts)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (ns *notificationService) NotifyPullRewiewRequest(doer *models.User, issue *models.Issue, reviewer *models.User, isRequest bool, comment *models.Comment) {
 | 
				
			||||||
 | 
						if isRequest {
 | 
				
			||||||
 | 
							var opts = issueNotificationOpts{
 | 
				
			||||||
 | 
								IssueID:              issue.ID,
 | 
				
			||||||
 | 
								NotificationAuthorID: doer.ID,
 | 
				
			||||||
 | 
								ReceiverID:           reviewer.ID,
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if comment != nil {
 | 
				
			||||||
 | 
								opts.CommentID = comment.ID
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							_ = ns.issueQueue.Push(opts)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -827,6 +827,7 @@ issues.desc = Organize bug reports, tasks and milestones.
 | 
				
			|||||||
issues.filter_assignees = Filter Assignee
 | 
					issues.filter_assignees = Filter Assignee
 | 
				
			||||||
issues.filter_milestones = Filter Milestone
 | 
					issues.filter_milestones = Filter Milestone
 | 
				
			||||||
issues.filter_labels = Filter Label
 | 
					issues.filter_labels = Filter Label
 | 
				
			||||||
 | 
					issues.filter_reviewers = Filter Reviewer
 | 
				
			||||||
issues.new = New Issue
 | 
					issues.new = New Issue
 | 
				
			||||||
issues.new.title_empty = Title cannot be empty
 | 
					issues.new.title_empty = Title cannot be empty
 | 
				
			||||||
issues.new.labels = Labels
 | 
					issues.new.labels = Labels
 | 
				
			||||||
@@ -844,6 +845,8 @@ issues.new.assignees = Assignees
 | 
				
			|||||||
issues.new.add_assignees_title = Assign users
 | 
					issues.new.add_assignees_title = Assign users
 | 
				
			||||||
issues.new.clear_assignees = Clear assignees
 | 
					issues.new.clear_assignees = Clear assignees
 | 
				
			||||||
issues.new.no_assignees = No Assignees
 | 
					issues.new.no_assignees = No Assignees
 | 
				
			||||||
 | 
					issues.new.no_reviewers = No reviewers
 | 
				
			||||||
 | 
					issues.new.add_reviewer_title = Request review
 | 
				
			||||||
issues.no_ref = No Branch/Tag Specified
 | 
					issues.no_ref = No Branch/Tag Specified
 | 
				
			||||||
issues.create = Create Issue
 | 
					issues.create = Create Issue
 | 
				
			||||||
issues.new_label = New Label
 | 
					issues.new_label = New Label
 | 
				
			||||||
@@ -937,6 +940,9 @@ issues.ref_from = `from %[1]s`
 | 
				
			|||||||
issues.poster = Poster
 | 
					issues.poster = Poster
 | 
				
			||||||
issues.collaborator = Collaborator
 | 
					issues.collaborator = Collaborator
 | 
				
			||||||
issues.owner = Owner
 | 
					issues.owner = Owner
 | 
				
			||||||
 | 
					issues.re_request_review=Re-request review
 | 
				
			||||||
 | 
					issues.remove_request_review=Remove review request
 | 
				
			||||||
 | 
					issues.remove_request_review_block=Can't remove review request
 | 
				
			||||||
issues.sign_in_require_desc = <a href="%s">Sign in</a> to join this conversation.
 | 
					issues.sign_in_require_desc = <a href="%s">Sign in</a> to join this conversation.
 | 
				
			||||||
issues.edit = Edit
 | 
					issues.edit = Edit
 | 
				
			||||||
issues.cancel = Cancel
 | 
					issues.cancel = Cancel
 | 
				
			||||||
@@ -1048,6 +1054,10 @@ issues.review.approve = "approved these changes %s"
 | 
				
			|||||||
issues.review.comment = "reviewed %s"
 | 
					issues.review.comment = "reviewed %s"
 | 
				
			||||||
issues.review.content.empty = You need to leave a comment indicating the requested change(s).
 | 
					issues.review.content.empty = You need to leave a comment indicating the requested change(s).
 | 
				
			||||||
issues.review.reject = "requested changes %s"
 | 
					issues.review.reject = "requested changes %s"
 | 
				
			||||||
 | 
					issues.review.wait = "was requested for review %s"
 | 
				
			||||||
 | 
					issues.review.add_review_request = "requested review from %s %s"
 | 
				
			||||||
 | 
					issues.review.remove_review_request = "removed review request for %s %s"
 | 
				
			||||||
 | 
					issues.review.remove_review_request_self = "refused to review %s"
 | 
				
			||||||
issues.review.pending = Pending
 | 
					issues.review.pending = Pending
 | 
				
			||||||
issues.review.review = Review
 | 
					issues.review.review = Review
 | 
				
			||||||
issues.review.reviewers = Reviewers
 | 
					issues.review.reviewers = Reviewers
 | 
				
			||||||
@@ -1096,6 +1106,8 @@ pulls.approve_count_1 = "%d approval"
 | 
				
			|||||||
pulls.approve_count_n = "%d approvals"
 | 
					pulls.approve_count_n = "%d approvals"
 | 
				
			||||||
pulls.reject_count_1 = "%d change request"
 | 
					pulls.reject_count_1 = "%d change request"
 | 
				
			||||||
pulls.reject_count_n = "%d change requests"
 | 
					pulls.reject_count_n = "%d change requests"
 | 
				
			||||||
 | 
					pulls.waiting_count_1 = "%d waiting review"
 | 
				
			||||||
 | 
					pulls.waiting_count_n = "%d waiting reviews"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled.
 | 
					pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled.
 | 
				
			||||||
pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually.
 | 
					pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -289,6 +289,8 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB
 | 
				
			|||||||
		reviewTyp := models.ReviewTypeApprove
 | 
							reviewTyp := models.ReviewTypeApprove
 | 
				
			||||||
		if typ == "reject" {
 | 
							if typ == "reject" {
 | 
				
			||||||
			reviewTyp = models.ReviewTypeReject
 | 
								reviewTyp = models.ReviewTypeReject
 | 
				
			||||||
 | 
							} else if typ == "waiting" {
 | 
				
			||||||
 | 
								reviewTyp = models.ReviewTypeRequest
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for _, count := range counts {
 | 
							for _, count := range counts {
 | 
				
			||||||
			if count.Type == reviewTyp {
 | 
								if count.Type == reviewTyp {
 | 
				
			||||||
@@ -377,6 +379,16 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repos
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// RetrieveRepoReviewers find all reviewers of a repository
 | 
				
			||||||
 | 
					func RetrieveRepoReviewers(ctx *context.Context, repo *models.Repository, issuePosterID int64) {
 | 
				
			||||||
 | 
						var err error
 | 
				
			||||||
 | 
						ctx.Data["Reviewers"], err = repo.GetReviewers(ctx.User.ID, issuePosterID)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							ctx.ServerError("GetReviewers", err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RetrieveRepoMetas find all the meta information of a repository
 | 
					// RetrieveRepoMetas find all the meta information of a repository
 | 
				
			||||||
func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository, isPull bool) []*models.Label {
 | 
					func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository, isPull bool) []*models.Label {
 | 
				
			||||||
	if !ctx.Repo.CanWriteIssuesOrPulls(isPull) {
 | 
						if !ctx.Repo.CanWriteIssuesOrPulls(isPull) {
 | 
				
			||||||
@@ -815,6 +827,28 @@ func ViewIssue(ctx *context.Context) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if issue.IsPull {
 | 
				
			||||||
 | 
							canChooseReviewer := ctx.Repo.CanWrite(models.UnitTypePullRequests)
 | 
				
			||||||
 | 
							if !canChooseReviewer && ctx.User != nil && ctx.IsSigned {
 | 
				
			||||||
 | 
								canChooseReviewer, err = models.IsOfficialReviewer(issue, ctx.User)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									ctx.ServerError("IsOfficialReviewer", err)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if canChooseReviewer {
 | 
				
			||||||
 | 
								RetrieveRepoReviewers(ctx, repo, issue.PosterID)
 | 
				
			||||||
 | 
								ctx.Data["CanChooseReviewer"] = true
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								ctx.Data["CanChooseReviewer"] = false
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if ctx.Written() {
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ctx.IsSigned {
 | 
						if ctx.IsSigned {
 | 
				
			||||||
		// Update issue-user.
 | 
							// Update issue-user.
 | 
				
			||||||
		if err = issue.ReadBy(ctx.User.ID); err != nil {
 | 
							if err = issue.ReadBy(ctx.User.ID); err != nil {
 | 
				
			||||||
@@ -926,7 +960,7 @@ func ViewIssue(ctx *context.Context) {
 | 
				
			|||||||
			if comment.MilestoneID > 0 && comment.Milestone == nil {
 | 
								if comment.MilestoneID > 0 && comment.Milestone == nil {
 | 
				
			||||||
				comment.Milestone = ghostMilestone
 | 
									comment.Milestone = ghostMilestone
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else if comment.Type == models.CommentTypeAssignees {
 | 
							} else if comment.Type == models.CommentTypeAssignees || comment.Type == models.CommentTypeReviewRequest {
 | 
				
			||||||
			if err = comment.LoadAssigneeUser(); err != nil {
 | 
								if err = comment.LoadAssigneeUser(); err != nil {
 | 
				
			||||||
				ctx.ServerError("LoadAssigneeUser", err)
 | 
									ctx.ServerError("LoadAssigneeUser", err)
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
@@ -1273,6 +1307,122 @@ func UpdateIssueAssignee(ctx *context.Context) {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func isLegalReviewRequest(reviewer, doer *models.User, isAdd bool, issue *models.Issue) error {
 | 
				
			||||||
 | 
						if reviewer.IsOrganization() {
 | 
				
			||||||
 | 
							return fmt.Errorf("Organization can't be added as reviewer [user_id: %d, repo_id: %d]", reviewer.ID, issue.PullRequest.BaseRepo.ID)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if doer.IsOrganization() {
 | 
				
			||||||
 | 
							return fmt.Errorf("Organization can't be doer to add reviewer [user_id: %d, repo_id: %d]", doer.ID, issue.PullRequest.BaseRepo.ID)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						permReviewer, err := models.GetUserRepoPermission(issue.Repo, reviewer)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						permDoer, err := models.GetUserRepoPermission(issue.Repo, doer)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						lastreview, err := models.GetReviewerByIssueIDAndUserID(issue.ID, reviewer.ID)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var pemResult bool
 | 
				
			||||||
 | 
						if isAdd {
 | 
				
			||||||
 | 
							pemResult = permReviewer.CanAccessAny(models.AccessModeRead, models.UnitTypePullRequests)
 | 
				
			||||||
 | 
							if !pemResult {
 | 
				
			||||||
 | 
								return fmt.Errorf("Reviewer can't read [user_id: %d, repo_name: %s]", reviewer.ID, issue.Repo.Name)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if doer.ID == issue.PosterID && lastreview != nil && lastreview.Type != models.ReviewTypeRequest {
 | 
				
			||||||
 | 
								return nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							pemResult = permDoer.CanAccessAny(models.AccessModeWrite, models.UnitTypePullRequests)
 | 
				
			||||||
 | 
							if !pemResult {
 | 
				
			||||||
 | 
								pemResult, err = models.IsOfficialReviewer(issue, doer)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if !pemResult {
 | 
				
			||||||
 | 
									return fmt.Errorf("Doer can't choose reviewer [user_id: %d, repo_name: %s, issue_id: %d]", doer.ID, issue.Repo.Name, issue.ID)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if doer.ID == reviewer.ID {
 | 
				
			||||||
 | 
								return fmt.Errorf("doer can't be reviewer [user_id: %d, repo_name: %s]", doer.ID, issue.Repo.Name)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if reviewer.ID == issue.PosterID {
 | 
				
			||||||
 | 
								return fmt.Errorf("poster of pr can't be reviewer [user_id: %d, repo_name: %s]", reviewer.ID, issue.Repo.Name)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							if lastreview.Type == models.ReviewTypeRequest && lastreview.ReviewerID == doer.ID {
 | 
				
			||||||
 | 
								return nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							pemResult = permDoer.IsAdmin()
 | 
				
			||||||
 | 
							if !pemResult {
 | 
				
			||||||
 | 
								return fmt.Errorf("Doer is not admin [user_id: %d, repo_name: %s]", doer.ID, issue.Repo.Name)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// updatePullReviewRequest change pull's request reviewers
 | 
				
			||||||
 | 
					func updatePullReviewRequest(ctx *context.Context) {
 | 
				
			||||||
 | 
						issues := getActionIssues(ctx)
 | 
				
			||||||
 | 
						if ctx.Written() {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						reviewID := ctx.QueryInt64("id")
 | 
				
			||||||
 | 
						event := ctx.Query("is_add")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if event != "add" && event != "remove" {
 | 
				
			||||||
 | 
							ctx.ServerError("updatePullReviewRequest", fmt.Errorf("is_add should not be \"%s\"", event))
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, issue := range issues {
 | 
				
			||||||
 | 
							if issue.IsPull {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								reviewer, err := models.GetUserByID(reviewID)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									ctx.ServerError("GetUserByID", err)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								err = isLegalReviewRequest(reviewer, ctx.User, event == "add", issue)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									ctx.ServerError("isLegalRequestReview", err)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								err = issue_service.ReviewRequest(issue, ctx.User, reviewer, event == "add")
 | 
				
			||||||
 | 
								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.JSON(200, map[string]interface{}{
 | 
				
			||||||
 | 
							"ok": true,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// UpdatePullReviewRequest add or remove review request
 | 
				
			||||||
 | 
					func UpdatePullReviewRequest(ctx *context.Context) {
 | 
				
			||||||
 | 
						updatePullReviewRequest(ctx)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateIssueStatus change issue's status
 | 
					// UpdateIssueStatus change issue's status
 | 
				
			||||||
func UpdateIssueStatus(ctx *context.Context) {
 | 
					func UpdateIssueStatus(ctx *context.Context) {
 | 
				
			||||||
	issues := getActionIssues(ctx)
 | 
						issues := getActionIssues(ctx)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -738,6 +738,7 @@ func RegisterRoutes(m *macaron.Macaron) {
 | 
				
			|||||||
			m.Post("/labels", reqRepoIssuesOrPullsWriter, repo.UpdateIssueLabel)
 | 
								m.Post("/labels", reqRepoIssuesOrPullsWriter, repo.UpdateIssueLabel)
 | 
				
			||||||
			m.Post("/milestone", reqRepoIssuesOrPullsWriter, repo.UpdateIssueMilestone)
 | 
								m.Post("/milestone", reqRepoIssuesOrPullsWriter, repo.UpdateIssueMilestone)
 | 
				
			||||||
			m.Post("/assignee", reqRepoIssuesOrPullsWriter, repo.UpdateIssueAssignee)
 | 
								m.Post("/assignee", reqRepoIssuesOrPullsWriter, repo.UpdateIssueAssignee)
 | 
				
			||||||
 | 
								m.Post("/request_review", reqRepoIssuesOrPullsReader, repo.UpdatePullReviewRequest)
 | 
				
			||||||
			m.Post("/status", reqRepoIssuesOrPullsWriter, repo.UpdateIssueStatus)
 | 
								m.Post("/status", reqRepoIssuesOrPullsWriter, repo.UpdateIssueStatus)
 | 
				
			||||||
		}, context.RepoMustNotBeArchived())
 | 
							}, context.RepoMustNotBeArchived())
 | 
				
			||||||
		m.Group("/comments/:id", func() {
 | 
							m.Group("/comments/:id", func() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -632,6 +632,8 @@ func Issues(ctx *context.Context) {
 | 
				
			|||||||
		reviewTyp := models.ReviewTypeApprove
 | 
							reviewTyp := models.ReviewTypeApprove
 | 
				
			||||||
		if typ == "reject" {
 | 
							if typ == "reject" {
 | 
				
			||||||
			reviewTyp = models.ReviewTypeReject
 | 
								reviewTyp = models.ReviewTypeReject
 | 
				
			||||||
 | 
							} else if typ == "waiting" {
 | 
				
			||||||
 | 
								reviewTyp = models.ReviewTypeRequest
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for _, count := range counts {
 | 
							for _, count := range counts {
 | 
				
			||||||
			if count.Type == reviewTyp {
 | 
								if count.Type == reviewTyp {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,3 +51,23 @@ func ToggleAssignee(issue *models.Issue, doer *models.User, assigneeID int64) (r
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ReviewRequest add or remove a review for this PR, and make comment for it.
 | 
				
			||||||
 | 
					func ReviewRequest(issue *models.Issue, doer *models.User, reviewer *models.User, isAdd bool) (err error) {
 | 
				
			||||||
 | 
						var comment *models.Comment
 | 
				
			||||||
 | 
						if isAdd {
 | 
				
			||||||
 | 
							comment, err = models.AddRewiewRequest(issue, reviewer, doer)
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							comment, err = models.RemoveRewiewRequest(issue, reviewer, doer)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if comment != nil {
 | 
				
			||||||
 | 
							notification.NotifyPullRewiewRequest(doer, issue, reviewer, isAdd, comment)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -271,14 +271,25 @@
 | 
				
			|||||||
						{{if .IsPull}}
 | 
											{{if .IsPull}}
 | 
				
			||||||
							{{$approveOfficial := call $approvalCounts .ID "approve"}}
 | 
												{{$approveOfficial := call $approvalCounts .ID "approve"}}
 | 
				
			||||||
							{{$rejectOfficial := call $approvalCounts .ID "reject"}}
 | 
												{{$rejectOfficial := call $approvalCounts .ID "reject"}}
 | 
				
			||||||
							{{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}}
 | 
												{{$waitingOfficial := call $approvalCounts .ID "waiting"}}
 | 
				
			||||||
 | 
												{{if gt $approveOfficial 0}}
 | 
				
			||||||
								<span class="approvals">{{svg "octicon-check" 16}}
 | 
													<span class="approvals">{{svg "octicon-check" 16}}
 | 
				
			||||||
									{{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}}
 | 
														{{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}}
 | 
				
			||||||
								{{if or (gt $rejectOfficial 0)}}
 | 
													</span>
 | 
				
			||||||
									<span class="rejects">{{svg "octicon-x" 16}}
 | 
					 | 
				
			||||||
										{{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}}
 | 
					 | 
				
			||||||
								{{end}}
 | 
					 | 
				
			||||||
							{{end}}
 | 
												{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												{{if gt $rejectOfficial 0}}
 | 
				
			||||||
 | 
													<span class="rejects">{{svg "octicon-request-changes" 16}}
 | 
				
			||||||
 | 
														{{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}}
 | 
				
			||||||
 | 
													</span>
 | 
				
			||||||
 | 
												{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												{{if gt $waitingOfficial 0}}
 | 
				
			||||||
 | 
													<span class="waiting">{{svg "octicon-eye" 16}}
 | 
				
			||||||
 | 
														{{$.i18n.Tr (TrN $.i18n.Lang $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n") $waitingOfficial}}
 | 
				
			||||||
 | 
													</span>
 | 
				
			||||||
 | 
												{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}}
 | 
												{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}}
 | 
				
			||||||
								<span class="conflicting">{{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)}}</span>
 | 
													<span class="conflicting">{{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)}}</span>
 | 
				
			||||||
							{{end}}
 | 
												{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -241,14 +241,25 @@
 | 
				
			|||||||
						{{if .IsPull}}
 | 
											{{if .IsPull}}
 | 
				
			||||||
							{{$approveOfficial := call $approvalCounts .ID "approve"}}
 | 
												{{$approveOfficial := call $approvalCounts .ID "approve"}}
 | 
				
			||||||
							{{$rejectOfficial := call $approvalCounts .ID "reject"}}
 | 
												{{$rejectOfficial := call $approvalCounts .ID "reject"}}
 | 
				
			||||||
							{{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}}
 | 
												{{$waitingOfficial := call $approvalCounts .ID "waiting"}}
 | 
				
			||||||
 | 
												{{if gt $approveOfficial 0}}
 | 
				
			||||||
								<span class="approvals">{{svg "octicon-check" 16}}
 | 
													<span class="approvals">{{svg "octicon-check" 16}}
 | 
				
			||||||
									{{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}}
 | 
														{{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}}
 | 
				
			||||||
								{{if or (gt $rejectOfficial 0)}}
 | 
													</span>
 | 
				
			||||||
									<span class="rejects">{{svg "octicon-x" 16}}
 | 
					 | 
				
			||||||
										{{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}}
 | 
					 | 
				
			||||||
								{{end}}
 | 
					 | 
				
			||||||
							{{end}}
 | 
												{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												{{if gt $rejectOfficial 0}}
 | 
				
			||||||
 | 
													<span class="rejects">{{svg "octicon-request-changes" 16}}
 | 
				
			||||||
 | 
														{{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}}
 | 
				
			||||||
 | 
													</span>
 | 
				
			||||||
 | 
												{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												{{if gt $waitingOfficial 0}}
 | 
				
			||||||
 | 
													<span class="waiting">{{svg "octicon-eye" 16}}
 | 
				
			||||||
 | 
														{{$.i18n.Tr (TrN $.i18n.Lang $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n") $waitingOfficial}}
 | 
				
			||||||
 | 
													</span>
 | 
				
			||||||
 | 
												{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}}
 | 
												{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}}
 | 
				
			||||||
								<span class="conflicting">{{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)}}</span>
 | 
													<span class="conflicting">{{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)}}</span>
 | 
				
			||||||
							{{end}}
 | 
												{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@
 | 
				
			|||||||
	 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE,
 | 
						 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE,
 | 
				
			||||||
	 18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE,
 | 
						 18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE,
 | 
				
			||||||
	 22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED, 25 = TARGET_BRANCH_CHANGED,
 | 
						 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 eq .Type 0}}
 | 
				
			||||||
		<div class="comment" id="{{.HashTag}}">
 | 
							<div class="comment" id="{{.HashTag}}">
 | 
				
			||||||
		{{if .OriginalAuthor }}
 | 
							{{if .OriginalAuthor }}
 | 
				
			||||||
@@ -468,5 +468,25 @@
 | 
				
			|||||||
				<span class="text grey">{{.Content}}</span>
 | 
									<span class="text grey">{{.Content}}</span>
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
 | 
						{{else if eq .Type 27}}
 | 
				
			||||||
 | 
							<div class="event" id="{{.HashTag}}">
 | 
				
			||||||
 | 
								<span class="issue-symbol">{{svg "octicon-eye" 16}}</span>
 | 
				
			||||||
 | 
								<a class="ui avatar image" href="{{.Poster.HomeLink}}">
 | 
				
			||||||
 | 
									<img src="{{.Poster.RelAvatarLink}}">
 | 
				
			||||||
 | 
								</a>
 | 
				
			||||||
 | 
								<span class="text grey">
 | 
				
			||||||
 | 
									<a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a>
 | 
				
			||||||
 | 
									{{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}}
 | 
				
			||||||
 | 
								</span>
 | 
				
			||||||
 | 
							</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{{end}}
 | 
						{{end}}
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,25 @@
 | 
				
			|||||||
						<span class="type-icon text {{if eq .Type 1}}green
 | 
											<span class="type-icon text {{if eq .Type 1}}green
 | 
				
			||||||
							{{- else if eq .Type 2}}grey
 | 
												{{- else if eq .Type 2}}grey
 | 
				
			||||||
							{{- else if eq .Type 3}}red
 | 
												{{- else if eq .Type 3}}red
 | 
				
			||||||
							{{- else}}grey{{end}}">
 | 
												{{- 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 }}
 | 
				
			||||||
 | 
													<a href="#" class="ui poping up icon re-request-review" data-is-checked="{{if  eq .Type 4}}remove{{else}}add{{end}}" data-issue-id="{{$.Issue.ID}}" data-content="{{ if eq .Type 4 }} {{$.i18n.Tr "repo.issues.remove_request_review"}} {{else}} {{$.i18n.Tr "repo.issues.re_request_review"}} {{end}}"  data-id="{{.ReviewerID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
 | 
				
			||||||
 | 
														{{svg "octicon-sync" 16}}
 | 
				
			||||||
 | 
													</a>
 | 
				
			||||||
 | 
												{{end}}
 | 
				
			||||||
							{{svg (printf "octicon-%s" .Type.Icon) 16}}
 | 
												{{svg (printf "octicon-%s" .Type.Icon) 16}}
 | 
				
			||||||
						</span>
 | 
											</span>
 | 
				
			||||||
						{{if .Stale}}
 | 
											{{if .Stale}}
 | 
				
			||||||
@@ -28,6 +46,8 @@
 | 
				
			|||||||
								{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
 | 
													{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
 | 
				
			||||||
							{{else if eq .Type 3}}
 | 
												{{else if eq .Type 3}}
 | 
				
			||||||
								{{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
 | 
													{{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
 | 
				
			||||||
 | 
												{{else if eq .Type 4}}
 | 
				
			||||||
 | 
													{{$.i18n.Tr "repo.issues.review.wait" $createdStr | Safe}}
 | 
				
			||||||
							{{else}}
 | 
												{{else}}
 | 
				
			||||||
								{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
 | 
													{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
 | 
				
			||||||
							{{end}}
 | 
												{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,97 @@
 | 
				
			|||||||
	<div class="ui segment metas">
 | 
						<div class="ui segment metas">
 | 
				
			||||||
		{{template "repo/issue/branch_selector_field" .}}
 | 
							{{template "repo/issue/branch_selector_field" .}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							{{if .Issue.IsPull }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<input id="reviewer_id" name="reviewer_id" type="hidden" value="{{.reviewer_id}}">
 | 
				
			||||||
 | 
							<div class="ui {{if or (not .CanChooseReviewer) .Repository.IsArchived}}disabled{{end}} floating jump select-reviewers-modify dropdown">
 | 
				
			||||||
 | 
								<span class="text">
 | 
				
			||||||
 | 
									<strong>{{.i18n.Tr "repo.issues.review.reviewers"}}</strong>
 | 
				
			||||||
 | 
									{{if and .CanChooseReviewer (not .Repository.IsArchived)}}
 | 
				
			||||||
 | 
										{{svg "octicon-gear" 16}}
 | 
				
			||||||
 | 
									{{end}}
 | 
				
			||||||
 | 
								</span>
 | 
				
			||||||
 | 
								<div class="filter menu" data-action="" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
 | 
				
			||||||
 | 
									<div class="header" style="text-transform: none;font-size:16px;">{{.i18n.Tr "repo.issues.new.add_reviewer_title"}}</div>
 | 
				
			||||||
 | 
									{{if .Reviewers}}
 | 
				
			||||||
 | 
										<div class="ui icon search input">
 | 
				
			||||||
 | 
											<i class="search icon"></i>
 | 
				
			||||||
 | 
											<input type="text" placeholder="{{.i18n.Tr "repo.issues.filter_reviewers"}}">
 | 
				
			||||||
 | 
										</div>
 | 
				
			||||||
 | 
									{{end}}
 | 
				
			||||||
 | 
									{{range .Reviewers}}
 | 
				
			||||||
 | 
										{{$ReviewerID := .ID}}
 | 
				
			||||||
 | 
										{{$checked := false}}
 | 
				
			||||||
 | 
										{{$canChoose := false}}
 | 
				
			||||||
 | 
										{{$notReviewed := true}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										{{range $.PullReviewers}}
 | 
				
			||||||
 | 
											{{if eq .ReviewerID $ReviewerID }}
 | 
				
			||||||
 | 
												{{$notReviewed = false }} 
 | 
				
			||||||
 | 
												{{if  eq .Type 4 }}
 | 
				
			||||||
 | 
													{{$checked = true}}
 | 
				
			||||||
 | 
													{{if or (eq $ReviewerID $.SignedUserID) $.Permission.IsAdmin}}
 | 
				
			||||||
 | 
														{{$canChoose = true}}
 | 
				
			||||||
 | 
													{{end}}
 | 
				
			||||||
 | 
												{{else}}
 | 
				
			||||||
 | 
													{{$canChoose = true}}
 | 
				
			||||||
 | 
												{{end}}
 | 
				
			||||||
 | 
											{{end}}
 | 
				
			||||||
 | 
										{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										{{ if $notReviewed}}
 | 
				
			||||||
 | 
											{{$canChoose = true}}
 | 
				
			||||||
 | 
										{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										<a class="{{if not $canChoose}}ui poping up{{end}} item {{if $checked}} checked {{end}}" href="#" data-id="{{.ID}}" data-id-selector="#review_request_{{.ID}}" data-can-change="{{if not $canChoose}}block{{end}}" {{if not $canChoose}} data-content="{{$.i18n.Tr "repo.issues.remove_request_review_block"}}"{{end}} data-is-checked="{{if $checked}}add{{else}}remove{{end}}">
 | 
				
			||||||
 | 
											<span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check" 16}}</span>
 | 
				
			||||||
 | 
											<span class="text">
 | 
				
			||||||
 | 
												<img class="ui avatar image" src="{{.RelAvatarLink}}"> {{.GetDisplayName}}
 | 
				
			||||||
 | 
											</span>
 | 
				
			||||||
 | 
										</a>
 | 
				
			||||||
 | 
									{{end}}
 | 
				
			||||||
 | 
								</div>
 | 
				
			||||||
 | 
							</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<div class="ui assignees list">
 | 
				
			||||||
 | 
								<span class="no-select item {{if .PullReviewers}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_reviewers"}}</span>
 | 
				
			||||||
 | 
								<div class="selected">
 | 
				
			||||||
 | 
									{{range .PullReviewers}}
 | 
				
			||||||
 | 
										<div class="item" style="margin-bottom: 10px;">
 | 
				
			||||||
 | 
											<a href="{{.Reviewer.HomeLink}}"><img class="ui avatar image" src="{{.Reviewer.RelAvatarLink}}"> {{.Reviewer.GetDisplayName}}</a>
 | 
				
			||||||
 | 
											<span class="ui right type-icon text {{if eq .Type 1}}green
 | 
				
			||||||
 | 
												{{- else if eq .Type 2}}grey
 | 
				
			||||||
 | 
												{{- else if eq .Type 3}}red
 | 
				
			||||||
 | 
												{{- else if eq .Type 4}}yellow
 | 
				
			||||||
 | 
												{{- else}}grey{{end}} right ">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												{{$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}}
 | 
				
			||||||
 | 
													<a href="#" class="ui poping up icon re-request-review" data-is-checked="{{if  eq .Type 4}}remove{{else}}add{{end}}" data-content="{{ if eq .Type 4 }} {{$.i18n.Tr "repo.issues.remove_request_review"}} {{else}} {{$.i18n.Tr "repo.issues.re_request_review"}} {{end}}" data-issue-id="{{$.Issue.ID}}"  data-id="{{.ReviewerID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
 | 
				
			||||||
 | 
														{{svg "octicon-sync" 16}}
 | 
				
			||||||
 | 
													</a>
 | 
				
			||||||
 | 
												{{end}}
 | 
				
			||||||
 | 
												{{svg (printf "octicon-%s" .Type.Icon) 16}}
 | 
				
			||||||
 | 
											</span>
 | 
				
			||||||
 | 
										</div>
 | 
				
			||||||
 | 
									{{end}}
 | 
				
			||||||
 | 
								</div>
 | 
				
			||||||
 | 
							</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<div class="ui divider"></div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown">
 | 
							<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown">
 | 
				
			||||||
			<span class="text">
 | 
								<span class="text">
 | 
				
			||||||
				<strong>{{.i18n.Tr "repo.issues.new.labels"}}</strong>
 | 
									<strong>{{.i18n.Tr "repo.issues.new.labels"}}</strong>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -173,14 +173,25 @@
 | 
				
			|||||||
								{{if .IsPull}}
 | 
													{{if .IsPull}}
 | 
				
			||||||
									{{$approveOfficial := call $approvalCounts .ID "approve"}}
 | 
														{{$approveOfficial := call $approvalCounts .ID "approve"}}
 | 
				
			||||||
									{{$rejectOfficial := call $approvalCounts .ID "reject"}}
 | 
														{{$rejectOfficial := call $approvalCounts .ID "reject"}}
 | 
				
			||||||
									{{if or (gt $approveOfficial 0) (gt $rejectOfficial 0) }}
 | 
														{{$waitingOfficial := call $approvalCounts .ID "waiting"}}
 | 
				
			||||||
 | 
														{{if gt $approveOfficial 0}}
 | 
				
			||||||
										<span class="approvals">{{svg "octicon-check" 16}}
 | 
															<span class="approvals">{{svg "octicon-check" 16}}
 | 
				
			||||||
											{{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}}
 | 
																{{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}}
 | 
				
			||||||
										{{if or (gt $rejectOfficial 0)}}
 | 
															</span>
 | 
				
			||||||
											<span class="rejects">{{svg "octicon-x" 16}}
 | 
					 | 
				
			||||||
												{{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}}
 | 
					 | 
				
			||||||
										{{end}}
 | 
					 | 
				
			||||||
									{{end}}
 | 
														{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
														{{if gt $rejectOfficial 0}}
 | 
				
			||||||
 | 
															<span class="rejects">{{svg "octicon-request-changes" 16}}
 | 
				
			||||||
 | 
																{{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}}
 | 
				
			||||||
 | 
															</span>
 | 
				
			||||||
 | 
														{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
														{{if gt $waitingOfficial 0}}
 | 
				
			||||||
 | 
															<span class="waiting">{{svg "octicon-eye" 16}}
 | 
				
			||||||
 | 
																{{$.i18n.Tr (TrN $.i18n.Lang $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n") $waitingOfficial}}
 | 
				
			||||||
 | 
															</span>
 | 
				
			||||||
 | 
														{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
									{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}}
 | 
														{{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}}
 | 
				
			||||||
										<span class="conflicting">{{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)}}</span>
 | 
															<span class="conflicting">{{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)}}</span>
 | 
				
			||||||
									{{end}}
 | 
														{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,7 +158,7 @@ function initLabelEdit() {
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function updateIssuesMeta(url, action, issueIds, elementId) {
 | 
					function updateIssuesMeta(url, action, issueIds, elementId, isAdd) {
 | 
				
			||||||
  return new Promise(((resolve) => {
 | 
					  return new Promise(((resolve) => {
 | 
				
			||||||
    $.ajax({
 | 
					    $.ajax({
 | 
				
			||||||
      type: 'POST',
 | 
					      type: 'POST',
 | 
				
			||||||
@@ -167,7 +167,8 @@ function updateIssuesMeta(url, action, issueIds, elementId) {
 | 
				
			|||||||
        _csrf: csrf,
 | 
					        _csrf: csrf,
 | 
				
			||||||
        action,
 | 
					        action,
 | 
				
			||||||
        issue_ids: issueIds,
 | 
					        issue_ids: issueIds,
 | 
				
			||||||
        id: elementId
 | 
					        id: elementId,
 | 
				
			||||||
 | 
					        is_add: isAdd
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      success: resolve
 | 
					      success: resolve
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@@ -390,7 +391,8 @@ function initCommentForm() {
 | 
				
			|||||||
            label['update-url'],
 | 
					            label['update-url'],
 | 
				
			||||||
            label.action,
 | 
					            label.action,
 | 
				
			||||||
            label['issue-id'],
 | 
					            label['issue-id'],
 | 
				
			||||||
            elementId
 | 
					            elementId,
 | 
				
			||||||
 | 
					            label['is-checked']
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
          promises.push(promise);
 | 
					          promises.push(promise);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@@ -400,22 +402,30 @@ function initCommentForm() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    $listMenu.find('.item:not(.no-select)').click(function () {
 | 
					    $listMenu.find('.item:not(.no-select)').click(function () {
 | 
				
			||||||
      // we don't need the action attribute when updating assignees
 | 
					      // we don't need the action attribute when updating assignees
 | 
				
			||||||
      if (selector === 'select-assignees-modify') {
 | 
					      if (selector === 'select-assignees-modify' || selector === 'select-reviewers-modify') {
 | 
				
			||||||
        // UI magic. We need to do this here, otherwise it would destroy the functionality of
 | 
					        // UI magic. We need to do this here, otherwise it would destroy the functionality of
 | 
				
			||||||
        // adding/removing labels
 | 
					        // adding/removing labels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($(this).data('can-change') === 'block') {
 | 
				
			||||||
 | 
					          return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($(this).hasClass('checked')) {
 | 
					        if ($(this).hasClass('checked')) {
 | 
				
			||||||
          $(this).removeClass('checked');
 | 
					          $(this).removeClass('checked');
 | 
				
			||||||
          $(this).find('.octicon-check').addClass('invisible');
 | 
					          $(this).find('.octicon-check').addClass('invisible');
 | 
				
			||||||
 | 
					          $(this).data('is-checked', 'remove');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          $(this).addClass('checked');
 | 
					          $(this).addClass('checked');
 | 
				
			||||||
          $(this).find('.octicon-check').removeClass('invisible');
 | 
					          $(this).find('.octicon-check').removeClass('invisible');
 | 
				
			||||||
 | 
					          $(this).data('is-checked', 'add');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        updateIssuesMeta(
 | 
					        updateIssuesMeta(
 | 
				
			||||||
          $listMenu.data('update-url'),
 | 
					          $listMenu.data('update-url'),
 | 
				
			||||||
          '',
 | 
					          '',
 | 
				
			||||||
          $listMenu.data('issue-id'),
 | 
					          $listMenu.data('issue-id'),
 | 
				
			||||||
          $(this).data('id')
 | 
					          $(this).data('id'),
 | 
				
			||||||
 | 
					          $(this).data('is-checked')
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        $listMenu.data('action', 'update'); // Update to reload the page when we updated items
 | 
					        $listMenu.data('action', 'update'); // Update to reload the page when we updated items
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
@@ -474,6 +484,7 @@ function initCommentForm() {
 | 
				
			|||||||
          $listMenu.data('update-url'),
 | 
					          $listMenu.data('update-url'),
 | 
				
			||||||
          'clear',
 | 
					          'clear',
 | 
				
			||||||
          $listMenu.data('issue-id'),
 | 
					          $listMenu.data('issue-id'),
 | 
				
			||||||
 | 
					          '',
 | 
				
			||||||
          ''
 | 
					          ''
 | 
				
			||||||
        ).then(reload);
 | 
					        ).then(reload);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -481,6 +492,7 @@ function initCommentForm() {
 | 
				
			|||||||
      $(this).parent().find('.item').each(function () {
 | 
					      $(this).parent().find('.item').each(function () {
 | 
				
			||||||
        $(this).removeClass('checked');
 | 
					        $(this).removeClass('checked');
 | 
				
			||||||
        $(this).find('.octicon').addClass('invisible');
 | 
					        $(this).find('.octicon').addClass('invisible');
 | 
				
			||||||
 | 
					        $(this).data('is-checked', 'remove');
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $list.find('.item').each(function () {
 | 
					      $list.find('.item').each(function () {
 | 
				
			||||||
@@ -495,6 +507,7 @@ function initCommentForm() {
 | 
				
			|||||||
  initListSubmits('select-label', 'labels');
 | 
					  initListSubmits('select-label', 'labels');
 | 
				
			||||||
  initListSubmits('select-assignees', 'assignees');
 | 
					  initListSubmits('select-assignees', 'assignees');
 | 
				
			||||||
  initListSubmits('select-assignees-modify', 'assignees');
 | 
					  initListSubmits('select-assignees-modify', 'assignees');
 | 
				
			||||||
 | 
					  initListSubmits('select-reviewers-modify', 'assignees');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function selectItem(select_id, input_id) {
 | 
					  function selectItem(select_id, input_id) {
 | 
				
			||||||
    const $menu = $(`${select_id} .menu`);
 | 
					    const $menu = $(`${select_id} .menu`);
 | 
				
			||||||
@@ -512,7 +525,8 @@ function initCommentForm() {
 | 
				
			|||||||
          $menu.data('update-url'),
 | 
					          $menu.data('update-url'),
 | 
				
			||||||
          '',
 | 
					          '',
 | 
				
			||||||
          $menu.data('issue-id'),
 | 
					          $menu.data('issue-id'),
 | 
				
			||||||
          $(this).data('id')
 | 
					          $(this).data('id'),
 | 
				
			||||||
 | 
					          $(this).data('is-checked')
 | 
				
			||||||
        ).then(reload);
 | 
					        ).then(reload);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      switch (input_id) {
 | 
					      switch (input_id) {
 | 
				
			||||||
@@ -538,7 +552,8 @@ function initCommentForm() {
 | 
				
			|||||||
          $menu.data('update-url'),
 | 
					          $menu.data('update-url'),
 | 
				
			||||||
          '',
 | 
					          '',
 | 
				
			||||||
          $menu.data('issue-id'),
 | 
					          $menu.data('issue-id'),
 | 
				
			||||||
          $(this).data('id')
 | 
					          $(this).data('id'),
 | 
				
			||||||
 | 
					          $(this).data('is-checked')
 | 
				
			||||||
        ).then(reload);
 | 
					        ).then(reload);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -648,6 +663,18 @@ function initInstall() {
 | 
				
			|||||||
function initIssueComments() {
 | 
					function initIssueComments() {
 | 
				
			||||||
  if ($('.repository.view.issue .comments').length === 0) return;
 | 
					  if ($('.repository.view.issue .comments').length === 0) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  $('.re-request-review').click((event) => {
 | 
				
			||||||
 | 
					    const $this = $('.re-request-review');
 | 
				
			||||||
 | 
					    event.preventDefault();
 | 
				
			||||||
 | 
					    updateIssuesMeta(
 | 
				
			||||||
 | 
					      $this.data('update-url'),
 | 
				
			||||||
 | 
					      '',
 | 
				
			||||||
 | 
					      $this.data('issue-id'),
 | 
				
			||||||
 | 
					      $this.data('id'),
 | 
				
			||||||
 | 
					      $this.data('is-checked')
 | 
				
			||||||
 | 
					    ).then(reload);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  $(document).click((event) => {
 | 
					  $(document).click((event) => {
 | 
				
			||||||
    const urlTarget = $(':target');
 | 
					    const urlTarget = $(':target');
 | 
				
			||||||
    if (urlTarget.length === 0) return;
 | 
					    if (urlTarget.length === 0) return;
 | 
				
			||||||
@@ -2516,7 +2543,7 @@ $(document).ready(async () => {
 | 
				
			|||||||
      elementId = '';
 | 
					      elementId = '';
 | 
				
			||||||
      action = 'clear';
 | 
					      action = 'clear';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    updateIssuesMeta(url, action, issueIDs, elementId).then(() => {
 | 
					    updateIssuesMeta(url, action, issueIDs, elementId, '').then(() => {
 | 
				
			||||||
      // NOTICE: This reset of checkbox state targets Firefox caching behaviour, as the checkboxes stay checked after reload
 | 
					      // NOTICE: This reset of checkbox state targets Firefox caching behaviour, as the checkboxes stay checked after reload
 | 
				
			||||||
      if (action === 'close' || action === 'open') {
 | 
					      if (action === 'close' || action === 'open') {
 | 
				
			||||||
        // uncheck all checkboxes
 | 
					        // uncheck all checkboxes
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user