#3607 Update the styling of the user issues and user PR pages
Merged 2 years ago by ryanlerch. Opened 2 years ago by ryanlerch.
ryanlerch/pagure user-issues-and-prs  into  master

@@ -1,14 +1,15 @@ 

- {% macro render_issue_row(issue, repo, username, subtitle=True) %}

+ {% macro render_issue_row(issue, repo, username, subtitle=True, class="", showproject=False) %}

      {% if issue.status == 'Open' %}

          {% set status_color = "success" %}

      {% else %}

          {% set status_color = "danger" %}

      {% endif %}

  

- <div class="issuerow list-group-item list-group-item-action">

+ <div class="issuerow list-group-item list-group-item-action {{class}}">

          <div class="d-flex align-items-start">

              <span class="fa fa-fw text-{{status_color}} fa-exclamation-circle pt-1"></span>

-             <div class="ml-1">

+             <div class="w-100">

+             <div class="ml-1 d-flex">

                  <div>

                      <span class="text-{{status_color}} font-weight-bold">#{{issue.id}}</span>

                      <span class="font-weight-bold">
@@ -24,8 +25,30 @@ 

                      <span title="Private ticket" class="text-danger fa fa-fw fa-lock"></span>

                      {% endif %}

                  </div>

+                 <div class="ml-auto nowrap">

+                     <span class="font-weight-bold text-muted ml-auto">

+                     {% if issue.priority is not none  %}

+                     <span title="Priority" class="mr-3"><i class="fa fa-fw fa-bolt"></i>{{ repo.priorities[issue.priority | string] }}</span>

+                     {% endif %}

+ 

+                     {% if issue.assignee %}

+                     <span title="{{ issue.assignee.username}}" class="mr-3 assigned-user">

+                         <i class="fa fa-fw fa-user-plus pr-2"></i>

+                         {{ issue.assignee.username | avatar(size=20) | safe}}

+                     </span>

+                     {% endif %}

+ 

+                     {% if issue.user_comments|count > 0 %}

+                     <span title="Comments on the ticket" class="text-muted">

+                     <span class="fa fa-fw fa-comment pr-2"></span>

+                         {{issue.user_comments|count}}

+                     </span>

+                     {% endif %}

+                     </span>

+                 </div>

+             </div>

                  {% if subtitle %}

-                 <div>

+                 <div class="d-flex">

                      <small>Opened <a href="#" data-toggle="tooltip" title="{{

                          issue.date_created | format_datetime

                        }}">{{ issue.date_created | humanize}}</a> by <span title="{{
@@ -34,6 +57,40 @@ 

                          issue.last_updated | format_datetime

                        }}">{{ issue.last_updated | humanize}}</span>

                        </small>

+                       {% if showproject %}

+                       <small class="ml-auto mt-1">

+                             {% if repo.is_fork -%}

+                             <i class="fa fa-code-fork text-muted"></i>&nbsp;

+                             {%- else -%}

+                             <i class="fa fa-calendar-o fa-rotate-270 text-muted"></i> &nbsp;

+                             {%- endif -%}

+                           {% if repo.is_fork %}

+                           <a href="{{ url_for(

+                               'ui_ns.view_user', username=repo.user.user)

+                               }}">{{ repo.user.user }}</a><span class="mt-1 text-muted"> / </span>

+                           {% endif %}

+                           {% if repo.namespace %}

+                               <a href="{{ url_for(

+                                   'ui_ns.view_projects', namespace=repo.namespace, pattern='*')

+                               }}">{{ repo.namespace }}</a>/

+                           {% endif %}

+                           {% if repo.is_fork %}

+                           <a href="{{ url_for('ui_ns.view_repo',

+                               repo=repo.name,

+                               username=repo.user.username,

+                               namespace=repo.namespace)

+                               }}">

+                         {% else %}

+                         <a href="{{ url_for('ui_ns.view_repo',

+                         repo=repo.name,

+                         username=None,

+                         namespace=repo.namespace)

+                         }}">

+                         {% endif %}

+                             

+                             <strong>{{ repo.name }}</strong></a>

+                       </small>

+                       {% endif %}

                  </div>

                  <div>

                          {% for tag in issue.tags %}
@@ -50,26 +107,7 @@ 

                          {% endfor %}

                  </div>

                  {% endif %}

-             </div>

-             <span class="font-weight-bold text-muted ml-auto">

-             {% if issue.priority is not none  %}

-             <span title="Priority" class="mr-3"><i class="fa fa-fw fa-bolt"></i>{{ repo.priorities[issue.priority | string] }}</span>

-             {% endif %}

- 

-             {% if issue.assignee %}

-             <span title="{{ issue.assignee.username}}" class="mr-3 assigned-user">

-                 <i class="fa fa-fw fa-user-plus pr-2"></i>

-                 {{ issue.assignee.username | avatar(size=20) | safe}}

-             </span>

-             {% endif %}

- 

-             {% if issue.user_comments|count > 0 %}

-             <span title="Comments on the ticket" class="text-muted">

-               <span class="fa fa-fw fa-comment pr-2"></span>

-                 {{issue.user_comments|count}}

-             </span>

-             {% endif %}

-             </span>

+                 </div>

          </div>

      </div><!-- end issuerow -->

  {% endmacro%}

@@ -1,4 +1,4 @@ 

- {% macro render_pullrequest_row(request, repo, username, subtitle=True) %}

+ {% macro render_pullrequest_row(request, repo, username, subtitle=True, class="", showproject=False) %}

      {% if request.status|lower == 'open' %}

          {% set status_color = "success" %}

      {% elif request.status|lower == 'merged' %}
@@ -7,10 +7,11 @@ 

          {% set status_color = "danger" %}

      {% endif %}

  

- <div class="request-row list-group-item list-group-item-action">

+ <div class="request-row list-group-item list-group-item-action {{class}}">

          <div class="d-flex align-items-start">

              <span class="fa fa-fw text-{{status_color}} fa-arrow-circle-down pt-1"></span>

-             <div class="ml-1">

+             <div class="w-100">

+             <div class="ml-1 d-flex">

                  <div>

                      <span class="text-{{status_color}} font-weight-bold">#{{request.id}}</span>

                      <span class="font-weight-bold">
@@ -23,10 +24,30 @@ 

                          {{request.title}}

                          </a>

                      </span>

- 

                  </div>

+                 <span class="font-weight-bold text-muted ml-auto">

+ 

+                         {% if request.assignee %}

+                         <span title="{{ request.assignee.username}}" class="ml-3 assigned-user">

+                             <i class="fa fa-fw fa-user-plus pr-2"></i>

+                             {{ request.assignee.username | avatar(size=20) | safe}}

+                         </span>

+                         {% endif %}

+             

+                         <span title="branch to" class="text-muted ml-3">

+                             <span class="fa fa-fw fa-random pr-2"></span>

+                               {{request.branch}}

+                           </span>

+             

+                         <span title="Comments on the ticket" class="text-muted ml-3">

+                           <span class="fa fa-fw fa-comment pr-2"></span>

+                             {{request.user_comments|count}}

+                         </span>

+                         

+                 </span>

+             </div>

                  {% if subtitle %}

-                 <div>

+                 <div class="d-flex">

                      {% if request.status|lower == 'merged'%}

                          <small>

                              <span class="text-info font-weight-bold">Merged</span>
@@ -63,8 +84,40 @@ 

                        }}">{{ request.last_updated | humanize}}</span>

                        </small>

                      {% endif %}

+                     {% if showproject %}

+                       <small class="ml-auto mt-1">

+                             {% if repo.is_fork -%}

+                             <i class="fa fa-code-fork text-muted"></i>&nbsp;

+                             {%- else -%}

+                             <i class="fa fa-calendar-o fa-rotate-270 text-muted"></i> &nbsp;

+                             {%- endif -%}

+                           {% if repo.is_fork %}

+                           <a href="{{ url_for(

+                               'ui_ns.view_user', username=repo.user.user)

+                               }}">{{ repo.user.user }}</a><span class="mt-1 text-muted"> / </span>

+                           {% endif %}

+                           {% if repo.namespace %}

+                               <a href="{{ url_for(

+                                   'ui_ns.view_projects', namespace=repo.namespace, pattern='*')

+                               }}">{{ repo.namespace }}</a>/

+                           {% endif %}

+                           {% if repo.is_fork %}

+                           <a href="{{ url_for('ui_ns.view_repo',

+                               repo=repo.name,

+                               username=repo.user.username,

+                               namespace=repo.namespace)

+                               }}">

+                         {% else %}

+                         <a href="{{ url_for('ui_ns.view_repo',

+                         repo=repo.name,

+                         username=None,

+                         namespace=repo.namespace)

+                         }}">

+                         {% endif %}

+                             <strong>{{ repo.name }}</strong></a>

+                         </small>

+                       {% endif %}

                  </div>

-                 {% endif %}

                  <div>

                          {% for tag in request.tags %}

                              <span id="tag-{{ tag.tag }}" title="{{ tag.tag_description }}"
@@ -75,27 +128,8 @@ 

                              </span>

                          {% endfor %}

                  </div>

+                 {% endif %}

              </div>

-             <span class="font-weight-bold text-muted ml-auto">

- 

-             {% if request.assignee %}

-             <span title="{{ request.assignee.username}}" class="ml-3 assigned-user">

-                 <i class="fa fa-fw fa-user-plus pr-2"></i>

-                 {{ request.assignee.username | avatar(size=20) | safe}}

-             </span>

-             {% endif %}

- 

-             <span title="branch to" class="text-muted ml-3">

-                 <span class="fa fa-fw fa-random pr-2"></span>

-                   {{request.branch}}

-               </span>

- 

-             <span title="Comments on the ticket" class="text-muted ml-3">

-               <span class="fa fa-fw fa-comment pr-2"></span>

-                 {{request.user_comments|count}}

-             </span>

-             

-             </span>

          </div>

  </div><!--end request-row-->

  {% endmacro%}

@@ -1,145 +0,0 @@ 

- {% extends "master.html" %}

- 

- {% block title %}Issues for {{ username }}{% endblock %}

- 

- 

- {% block content %}

- <div class="p-t-2">

-   <div class="container">

-     <h3 class="p-b-2">

-         Issues for {{ username | avatar(20) | safe }} {{ username }}

-     </h3>

-     <div>

-       <span class="btn-group btn-group-sm issues-tagbar" role="group">

-           <a data-togglebutton="issue-status-open" id="toggle-open" class="btn btn-primary btn-sm" href="#">Open</a>

-           <a data-togglebutton="issue-status-closed" id="toggle-closed" class="btn btn-secondary btn-sm" href="#">Closed</a>

-           <a data-togglebutton="issue-status-all" class="btn btn-secondary btn-sm" href="#">All</a>

-       </span>

-     </div>

-     <hr>

- 

-     {% for issues in (user.assigned_issues, user.issues) %}

-       {% set outer_loop = loop %}

-       {% if outer_loop.index == 1 %}

-         <b>Assigned Issues <span id="assigned_issue_count"></span></b>

-       {% else %}

-         <b>Opened Issues <span id="opened_issue_count"></span></b>

-       {% endif %}

-       <table class="table table-hover table-striped m-b-0 m-t-1">

-         <thead class="thead-default">

-             <tr>

-                 <th class="nowrap">#</th>

-                 <th>Status</th>

-                 <th>Title</th>

-                 <th class="open_date nowrap">Opened</th>

-                 <th class="open_date nowrap">Modified</th>

-                 <th class="nowrap">Priority</th>

-                 <th class="nowrap">Project</th>

-                 <th class="assigned nowrap">Created by</th>

-                 <th class="assigned nowrap">Assigned to</th>

-             </tr>

-         </thead>

-         <tfoot>

-         </tfoot>

-         <tbody>

-         {% for issue in issues if issue.project.settings.get('issue_tracker', True) %}

-           <tr class="issue-status issue-status-{{issue.status|lower}} loop-index-{{outer_loop.index}}"

-               {%- if issue.status|lower != "open" %} style="display:none;"{% endif %}>

-                 <td class="nowrap"><span class="label label-default">#{{ issue.id }}</span></td>

-                 <td><span class="label {%

-                     if issue.status|lower == 'closed' %}label-danger{%

-                     elif issue.status|lower == 'open'%}label-primary{%

-                     else %}label-default{%

-                     endif%}">{{issue.status}}</span></td>

-                 <td class="stretch-table-column">

-                   <a href="{{ url_for(

-                       'ui_ns.view_issue',

-                       repo=issue.project.name,

-                       username=issue.project.user.username if issue.project.is_fork else None,

-                       namespace=issue.project.namespace,

-                       issueid=issue.id) }}">

-                     {% if issue.private %}

-                         Private Issue

-                     {% else %}

-                         {{ issue.title | noJS("img") | safe }}

-                     {% endif %}

-                   </a>

-                 </td>

-                 <td class="nowrap">

-                     <span title="{{issue.date_created | format_datetime}}">{{

-                         issue.date_created | humanize}}</span>

-                 </td>

-                 <td class="nowrap">

-                     <span title="{{issue.last_updated | format_datetime}}">{{

-                         issue.last_updated | humanize}}</span>

-                 </td>

-                 <td>

-                     {{ issue.project.priorities[issue.priority | string] or '' }}

-                 </td>

-                 <td class="nowrap">

-                   <a href="{{ url_for(

-                     'ui_ns.view_repo',

-                     repo=issue.project.name,

-                     username=issue.project.user.username if issue.project.is_fork else None,

-                     namespace=issue.project.namespace) }}">

-                     {{ issue.project.user.username + '/' if issue.project.is_fork }}

-                     {{ issue.project.namespace + '/' if issue.project.namespace }}

-                     {{ issue.project.name }}

-                   </a>

-                 </td>

-                 <td class="nowrap">

-                   {{ issue.user.default_email | avatar(16) | safe }}

-                   {{ issue.user.user }}

-                 </td>

-                 <td class="nowrap">

-                   {% if issue.assignee %}

-                   {{ issue.assignee.default_email | avatar(16) | safe }}

-                   {{ issue.assignee.user }}

-                   {% else %}

-                   <span class="text-muted">unassigned</span>

-                   {% endif %}

-                 </td>

-             </tr>

-         {% else %}

-             <tr>

-                 <td colspan="9" class="noresult">No issues found</td>

-             </tr>

-         {% endfor %}

-         </tbody>

-       </table>

-       <br>

-     {% endfor %}

-   </div>

- </div>

- 

- {% endblock %}

- 

- {% block jscripts %}

-     {{ super() }}

-     <script type="text/javascript">

-       count_issues(status='.issue-status-open');

-       $(function(){

-         $('.issues-tagbar .btn').click(function(){

-           var current_btn = $(this).attr("data-togglebutton");

-           count_issues(status='.'+current_btn);

-           $('.issues-tagbar .btn-primary').addClass("btn-secondary");

-           $('.issues-tagbar .btn-primary').removeClass("btn-primary");

-           $(this).removeClass("btn-secondary");

-           $(this).addClass("btn-primary");

-           if (current_btn == "issue-status-all"){

-             count_issues(status='');

-             $(".issue-status").show();

-           } else {

-             $(".issue-status").hide();

-             $("."+$(this).attr("data-togglebutton")).show();

-           }

-         });

-       });

-       function count_issues(status='.issue-status-open') {

-         var assigned_issue_count = $(status + '.loop-index-1').length;

-         var opened_issue_count = $(status + '.loop-index-2').length;

-         $('#assigned_issue_count').text(assigned_issue_count);

-         $('#opened_issue_count').text(opened_issue_count);

-       }

-     </script>

- {% endblock %}

@@ -1,173 +0,0 @@ 

- {% extends "master.html" %}

- 

- {% block title %}Pull Requests for {{ username }}{% endblock %}

- 

- 

- {% block content %}

- <div class="p-t-2">

-   <div class="container">

-     <h3 class="p-b-2">

-         Pull Requests for {{ username | avatar(20) | safe }} {{ username }}

-     </h3>

-     <div>

-       <span class="btn-group btn-group-sm issues-tagbar" role="group">

-           <a data-togglebutton="pr-status-open" id="toggle-open"

-             class="btn btn-primary btn-sm">Open</a>

-           <a data-togglebutton="pr-status-merged" id="toggle-merged"

-             class="btn btn-secondary btn-sm">Merged</a>

-           <a data-togglebutton="pr-status-closed" id="toggle-closed"

-             class="btn btn-secondary btn-sm">Closed</a>

-           <a data-togglebutton="pr-status-all"

-             class="btn btn-secondary btn-sm">All</a>

-       </span>

-     </div>

-     <hr>

- 

-     {% for pullrequests in (

-       requests|selectattr("user.username", "equalto", username),

-       requests|rejectattr("user.username", "equalto", username)) %}

-       {% if loop.first %}

-         {% set id="my-pr-table" %}

-         <b>

-           Pull Requests opened by {{ username | avatar(20) | safe }}

-           {{ username }}

-         </b>

-       {% else %}

-         {% set id="pr-table" %}

-         <b>

-           Pull Requests {{ username | avatar(20) | safe }}

-           {{ username }} can act on

-         </b>

-       {% endif %}

-       <table class="table table-hover table-striped m-b-0 m-t-1" id="{{ id }}">

-         <thead class="thead-default">

-           <tr>

-               <th class="nowrap">#</th>

-               <th>Status</th>

-               <th>Title</th>

-               <th>Merge Status</th>

-               <th class="open_date nowrap">Opened</th>

-               <th class="nowrap">Project</th>

-               <th class="nowrap">Opened by</th>

-               <th class="assigned nowrap">Assigned to</th>

-           </tr>

-         </thead>

-         <tfoot>

-         </tfoot>

-         <tbody>

-         {% for request in pullrequests %}

-           <tr class="pr-status pr-status-{{request.status|lower}}"{%

-             if request.status|lower != "open" %}style="display:none;"{%

-             endif %}>

-             <td class="nowrap">

-               <span class="label label-default">PR#{{ request.id }}</span>

-             </td>

-             <td>

-               <span class="label {%

-                 if request.status|lower == 'merged' %}label-success{%

-                 elif request.status|lower == 'closed' %}label-danger{%

-                 elif request.status|lower == 'open' %}label-primary{%

-                 endif %}">{{request.status}}

-               </span>

-             </td>

-             <td class="stretch-table-column">

-               <a href="{{ url_for(

-                 'ui_ns.request_pull',

-                 repo=request.project.name,

-                 username=request.project.user.username if request.project.is_fork else None,

-                 namespace=request.project.namespace,

-                 requestid=request.id) }}">

-                 {{ request.title | noJS("img") | safe }}

-               </a>

-             </td>

-             <td>

-               <span class="label {%

-                 if request.merge_status|lower in ['no_change', 'fforward'] %}label-success{%

-                 elif request.merge_status|lower == 'conflicts' %}label-danger{%

-                 elif request.merge_status|lower == 'merge' %}label-primary{%

-                 endif%}">

-                 {{request.merge_status or 'No Status' | lower}}

-               </span>

-             </td>

-             <td class="nowrap">

-               <span title="{{request.date_created | format_datetime}}">{{

-                 request.date_created | humanize}}</span>

-             </td>

-             <td class="nowrap">

-               <a href="{{ url_for(

-                 'ui_ns.view_repo',

-                 repo=request.project.name,

-                 username=request.project.user.username if request.project.is_fork else None,

-                 namespace=request.project.namespace) }}">

-                 {{ request.project.user.username + '/' if request.project.is_fork }}

-                 {{ request.project.namespace + '/' if request.project.namespace }}

-                 {{ request.project.name }}

-               </a>

-             </td>

-             <td class="nowrap">

-               {{ request.user.default_email | avatar(16) | safe }}

-               {{ request.user.username }}

-             </td>

-             <td class="nowrap">

-               {% if request.assignee %}

-               {{ request.assignee.default_email | avatar(16) | safe }}

-               {{ request.assignee.user }}

-               {% else %}

-               <span class="text-muted">unassigned</span>

-               {% endif %}

-             </td>

-           </tr>

-         {% endfor %}

-           <tr>

-             <td colspan="8" class="pr-status noresult" style="display:none;">

-               No pull-requests found

-             </td>

-           </tr>

-         </tbody>

-       </table>

-       <br>

-     {% endfor %}

-   </div>

- </div>

- 

- {% endblock %}

- 

- {% block jscripts %}

-     {{ super() }}

-     <script type="text/javascript">

-       $(function(){

-         $('.issues-tagbar .btn').click(function(){

-           $('.issues-tagbar .btn-primary').addClass("btn-secondary");

-           $('.issues-tagbar .btn-primary').removeClass("btn-primary");

-           $(this).removeClass("btn-secondary");

-           $(this).addClass("btn-primary");

-           if ($(this).attr("data-togglebutton") == "pr-status-all"){

-             $(".pr-status").show();

-           } else {

-             $(".pr-status").hide();

-             $("."+$(this).attr("data-togglebutton")).show();

-           }

-           showNoResultMessage();

-         });

-       });

- 

-       // Show 'No pull-requests found' message.

-       function showNoResultMessage(){

-         // Flush old view...

-         $('.noresult').hide();

- 

-         // ... and check which should be shown now.

-         if ($('#pr-table .pr-status').filter(':visible').length == 0){

-           $('#pr-table .noresult').show();

-         }

-         if ($('#my-pr-table .pr-status').filter(':visible').length == 0){

-           $('#my-pr-table .noresult').show();

-         }

-       }

- 

-       // Show 'No pull-requests found' message on pageload.

-       $(function(){

-         showNoResultMessage();

-       });

-     </script>

- {% endblock %}

@@ -0,0 +1,87 @@ 

+ {% extends "userprofile_master.html" %}

+ 

+ {% block title %}Issues for {{ username }}{% endblock %}

+ 

+ {% from "_render_issues.html" import render_issue_row %}

+ 

+ 

+ {% block userprofile_content %}

+ <div class="pt-4">

+   <div class="container">

+     <div class="d-flex align-items-center">

+     <h4 class="mb-0 font-weight-bold">

+         Issues for {{ username | avatar(20) | safe }} {{ username }}

+     </h4>

+     <div class="ml-auto">

+       <span class="btn-group btn-group-sm issues-tagbar" role="group">

+           <a data-togglebutton="issue-status-open" id="toggle-open" class="btn btn-primary btn-sm" href="#">Open</a>

+           <a data-togglebutton="issue-status-closed" id="toggle-closed" class="btn btn-outline-primary btn-sm" href="#">Closed</a>

+           <a data-togglebutton="issue-status-all" class="btn btn-outline-primary btn-sm" href="#">All</a>

+       </span>

+     </div>

+     </div>

+     <div class="d-flex mt-4 mb-2 align-items-center">

+       <h5 class="font-weight-bold mb-0">Issues Created</h5>

+       <span class="ml-auto btn btn-outline-secondary border-0 o-100 disabled font-weight-bold">

+         <span id="opened_issue_count"></span> issues

+       </span>

+     </div>

+     {% for issue in user.issues if issue.project.settings.get('issue_tracker', True) %}

+       {% if issue.status|lower != "open" %}

+         {% set hidden = "hidden "%}

+       {% else %}

+         {% set hidden = "" %}

+       {% endif %}

+       {% set htmlclass = hidden+"loop-index-2 issue-status issue-status-"+issue.status|lower%}

+       {{render_issue_row(issue, issue.project, username, class=htmlclass, showproject=True)}}

+     {% endfor %}

+ 

+     <div class="d-flex mt-4 mb-2 align-items-center">

+       <h5 class="font-weight-bold mb-0">Assigned Issues</h5>

+       <span class="ml-auto btn btn-outline-secondary border-0 o-100 disabled font-weight-bold">

+         <span id="assigned_issue_count"></span> issues

+       </span>

+     </div>

+     {% for issue in user.assigned_issues if issue.project.settings.get('issue_tracker', True) %}

+       {% if issue.status|lower != "open" %}

+         {% set hidden = "hidden "%}

+       {% else %}

+         {% set hidden = "" %}

+       {% endif %}

+       {% set htmlclass = hidden+"loop-index-1 issue-status issue-status-"+issue.status|lower%}

+       {{render_issue_row(issue, issue.project, username, class=htmlclass, showproject=True)}}

+     {% endfor %}

+   </div>

+ </div>

+ 

+ {% endblock %}

+ 

+ {% block jscripts %}

+     {{ super() }}

+     <script type="text/javascript">

+       count_issues(status='.issue-status-open');

+       $(function(){

+         $('.issues-tagbar .btn').click(function(){

+           var current_btn = $(this).attr("data-togglebutton");

+           count_issues(status='.'+current_btn);

+           $('.issues-tagbar .btn-primary').addClass("btn-outline-primary");

+           $('.issues-tagbar .btn-primary').removeClass("btn-primary");

+           $(this).removeClass("btn-outline-primary");

+           $(this).addClass("btn-primary");

+           if (current_btn == "issue-status-all"){

+             count_issues(status='');

+             $(".issue-status").show();

+           } else {

+             $(".issue-status").hide();

+             $("."+$(this).attr("data-togglebutton")).show();

+           }

+         });

+       });

+       function count_issues(status='.issue-status-open') {

+         var assigned_issue_count = $(status + '.loop-index-1').length;

+         var opened_issue_count = $(status + '.loop-index-2').length;

+         $('#assigned_issue_count').text(assigned_issue_count);

+         $('#opened_issue_count').text(opened_issue_count);

+       }

+     </script>

+ {% endblock %}

@@ -95,6 +95,24 @@ 

                </div>

              </a>

            </li>

+           <li class="nav-item text-dark">

+               <a class="nav-link d-flex align-items-center {{'active' if select=='issues'}}"

+                 href="{{ url_for('ui_ns.view_user_issues', username=user.username) }}">

+                 <span>

+                   <i class="fa fa-fw text-muted fa-exclamation-circle"></i>

+                   <span class="d-none d-md-inline">Issues&nbsp;</span>

+                 </span>

+               </a>

+             </li>

+             <li class="nav-item text-dark">

+               <a class="nav-link d-flex align-items-center {{'active' if select=='requests'}}"

+                 href="{{ url_for('ui_ns.view_user_requests', username=user.username) }}">

+                 <span>

+                   <i class="fa fa-fw text-muted fa-exclamation-circle"></i>

+                   <span class="d-none d-md-inline">Pull Requests&nbsp;</span>

+                 </span>

+               </a>

+             </li>

          </ul>

      </div>

  

@@ -0,0 +1,97 @@ 

+ {% extends "userprofile_master.html" %}

+ 

+ {% block title %}Pull Requests for {{ username }}{% endblock %}

+ 

+ {% from "_render_pullrequests.html" import render_pullrequest_row %}

+ 

+ {% block userprofile_content %}

+ <div class="pt-4">

+   <div class="container">

+     <div class="d-flex align-items-center">

+       <h4 class="mb-0 font-weight-bold">

+           Pull Requests for {{ username | avatar(20) | safe }} {{ username }}

+       </h4>

+       <div class="ml-auto">

+           <span class="btn-group btn-group-sm issues-tagbar" role="group">

+               <a data-togglebutton="pr-status-open" href="#" id="toggle-open"

+                 class="btn btn-primary btn-sm">Open</a>

+               <a data-togglebutton="pr-status-merged" href="#" id="toggle-merged"

+                 class="btn btn-outline-primary btn-sm">Merged</a>

+               <a data-togglebutton="pr-status-closed" href="#" id="toggle-closed"

+                 class="btn btn-outline-primary btn-sm">Cancelled</a>

+               <a data-togglebutton="pr-status-all" href="#"

+                 class="btn btn-outline-primary btn-sm">All</a>

+           </span>

+       </div>

+     </div>

+ 

+     <div class="d-flex mt-4 mb-2 align-items-center">

+         <h5 class="font-weight-bold mb-0">Pull Requests Created</h5>

+         <span class="ml-auto btn btn-outline-secondary border-0 o-100 disabled font-weight-bold">

+           <span id="opened_pr_count"></span> PRs

+         </span>

+     </div>

+ 

+     {% for request in requests|selectattr("user.username", "equalto", username) %}

+       {% if request.status|lower != "open" %}

+         {% set hidden = "hidden "%}

+       {% else %}

+         {% set hidden = "" %}

+       {% endif %}

+     {% set htmlclass = hidden+"pr-created pr-status pr-status-"+request.status|lower%}

+       {{render_pullrequest_row(request, request.project, username, class=htmlclass, showproject=True)}}

+     {% endfor %}

+ 

+ 

+     <div class="d-flex mt-4 mb-2 align-items-center">

+         <h5 class="font-weight-bold mb-0">Pull Requests {{username}} can act on</h5>

+         <span class="ml-auto btn btn-outline-secondary border-0 o-100 disabled font-weight-bold">

+           <span id="assigned_pr_count"></span> PRs

+         </span>

+     </div>

+ 

+     {% for request in requests|rejectattr("user.username", "equalto", username) %}

+       {% if request.status|lower != "open" %}

+         {% set hidden = "hidden "%}

+       {% else %}

+         {% set hidden = "" %}

+       {% endif %}

+     {% set htmlclass = hidden+"pr-assigned pr-status pr-status-"+request.status|lower%}

+       {{render_pullrequest_row(request, request.project, username, class=htmlclass, showproject=True)}}

+     {% endfor %}

+   </div>

+ </div>

+ 

+ {% endblock %}

+ 

+ {% block jscripts %}

+     {{ super() }}

+     <script type="text/javascript">

+       count_issues(status='.pr-status-open');

+       $(function(){

+         $('.issues-tagbar .btn').click(function(){

+           var current_btn = $(this).attr("data-togglebutton");

+           count_issues(status='.'+current_btn);

+           $('.issues-tagbar .btn-primary').addClass("btn-outline-primary");

+           $('.issues-tagbar .btn-primary').removeClass("btn-primary");

+           $(this).removeClass("btn-outline-primary");

+           $(this).addClass("btn-primary");

+           if (current_btn == "pr-status-all"){

+             count_issues(status='');

+             $(".pr-status").show();

+           } else {

+             $(".pr-status").hide();

+             $("."+$(this).attr("data-togglebutton")).show();

+           }

+           showNoResultMessage();

+         });

+       });

+ 

+       function count_issues(status='.pr-status-open') {

+         var assigned_pr_count = $(status + '.pr-assigned').length;

+         var opened_pr_count = $(status + '.pr-created').length;

+         $('#assigned_pr_count').text(assigned_pr_count);

+         $('#opened_pr_count').text(opened_pr_count);

+       }

+     </script>

+ {% endblock %}

file modified
+16 -2
@@ -891,8 +891,16 @@ 

          flask.g.session, username=username

      )

  

+     userprofile_common = get_userprofile_common(user)

+ 

      return flask.render_template(

-         "user_requests.html", username=username, user=user, requests=requests

+         "userprofile_pullrequests.html",

+         username=username,

+         user=user,

+         requests=requests,

+         select="requests",

+         repos_length=userprofile_common["repos_length"],

+         forks_length=userprofile_common["forks_length"],

      )

  

  
@@ -910,9 +918,15 @@ 

          flask.abort(404, "Tickets have been disabled on this pagure instance")

  

      user = _get_user(username=username)

+     userprofile_common = get_userprofile_common(user)

  

      return flask.render_template(

-         "user_issues.html", username=username, user=user

+         "userprofile_issues.html",

+         username=username,

+         user=user,

+         repos_length=userprofile_common["repos_length"],

+         forks_length=userprofile_common["forks_length"],

+         select='issues',

      )

  

  

@@ -1491,7 +1491,7 @@ 

          output_text = output.get_data(as_text=True)

          self.assertIn('test pull-request #1', output_text)

          self.assertEqual(

-             output_text.count('<tr class="pr-status pr-status-open"'),

+             output_text.count('pr-status pr-status-open"'),

              1)

  

          # Add a PR in a fork
@@ -1527,7 +1527,7 @@ 

          self.assertIn('test pull-request #1', output_text)

          self.assertIn('t├ęst pull-request #2', output_text)

          self.assertEqual(

-             output_text.count('<tr class="pr-status pr-status-open"'),

+             output_text.count('pr-status pr-status-open"'),

              2)

  

      @patch(
@@ -1577,7 +1577,7 @@ 

          self.assertIn('test pull-request #1', output_text)

          self.assertIn('test pull-request #2', output_text)

          self.assertEqual(

-             output_text.count('<tr class="pr-status pr-status-open"'),

+             output_text.count('pr-status pr-status-open"'),

              2)

  

          # Check foo's PR list
@@ -1587,7 +1587,7 @@ 

          self.assertNotIn('test pull-request #1', output_text)

          self.assertIn('test pull-request #2', output_text)

          self.assertEqual(

-             output_text.count('<tr class="pr-status pr-status-open"'),

+             output_text.count('pr-status pr-status-open"'),

              1)

  

      @patch(
@@ -1619,7 +1619,7 @@ 

          output_text = output.get_data(as_text=True)

          self.assertIn('test pull-request #1', output_text)

          self.assertEqual(

-             output_text.count('<tr class="pr-status pr-status-open"'),

+             output_text.count('pr-status pr-status-open"'),

              1)

  

      def test_view_my_issues_no_user(self):
@@ -1654,7 +1654,7 @@ 

          self.assertIn('Test issue #1', output_text)

          self.assertEqual(

              output_text.count(

-                 '<tr class="issue-status issue-status-open'),

+                 'issue-status issue-status-open'),

              1)

  

          # Add an issue in a fork
@@ -1711,7 +1711,7 @@ 

          self.assertIn('Test issue #3', output_text)

          self.assertEqual(

              output_text.count(

-                 '<tr class="issue-status issue-status-open'),

+                 'issue-status issue-status-open'),

              3)

  

      @patch(
@@ -1742,7 +1742,7 @@ 

          output_text = output.get_data(as_text=True)

          self.assertIn('Test issue #1', output_text)

          self.assertEqual(

-             output_text.count('<tr class="issue-status issue-status-open'),

+             output_text.count('issue-status issue-status-open'),

              1)

  

          # Disable issue tracking
@@ -1759,7 +1759,7 @@ 

          output_text = output.get_data(as_text=True)

          self.assertNotIn('Test issue #1', output_text)

          self.assertEqual(

-             output_text.count('<tr class="issue-status issue-status-open'),

+             output_text.count('issue-status issue-status-open'),

              0)

  

      def test_view_my_issues_tickets_turned_off(self):

@@ -947,7 +947,7 @@ 

          # sort by last_updated

          output = self.app.get('/test/pull-requests?order_key=last_updated')

          output_text = output.get_data(as_text=True)

-         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

+         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action ">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

          self.assertEqual(output.status_code, 200)

          # Make sure that issue four is first since it was modified last

          self.assertIn('href="/test/pull-request/4"', tr_elements[0])
@@ -963,7 +963,7 @@ 

          # sort by last_updated

          output = self.app.get('/test/pull-requests?order_key=last_updated')

          output_text = output.get_data(as_text=True)

-         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

+         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action ">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

          self.assertEqual(output.status_code, 200)

          # Make sure that PR four is first since it was modified last

          self.assertIn('href="/test/pull-request/1"', tr_elements[0])
@@ -977,7 +977,7 @@ 

          output = self.app.get('/test/pull-requests?'

                  'order_key=last_updated&order=asc')

          output_text = output.get_data(as_text=True)

-         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

+         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action ">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

          self.assertIn('href="/test/pull-request/2"', tr_elements[0])

          self.assertIn('href="/test/pull-request/4"', tr_elements[1])

          self.assertIn('href="/test/pull-request/1"', tr_elements[2])
@@ -985,13 +985,13 @@ 

          #check that search_pattern argument works

          output = self.app.get('/test/pull-requests?search_pattern=feature')

          output_text = output.get_data(as_text=True)

-         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

+         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action ">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

          self.assertIn('href="/test/pull-request/1"', tr_elements[0])

          self.assertEqual(len(tr_elements), 1)

  

          output = self.app.get('/test/pull-requests?search_pattern=PR')

          output_text = output.get_data(as_text=True)

-         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

+         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action ">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

          self.assertIn('href="/test/pull-request/4"', tr_elements[0])

          self.assertIn('href="/test/pull-request/2"', tr_elements[1])

          self.assertIn('href="/test/pull-request/1"', tr_elements[2])
@@ -999,7 +999,7 @@ 

  

          output = self.app.get('/test/pull-requests?search_pattern=*PR')

          output_text = output.get_data(as_text=True)

-         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

+         tr_elements = re.findall('<div class="request-row list-group-item list-group-item-action ">(.*?)</div><!--end request-row-->', output_text, re.M | re.S)

          self.assertEqual(len(tr_elements), 1)

          self.assertIn('href="/test/pull-request/2"', tr_elements[0])

  

@@ -898,7 +898,7 @@ 

          # Sort by last_updated

          output = self.app.get('/test/issues?order_key=last_updated')

          self.assertEqual(output.status_code, 200)

-         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

                                     output.get_data(as_text=True), re.M | re.S)

          # Make sure that issue four is first since it was modified last

          self.assertIn('href="/test/issue/4"', tr_elements[0])
@@ -914,7 +914,7 @@ 

          self.session.commit()

          output = self.app.get('/test/issues?order_key=last_updated')

          self.assertEqual(output.status_code, 200)

-         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

                                     output.get_data(as_text=True), re.M | re.S)

          # Make sure that issue one is first since it was modified last

          self.assertIn('href="/test/issue/1"', tr_elements[0])
@@ -926,7 +926,7 @@ 

          self.assertIn('href="/test/issue/2"', tr_elements[2])

          # Now query so that the results are ascending

          output = self.app.get('/test/issues?order_key=last_updated&order=asc')

-         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

                                     output.get_data(as_text=True), re.M | re.S)

  

          self.assertIn('href="/test/issue/2"', tr_elements[0])
@@ -936,7 +936,7 @@ 

          # Sort by title descending

          output = self.app.get('/test/issues?order_key=title')

          self.assertEqual(output.status_code, 200)

-         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

                                     output.get_data(as_text=True), re.M | re.S)

  

          self.assertIn('href="/test/issue/2"', tr_elements[0])
@@ -946,7 +946,7 @@ 

          # Sort by title ascending

          output = self.app.get('/test/issues?order_key=title&order=asc')

          self.assertEqual(output.status_code, 200)

-         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

                                     output.get_data(as_text=True), re.M | re.S)

  

          self.assertIn('href="/test/issue/4"', tr_elements[0])
@@ -956,7 +956,7 @@ 

          # Sort by user (reporter/author) descending

          output = self.app.get('/test/issues?order_key=user&order=desc')

          self.assertEqual(output.status_code, 200)

-         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

                                     output.get_data(as_text=True), re.M | re.S)

  

          # We check that they are unassigned, otherwise our previous check is
@@ -970,7 +970,7 @@ 

          # Sort by user (reporter/author) ascending

          output = self.app.get('/test/issues?order_key=user&order=asc')

          self.assertEqual(output.status_code, 200)

-         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

                                     output.get_data(as_text=True), re.M | re.S)

  

          # Check for the name after the avatar
@@ -1003,7 +1003,7 @@ 

          # Sort by assignee descending

          output = self.app.get('/test/issues?order_key=assignee&order=desc')

          self.assertEqual(output.status_code, 200)

-         #tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action">(.*?)</div><!-- end issuerow -->',

+         #tr_elements = re.findall(r'<div class="issuerow list-group-item list-group-item-action ">(.*?)</div><!-- end issuerow -->',

          #                           output.get_data(as_text=True), re.M | re.S)

          #arrowed_th = ('Assignee</a>\n            <span class="oi" data-glyph='

          #              '"arrow-thick-bottom"></span>')