From ed0299f463a588bd960acef7bd006052ea3b8be1 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 06 2016 23:09:30 +0000 Subject: [PATCH 1/11] started reorganizing the PR page --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index e0eaad4..c2f5387 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -24,39 +24,44 @@ {% block repo %}
-
+
{% if pull_request %}

PR#{{requestid}} {{ pull_request.title | noJS(ignore="img") | safe }}{% if authenticated and (g.fas_user.username == pull_request.user.username or repo_admin) and pull_request.status == 'Open' - %} - ( + edit) {% - endif %}

- -
-
- {% if pull_request.status == 'Open' and repo_admin %} - -
- {{ mergeform.csrf_token }} - -
-
- {% endif %} + title="Update title">edit + {% if pull_request.status == 'Open' and authenticated and (repo_admin or g.fas_user.username == pull_request.user.username) %} - -
{{ mergeform.csrf_token }} - -
-
+ + {% endif %} + + {% endif %} + + +
+ Proposed {{ pull_request.date_created |humanize }} + by {{ pull_request.user.user | avatar(16) | safe }} {{ pull_request.user.user }} +
+ + From + {{ pull_request.project_from.fullname or pull_request.remote_git}} + {{ pull_request.branch_from }} + into + {{ pull_request.project.fullname }} + {{ pull_request.branch }} + +
+
{% if pull_request.status != 'Open' %} {{ pull_request.status }} by @@ -64,12 +69,12 @@ {% endif %} - + {# - + #}
{% elif form and (repo_admin or remote_git) %} @@ -113,40 +118,7 @@ {% endif %} {% endfor %} -
-
- - - - {{ render_bootstrap_field(form.title) }} - - - - - - - - - - - - - - - - - -
From git repo: - {% if remote_git -%} - {{ remote_git }} - {%- else -%} - {{ repo.fullname}} - {%- endif %} -
From branch:{{ branch_from }}
To git repo: - {% if repo.is_fork -%}{{ repo.parent.fullname }}{% - else %}{{ repo.fullname }}{% endif %} -
To branch:{{ branch_to }}

{{ form.csrf_token }} @@ -159,17 +131,260 @@ {% endif %} {% if pull_request %} -

+
+
-
+
+ {% if pull_request.flags %}
+ {% for flag in pull_request.flags %} + + + + + + + {% endfor %} + +
{{ flag.percent }}%{{ flag.username }}{{ flag.comment }} + {{ flag.date_created | humanize }} +
+
+
+ {% endif %} + +
+
+{% endif %} + + + +
+ +
+ + + + + + + {% for commit in diff_commits %} + + + {% if commit.message.strip().split('\n') | length > 1 %} + + {% else %} + + {% endif %} + + + {% else %} + + {% endfor %} + +
{{ commit.oid.hex|short }} + {% if pull_request and pull_request.status and pull_request.project_from.is_fork %} + + {% elif pull_request and pull_request.remote %} + + {% else %} + + {% endif %} + {{ commit.message.strip().split('\n')[0] }} +
+ {{ commit.message.strip().split('\n')[2:] | join('\n') }} +
+
+
more + {{ commit.commit_time|humanize }}
No commits found
+
+ +
+ {% if authenticated and pull_request %} +
+ {% endif %} + + {% if diff %} + {% for patch in diff %} +
+
+
+
+ {%- if patch | hasattr('new_file_path') -%} + {%- if patch.new_file_path == patch.old_file_path -%} + {{ patch.new_file_path }} + {%- else -%} + {{ patch.new_file_path }} (Renamed from "{{ patch.old_file_path }}") + {%- endif -%} + {%- elif patch | hasattr('delta') -%} + {%- if patch.delta.new_file.path == patch.delta.old_file.path -%} + {{ patch.delta.new_file.path }} + {%- else -%} + {{ patch.delta.new_file.path }} (Renamed from "{{ patch.delta.old_file.path }}") + {%- endif -%} + {%- endif -%} + + {% if pull_request %} + View + {% elif patch |hasattr('delta') %} + title="View file as of {{ patch.delta.new_file.id|short }}">View + {% else %} + title="View file as of {{ patch.new_oid|short }}">View + {% endif %} +
+
+
##{{patch}}## + {% autoescape false %} + {{ patch | patch_to_diff | html_diff | format_loc( + filename=patch.new_file_path, + commit=patch.new_id or patch.new_oid, + prequest=pull_request, + index=loop.index)}} + {% endautoescape %} +
+
+
+ {% endfor %} + {% endif %} + + {% if authenticated and pull_request %} + {{ mergeform.csrf_token }} +
+ {% endif %} +
+ {% if pull_request %} +
+
+ {% if pull_request.discussion %} +
+ + {% for comment in pull_request.discussion %} + {% if not comment.commit_id %} + {{ show_comment(comment, comment.id, repo, username, + requestid, form, repo_admin) }} + {% endif %} + {% endfor %} + {{ mergeform.csrf_token }} +
+ {% endif %} +
+ + {% if authenticated and mergeform and pull_request %} +
+
+ +
+ + {% if authenticated %} +
+ {{ mergeform.csrf_token }} + +
+ + + Preview + + + +
+
+
+ +
+ + +
+
+ {% else %} +

Login to comment on this ticket.

+ {% endif %} +
+
+
+ {% endif %} +
+ {% endif %} +
+ +
+ + +
+ {% if pull_request %} +
+ +
+
+ + + + + {# - + #} ')); - if (res.code == 'CONFLICTS' || res.code == 'NO_CHANGE') { - $('#merge_btn').attr("disabled", "disabled"); + if (res.code == 'FFORWARD'){ + $('#merge_btn').addClass("btn-success"); + $('#merge-alert').addClass("alert-success"); + $('#merge-alert-message').append(res.message); + $('#merge-alert').show(); + } + else if (res.code == 'MERGE') { + $('#merge_btn').addClass("btn-warning"); + $('#merge-alert').addClass("alert-warning"); + $('#merge-alert-message').append(res.message); + $('#merge-alert').show(); + } + else if (res.code == 'CONFLICTS') { + $('#merge_btn').hide(); + $('#merge-alert').addClass("alert-danger"); + $('#merge-alert-message').append(res.message); + $('#merge-alert').show(); + } + else if (res.code == 'NO_CHANGE') { + $('#merge_btn').hide(); + $('#merge-alert').addClass("alert-info"); + $('#merge-alert-message').append(res.message); + $('#merge-alert').show(); } }, error: function(res) { From f7fe432a592f745d6e11a88023b3ed4c7bc191a8 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 06 2016 23:09:30 +0000 Subject: [PATCH 2/11] fix inline comments on newer versions of pygit2 (f23) --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index c2f5387..16799e0 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -235,22 +235,34 @@ {% if diff %} {% for patch in diff %} + {% if patch |hasattr('new_id') %} + {% set patch_new_id = patch.new_id %} + {% elif patch |hasattr('delta') %} + {% set patch_new_id = patch.delta.new_file.id %} + {% else %} + {% set patch_new_id = patch.new_oid %} + {% endif %} + + {% if patch | hasattr('new_file_path') %} + {% set patch_new_file_path = patch.new_file_path -%} + {% if patch.new_file_path != patch.old_file_path %} + {% set patch_old_file_path = patch.old_file_path %} + {%- endif -%} + {%- elif patch | hasattr('delta') -%} + {% set patch_new_file_path = patch.delta.new_file.path -%} + {%- if patch.delta.new_file.path != patch.delta.old_file.path -%} + {% set patch_old_file_path = patch.delta.old_file.path %} + {%- endif -%} + {%- endif -%} +
- {%- if patch | hasattr('new_file_path') -%} - {%- if patch.new_file_path == patch.old_file_path -%} - {{ patch.new_file_path }} - {%- else -%} - {{ patch.new_file_path }} (Renamed from "{{ patch.old_file_path }}") - {%- endif -%} - {%- elif patch | hasattr('delta') -%} - {%- if patch.delta.new_file.path == patch.delta.old_file.path -%} - {{ patch.delta.new_file.path }} - {%- else -%} - {{ patch.delta.new_file.path }} (Renamed from "{{ patch.delta.old_file.path }}") - {%- endif -%} + {%- if patch_new_file_path == patch_old_file_path -%} + {{ patch_new_file_path }} (Renamed from "{{ patch_old_file_path }}") + {%- else -%} + {{ patch_new_file_path }} {%- endif -%} {% if pull_request %} @@ -261,7 +273,7 @@ if pull_request.project_from.is_fork else None, repo=pull_request.project_from.name, identifier=pull_request.branch_from, - filename=patch.new_file_path) }}" + filename=patch_new_file_path) }}" {% else %} View - {% elif patch |hasattr('delta') %} - title="View file as of {{ patch.delta.new_file.id|short }}">View - {% else %} - title="View file as of {{ patch.new_oid|short }}">View + filename=patch_new_file_path) }}" {% endif %} + title="View file as of {{ patch_new_id|short }}">View
-
##{{patch}}## +
{% autoescape false %} {{ patch | patch_to_diff | html_diff | format_loc( - filename=patch.new_file_path, - commit=patch.new_id or patch.new_oid, + filename=patch_new_file_path, + commit=patch_new_id, prequest=pull_request, index=loop.index)}} {% endautoescape %} diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index e5a424e..056756c 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -66,8 +66,8 @@ def format_loc(loc, commit=None, filename=None, prequest=None, index=None): comments = {} if prequest and not isinstance(prequest, flask.wrappers.Request): for com in prequest.comments: - if commit and com.commit_id == commit \ - and com.filename == filename: + if commit and unicode(com.commit_id) == unicode(commit) \ + and unicode(com.filename) == unicode(filename): if com.line in comments: comments[com.line].append(com) else: From 46087c7def104250de274e0330ba71cf43d51521 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 06 2016 23:09:30 +0000 Subject: [PATCH 3/11] added notifications about the inline comments in the comments tab --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 16799e0..07cc8d0 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -163,7 +163,7 @@
{% endif %} -
' '' ); + '' ); cancel_edit_btn(); emoji_complete(json_url, folder); }); diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index dd9bf0e..f6b4c4a 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -90,7 +90,7 @@ def format_loc(loc, commit=None, filename=None, prequest=None, index=None): '' % ( { @@ -124,14 +124,14 @@ def format_loc(loc, commit=None, filename=None, prequest=None, index=None): output.append('') tpl_edit = '' \ - '' \ + '' \ '' tpl_edited = ' ' \ 'Edited %(human_edit_date)s by %(user)s ' - tpl_delete = '' + '' '
By @@ -208,9 +423,9 @@
Created - {{ pull_request.date_created |humanize }} + {{ pull_request.date_created |humanize }}
Assignee @@ -231,90 +446,7 @@ - - -
- {% if pull_request.flags %} -
-
- - - - - {% for flag in pull_request.flags %} - - - - - - - {% endfor %} - -
{{ flag.percent }}%{{ flag.username }}{{ flag.comment }} - {{ flag.date_created | humanize }} -
-
-
- {% endif %} - -
- -{% endif %} - - - - - -
+ {% endif %} {% if diff %}
@@ -370,142 +502,7 @@
{% endif %} - - - {% if authenticated and pull_request %} -
- {% endif %} - - {% if diff %} - {% for patch in diff %} -
-
-
-
- {%- if patch | hasattr('new_file_path') -%} - {%- if patch.new_file_path == patch.old_file_path -%} - {{ patch.new_file_path }} - {%- else -%} - {{ patch.new_file_path }} (Renamed from "{{ patch.old_file_path }}") - {%- endif -%} - {%- elif patch | hasattr('delta') -%} - {%- if patch.delta.new_file.path == patch.delta.old_file.path -%} - {{ patch.delta.new_file.path }} - {%- else -%} - {{ patch.delta.new_file.path }} (Renamed from "{{ patch.delta.old_file.path }}") - {%- endif -%} - {%- endif -%} - - {% if pull_request %} - View - {% elif patch |hasattr('delta') %} - title="View file as of {{ patch.delta.new_file.id|short }}">View - {% else %} - title="View file as of {{ patch.new_oid|short }}">View - {% endif %} -
-
-
- {% autoescape false %} - {{ patch | patch_to_diff | html_diff | format_loc( - filename=patch.new_file_path, - commit=patch.new_id or patch.new_oid, - prequest=pull_request, - index=loop.index)}} - {% endautoescape %} -
-
-
- {% endfor %} - {% endif %} - - {% if authenticated and pull_request %} - {{ mergeform.csrf_token }} -
- {% endif %} -
- - - {% if pull_request %} -
- {% if pull_request.discussion %} -
- - {% for comment in pull_request.discussion %} - {% if not comment.commit_id %} - {{ show_comment(comment, comment.id, repo, username, - requestid, form, repo_admin) }} - {% endif %} - {% endfor %} - {{ mergeform.csrf_token }} -
- {% endif %} -
- {% endif %} - - {% if authenticated and mergeform and pull_request %} -
-
- -
- - {% if authenticated %} -
- {{ mergeform.csrf_token }} - -
- - - Preview - - - -
-
-
- -
- - -
-
- {% else %} -

