From c64736cc38bb9c32a20ec7f689e3c9acc3a739f3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 06 2016 08:54:57 +0000 Subject: [PATCH 1/3] Return the branches already concerned by a PR as well as those not This way we can both offer to open a new PR for that branch or to see the existing PR concerning the branch. --- diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 828e50e..514a1af 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -321,14 +321,19 @@ def get_pull_request_ready_branch(): project_id_from=repo.id, status='Open' ) + branches_pr = {} for pr in prs: if pr.branch_from in branches: + branches_pr[pr.branch_from] = pr.id del(branches[pr.branch_from]) return flask.jsonify( { 'code': 'OK', - 'message': branches, + 'message': { + 'new_branch': branches, + 'branch_w_pr': branches_pr, + }, } ) From fc52ba91b2ccd7b80f88b3fabe0162f81c5a8d1a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 06 2016 08:56:05 +0000 Subject: [PATCH 2/3] Adjust the JS for the data change to point to the opened PR when there is one --- diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index f65c3fc..44d1552 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -278,7 +278,7 @@ $(function() { dataType: 'json', success: function(res) { if (res.code == 'OK'){ - for (branch in res.message){ + for (branch in res.message.new_branch){ var url = "{{ url_for( 'new_request_pull', repo=repo.name, @@ -286,7 +286,8 @@ $(function() { branch_to=head or 'master', branch_from='') }}"; html = ''; {% else %} html2 = ' \ New PR \ '; {%endif%} $('#branch-'+branch+' .branch_del').prepend(html2); $('[data-toggle="tooltip"]').tooltip({placement : 'bottom'}); } + for (branch in res.message.branch_w_pr){ + var url = "{{ url_for( + 'request_pull', + repo=repo.name, + username=repo.user.user if repo.is_fork else None, + requestid=-100) }}"; + url = url.replace(-100, res.message.branch_w_pr[branch]); + var html = ' \ + ' + + 'See PR \ + '; + console.log(html); + $('#branch-' + branch + ' .branch_del').prepend(html); + $('[data-toggle="tooltip"]').tooltip({placement : 'bottom'}); + } } } }); From d746d149c593bffcf2fa8851c5ba456a257a06c7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 06 2016 10:14:18 +0000 Subject: [PATCH 3/3] Adjust the label to be ``PR#`` rather than ``See PR`` --- diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index 44d1552..9ab7e36 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -327,7 +327,7 @@ $(function() { ' - + 'See PR \ + + 'PR#' + res.message.branch_w_pr[branch] + ' \ '; console.log(html); $('#branch-' + branch + ' .branch_del').prepend(html);