'+
''+
''+
'{1}'+
+ reasons_html +
''+
'
diff --git a/rhodecode/templates/pullrequests/pullrequest.html b/rhodecode/templates/pullrequests/pullrequest.html
--- a/rhodecode/templates/pullrequests/pullrequest.html
+++ b/rhodecode/templates/pullrequests/pullrequest.html
@@ -439,13 +439,6 @@
};
var targetRepoChanged = function(repoData) {
- // reset && add the reviewer based on selected repo
- $('#review_members').html('');
- addReviewMember(
- repoData.user.user_id, repoData.user.firstname,
- repoData.user.lastname, repoData.user.username,
- repoData.user.gravatar_link);
-
// generate new DESC of target repo displayed next to select
$('#target_repo_desc').html(
"${_('Destination repository')}: {0}".format(repoData['description'])
@@ -488,10 +481,12 @@
$sourceRef.on('change', function(e){
loadRepoRefDiffPreview();
+ loadDefaultReviewers();
});
$targetRef.on('change', function(e){
loadRepoRefDiffPreview();
+ loadDefaultReviewers();
});
$targetRepo.on('change', function(e){
@@ -518,6 +513,36 @@
});
+ var loadDefaultReviewers = function() {
+ if (loadDefaultReviewers._currentRequest) {
+ loadDefaultReviewers._currentRequest.abort();
+ }
+ var url = pyroutes.url('repo_default_reviewers_data', {'repo_name': targetRepoName});
+
+ var sourceRepo = $sourceRepo.eq(0).val();
+ var sourceRef = $sourceRef.eq(0).val().split(':');
+ var targetRepo = $targetRepo.eq(0).val();
+ var targetRef = $targetRef.eq(0).val().split(':');
+ url += '?source_repo=' + sourceRepo;
+ url += '&source_ref=' + sourceRef[2];
+ url += '&target_repo=' + targetRepo;
+ url += '&target_ref=' + targetRef[2];
+
+ loadDefaultReviewers._currentRequest = $.get(url)
+ .done(function(data) {
+ loadDefaultReviewers._currentRequest = null;
+
+ // reset && add the reviewer based on selected repo
+ $('#review_members').html('');
+ for (var i = 0; i < data.reviewers.length; i++) {
+ var reviewer = data.reviewers[i];
+ addReviewMember(
+ reviewer.user_id, reviewer.firstname,
+ reviewer.lastname, reviewer.username,
+ reviewer.gravatar_link, reviewer.reasons);
+ }
+ });
+ };
prButtonLock(true, "${_('Please select origin and destination')}");
// auto-load on init, the target refs select2
@@ -532,6 +557,7 @@
// in case we have a pre-selected value, use it now
$sourceRef.select2('val', '${c.default_source_ref}');
loadRepoRefDiffPreview();
+ loadDefaultReviewers();
%endif
ReviewerAutoComplete('user');