Login to comment on this ticket.

- {% endif %} -
- -
- {% endif %} - - {% endblock %} @@ -603,23 +600,6 @@ function setup_reply_btns() { } }); - $( ".nav-item" ).click( - function() { - var header = $( this ).attr('data-id'); - if (header == 'nav-diff') { - $($(this).parent().children()[1]).removeClass('active'); - $(this).addClass('active'); - $('#commit_list').hide(); - $('#request_diff').show(); - } else { - $($(this).parent().children()[0]).removeClass('active'); - $(this).addClass('active'); - $('#request_diff').hide(); - $('#commit_list').show(); - } - } - ); - {% if pull_request %} {# These lines are only for existing pull-requests, not new ones #} @@ -761,11 +741,29 @@ function setup_reply_btns() { }, dataType: 'json', success: function(res) { - var _obj = $('#pr_flags').find('tbody'); - _obj.append($('
PR Status:'+res.short_code+'
' + '
' '' From 4ec16d30ea25efe739d8b97c52938a075c737b1d Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 07 2016 00:33:38 +0000 Subject: [PATCH 4/11] fixed flags presentation --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 07cc8d0..3172a92 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -136,29 +136,6 @@
- {% if pull_request.flags %} -
-
- - - - - {% for flag in pull_request.flags %} - - - - - - - {% endfor %} - -
{{ flag.percent }}%{{ flag.username }}{{ flag.comment }} - {{ flag.date_created | humanize }} -
-
-
- {% endif %} -
{% endif %} @@ -286,7 +263,7 @@ title="View file as of {{ patch_new_id|short }}">View -
+ {% autoescape false %} {{ patch | patch_to_diff | html_diff | format_loc( filename=patch_new_file_path, @@ -294,7 +271,7 @@ prequest=pull_request, index=loop.index)}} {% endautoescape %} -
+ {% endfor %} @@ -393,54 +370,35 @@ {% endif %} + + {% if pull_request.flags %}
+
    + {% for flag in pull_request.flags %} +
  • +
    + {{ flag.username }} +
    {{ flag.percent }}%
    +
    +
    + {{ flag.comment }} +
    + {{ flag.date_created | humanize }}
    +
    +
    +
  • + {% endfor %} +
+
+ {% endif %} + + {# + + #} {% endif %} {% if diff %}
-
Changes summary:
+
Changes summary
-
@@ -514,7 +472,6 @@ {% endfor %}
-
{% endif %} From 410361ffb33577c475032e91399ce64bd28e7410 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 07 2016 01:19:47 +0000 Subject: [PATCH 5/11] cleaned up buttons on comments --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 61d76b1..b591b39 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -133,25 +133,27 @@ {% 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 %} +
+
From 79145cd5e6c2115c669a441af33f5ca20e9fd408 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 07 2016 02:09:41 +0000 Subject: [PATCH 6/11] cleaned up inline comments a bit --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 3172a92..6099f35 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -618,7 +618,7 @@ function setup_reply_btns() { if (next_row.prev().find('.pr_comment_form').length == 0){ $.get( url , function( data ) { next_row.before( - '
' + data + '
' + data + '
' '

' - 'Add comment' + '' '

' '
' - '
' - '
' + '
' + '
' + '
' '' - ' %(user)s' - ' %(user)s commented ' + '' '%(human_date)s' - '
' - '
' + '
' '
' '
' '%(comment)s' @@ -189,7 +189,7 @@ def format_loc(loc, commit=None, filename=None, prequest=None, index=None): '
' '
' '%(templ_edited)s' - '
{% endif %}
From 081cd395eda741efbfcd72fa4bce620b1ef04e89 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 07 2016 03:23:18 +0000 Subject: [PATCH 8/11] added some whitespace on the tabs in the PR page --- diff --git a/pagure/static/koji.css b/pagure/static/koji.css index 26c1d40..98b44fd 100644 --- a/pagure/static/koji.css +++ b/pagure/static/koji.css @@ -359,3 +359,11 @@ btn-group-vertical > .btn-group::after, .btn-group-vertical > .btn-group::before margin-bottom: 0; padding-left: 0; } + +#pr-tabs +{ + border-bottom: 1px solid #ddd; + margin-bottom:1.5em; + margin-top:2em; +} + From bc6d33c2529ce164dbae44086aadb12cb41a74c8 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 07 2016 05:26:11 +0000 Subject: [PATCH 9/11] updated the commits tab --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 330327c..8da3f38 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -163,44 +163,34 @@
- - - - - - +
{% for commit in diff_commits %} -
- - - {% if commit.message.strip().split('\n') | length > 1 %} - - {% else %} - - {% endif %} - - - {% else %} - + + {{ commit.author | author2avatar(20) | safe }} {{ commit.author.name }} +
+ {{ commit.hex|short }} +
+ {% endfor %} - -
{{ commit.oid.hex|short }} + {% if pull_request and pull_request.status and pull_request.project_from.is_fork %} - {% elif pull_request and pull_request.remote %} {% else %} - {% endif %} - {{ commit.message.strip().split('\n')[0] }} - more - {{ commit.commit_time|humanize }}
No commits found
+
From 272c1e714b6e01e4dea17381b026cea6cb02d3d3 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 07 2016 05:41:33 +0000 Subject: [PATCH 10/11] layout changes to the new PR view --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 8da3f38..d465ccb 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -24,7 +24,7 @@ {% block repo %}
-
+
{% if pull_request %}

PR#{{requestid}} {{ pull_request.title | noJS(ignore="img") | safe }}{% if authenticated and (g.fas_user.username == pull_request.user.username @@ -98,6 +98,7 @@ repo=repo.name, commitid=commitid, branch_from=branch_from, branch_to=branch_to) }}" method="post"> {% endif %} +
Pull from {% if remote_git -%}{{ remote_git }}{%- @@ -118,32 +119,25 @@ {% endif %} {% endfor %} +
{{ render_bootstrap_field(form.title) }}

- + {{ form.csrf_token }} - - + + Cancel

{% endif %} -{% if pull_request %} -
-
-
- -
-
-
-{% endif %} -

-