Fix CreateComment for SQLite and JS click event on Request Review (#11040)
* fix some bug about Request review * fix ``CreateComment`` wrong using ,it will not work when use Sqlite * fix wrong js click event code , it will send wrong data when it has many choices Signed-off-by: a1012112796 <1012112796@qq.com> * Apply suggestions from code review Co-Authored-By: Lauris BH <lauris@nix.lv> * add getReviewerByIssueIDAndUserID fix wrong conditions check in initIssueComments after #10972 * call CI again Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									8592fb7121
								
							
						
					
					
						commit
						cc07b9ca37
					
				
					 2 changed files with 18 additions and 10 deletions
				
			
		|  | @ -395,9 +395,13 @@ func GetReviewersByIssueID(issueID int64) (reviews []*Review, err error) { | ||||||
| 
 | 
 | ||||||
| // GetReviewerByIssueIDAndUserID get the latest review of reviewer for a pull request
 | // GetReviewerByIssueIDAndUserID get the latest review of reviewer for a pull request
 | ||||||
| func GetReviewerByIssueIDAndUserID(issueID, userID int64) (review *Review, err error) { | func GetReviewerByIssueIDAndUserID(issueID, userID int64) (review *Review, err error) { | ||||||
|  | 	return getReviewerByIssueIDAndUserID(x, issueID, userID) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func getReviewerByIssueIDAndUserID(e Engine, issueID, userID int64) (review *Review, err error) { | ||||||
| 	review = new(Review) | 	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 (?, ?, ?))", | 	if _, err := e.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). | 		issueID, userID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest). | ||||||
| 		Get(review); err != nil { | 		Get(review); err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
|  | @ -559,7 +563,7 @@ func RemoveRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Com | ||||||
| 		// recalculate which is the latest official review from that user
 | 		// recalculate which is the latest official review from that user
 | ||||||
| 		var review *Review | 		var review *Review | ||||||
| 
 | 
 | ||||||
| 		review, err = GetReviewerByIssueIDAndUserID(issue.ID, reviewer.ID) | 		review, err = getReviewerByIssueIDAndUserID(sess, issue.ID, reviewer.ID) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
|  | @ -575,7 +579,7 @@ func RemoveRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Com | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	comment, err = CreateComment(&CreateCommentOptions{ | 	comment, err = createComment(sess, &CreateCommentOptions{ | ||||||
| 		Type:            CommentTypeReviewRequest, | 		Type:            CommentTypeReviewRequest, | ||||||
| 		Doer:            doer, | 		Doer:            doer, | ||||||
| 		Repo:            issue.Repo, | 		Repo:            issue.Repo, | ||||||
|  |  | ||||||
|  | @ -661,17 +661,21 @@ function initInstall() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function initIssueComments() { | function initIssueComments() { | ||||||
|   if ($('.repository.view.issue .comments').length === 0) return; |   if ($('.repository.view.issue .timeline').length === 0) return; | ||||||
|  | 
 | ||||||
|  |   $('.re-request-review').on('click', function (event) { | ||||||
|  |     const url = $(this).data('update-url'); | ||||||
|  |     const issueId = $(this).data('issue-id'); | ||||||
|  |     const id = $(this).data('id'); | ||||||
|  |     const isChecked = $(this).data('is-checked'); | ||||||
| 
 | 
 | ||||||
|   $('.re-request-review').click((event) => { |  | ||||||
|     const $this = $('.re-request-review'); |  | ||||||
|     event.preventDefault(); |     event.preventDefault(); | ||||||
|     updateIssuesMeta( |     updateIssuesMeta( | ||||||
|       $this.data('update-url'), |       url, | ||||||
|       '', |       '', | ||||||
|       $this.data('issue-id'), |       issueId, | ||||||
|       $this.data('id'), |       id, | ||||||
|       $this.data('is-checked') |       isChecked | ||||||
|     ).then(reload); |     ).then(reload); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue