From d48a2d9d971188620cad131e7d4c20c7bff7acb4 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:02:42 +0000 Subject: [PATCH 1/9] Fix showing the inline comments even if there are no generic comments --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index d808e0a..c81121f 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -271,7 +271,7 @@ {% if pull_request %}
- {% if pull_request.discussion %} + {% if pull_request.comments %}
From ecba85ddca4b2d55ec345d49e5bd66c1622eec98 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:02:42 +0000 Subject: [PATCH 2/9] Fix the cancel button in the inline comment form --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index c81121f..aaea8a9 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -477,7 +477,7 @@ function cancel_edit_btn() { item = $(this).closest('section'); $(item.parent().find('.issue_comment')).show(); $(item.parent().find('.issue_actions')).show(); - $(item.parent().find('.edit_comment')).remove(); + $(item.parent().closest('.pr_comment_form')).remove(); return false; } ); @@ -598,7 +598,9 @@ function setup_reply_btns() { if (next_row.prev().find('.pr_comment_form').length == 0){ $.get( url , function( data ) { next_row.before( - '
' + data + '
' ); + ' \ +
' + + data + '
' ); cancel_edit_btn(); emoji_complete(json_url, folder); }); From 44be5fc6d1f39c4993ba00510d4997193793ba7d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:02:42 +0000 Subject: [PATCH 3/9] Fix the formatting on the comments added via the event source --- diff --git a/pagure/static/request_ev.js b/pagure/static/request_ev.js index 6f8d64d..f91ad12 100644 --- a/pagure/static/request_ev.js +++ b/pagure/static/request_ev.js @@ -1,9 +1,12 @@ add_comment = function(data) { console.log('Adding comment ' + data.comment_added); var field = $('#comments'); - var edit_btn = ' \ - reply '; + var edit_btn = ' \ + \ + '; var inline = false; if (data.commit_id){ inline = true; @@ -29,22 +32,19 @@ add_comment = function(data) {
\ \
\ - \ -
\ - \ +
\ +
\ + \ + \ + ' + + edit_btn + + ' \ +
\ +
\ '; if (inline){ From 96fa6b3787cb5c35174d51c05e4c038c06be4bd0 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:02:42 +0000 Subject: [PATCH 4/9] Adjust indentation to 2 spaces --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index b591b39..e8f33f2 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -130,31 +130,31 @@
- {% if comment.edited_on %} - Edited {{ comment.edited_on | humanize }} by {{ comment.editor.username }} - {% endif %} -
-
- - - - - - - {% if id != 0 and g.fas_user and ( - (comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username) - or repo_admin) %} - - {% endif %} -
+ {% if comment.edited_on %} + Edited {{ comment.edited_on | humanize }} by {{ comment.editor.username }} + {% endif %} +
+
+ + + + + + + {% if id != 0 and g.fas_user and ( + (comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username) + or repo_admin) %} + + {% endif %}
+
{% endmacro %} From e65964d66511c370042206d131dd174dabfe92ee Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:02:42 +0000 Subject: [PATCH 5/9] Fix the layout of inline comments added via the event source --- diff --git a/pagure/static/request_ev.js b/pagure/static/request_ev.js index f91ad12..10a5119 100644 --- a/pagure/static/request_ev.js +++ b/pagure/static/request_ev.js @@ -13,6 +13,40 @@ add_comment = function(data) { edit_btn = ''; } + if (inline) { + var _data = ' \ + \ +
\ +
\ + \ +
\ +
\ + ' + data.comment_added + ' \ +
\ +
\ +
\ + \ +
\ + '; + } else { var _data = '
\
\ \ @@ -46,16 +80,15 @@ add_comment = function(data) {
\
\ '; + } if (inline){ // Inline comment console.log('Inline'); - var _row = ' \ -
' + _data + '
'; var field = $('[data-commit="' + data.commit_id + '"]').parent(); var id = field.children().children().attr('id').split('_')[0]; var row = $('#' + id + '_' + (parseInt(data.line) + 1)).parent().parent(); - row.before(_row); + row.before(_data); } else { // Generic comment console.log('generic'); From 279d4c183322f5c3c039b945c1ccf2c7ff638724 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:02:42 +0000 Subject: [PATCH 6/9] Fix removing the comment form after making a comment --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index aaea8a9..42bf160 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -786,7 +786,7 @@ function try_async_comment(form, inline) { if(data == 'ok') { $('#comment').val(''); /* We have submitted the comment correctly */ - var item = $('#comment_block').closest('section'); + var item = $('.pr_comment_form').closest('tr'); if (!$(item.parent().children()[1]).is(':visible')){ $(item.parent().children()[1]).show() } From 1f235d499a184c6fa417d37e7cea2cd6bbedddc6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:20:30 +0000 Subject: [PATCH 7/9] Code style --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 42bf160..9249b3d 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -284,8 +284,12 @@
- {{comment.user.user}} commented on line {{comment.line}} of {{comment.filename}} -
{{ comment.date_created | humanize}}
+ {{comment.user.user}} commented on line + {{ + comment.line}} of {{comment.filename}} +
+ {{ + comment.date_created | humanize}}
From 21397822e246d0b3cef58a87b735758bd926e86c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:22:27 +0000 Subject: [PATCH 8/9] Adjust inline comment as the status of pull-requests isn't a boolean The status of a PR is Open, Merged or Close, making the check performed here incomplete --- diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index f6b4c4a..5d8e0b1 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -145,7 +145,7 @@ def format_loc(loc, commit=None, filename=None, prequest=None, index=None): templ_edit = '' templ_edited = '' if authenticated() and ( - (comment.parent.status is True + (str(comment.parent.status).lower() in ['true', 'open'] and comment.user.user == flask.g.fas_user.username) or is_repo_admin(comment.parent.project)): templ_delete = tpl_delete % ({'commentid': comment.id}) From 67ff39c17696324133962442575e31aabf81561e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 07 2016 14:43:33 +0000 Subject: [PATCH 9/9] Disable the submit button when doing async action to avoid making two calls --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index a911dfa..30f6a2c 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -352,6 +352,7 @@ source.addEventListener('message', function(e) { {% if authenticated and form %} function try_async_comment(form) { + $(form).find('input[type="submit"]').attr("disabled", "disabled"); var _data = $(form).serialize(); var btn = $(document.activeElement); if (btn[0].name == 'drop_comment'){ diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 9249b3d..7f816ea 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -774,6 +774,7 @@ $('#assignee').selectize({ function try_async_comment(form, inline) { $(form).off('submit'); + $(form).find('input[type="submit"]').attr("disabled", "disabled"); var _data = $(form).serialize(); var btn = $(document.activeElement); if (btn[0].name == 'drop_comment'){