Blob Blame Raw
{% extends "repo_master.html" %}

{% from "_render_repo.html" import pagination_link %}

{% block title %}Pull requests - {{
    repo.namespace + '/' if repo.namespace }}{{ repo.name }}{% endblock %}
{% set tag = "home" %}


{% block repo %}

<div>
  <h2 class="p-b-1">
    {{ requests|count }} {%-
    if status and status|lower != 'open' and status|lower != 'false'
     %} {{ status }} {%-
    elif status|lower in ['closed', 'false']
    %} Closed/Merged {%- endif
    %} Pull Requests (of {{ requests_cnt }})
    {% if g.authenticated and repo.settings.get('pull_requests', True) %}
        <span id="request_pull" class="inline_it">

        </span>

    <div class="dropdown float-right" id="PR-dropdown">
      <button class="btn btn-primary btn-sm dropdown-toggle"
        type="button" id="dropdownMenu1" data-toggle="dropdown"
        aria-haspopup="true" aria-expanded="false">
        File Pull Request
      </button>
      <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu1">
        <a class="dropdown-item ">
          <small><img  id="spinnergif"
            src="{{ url_for('static', filename='images/spinner.gif') }}">
          </small>
        </a>
        <a class="dropdown-item" href="{{ url_for(
            'ui_ns.new_remote_request_pull',
            repo=repo.name,
            username=username,
            namespace=repo.namespace) }}">
          <small>Remote pull-request</small>
        </a>
      </div>
    </div>
    {%endif%}
  </h2>

<div>
  <span class="btn-group btn-group-sm issues-tagbar py-3" role="group">
      <a class="btn {%
            if status|lower in ['open', 'true'] %}btn-primary{%
            else %}btn-secondary{%
            endif %} btn-sm" href="{{ url_for(
                'ui_ns.request_pulls',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">Open</a>
      <a class="btn {%
        if status|lower in ['closed', 'false'] %}btn-primary{%
        else %}btn-outline-dark{%
        endif %} btn-sm" href="{{ url_for(
            'ui_ns.request_pulls',
            repo=repo.name,
            username=username,
            author=author,
            namespace=repo.namespace,
            status=0) }}">Closed</a>
      <a class="btn {%
        if status|lower in ['all', 'none'] %}btn-primary{%
        else %}btn-outline-dark{%
        endif %} btn-sm" href="{{ url_for(
            'ui_ns.request_pulls',
            repo=repo.name,
            username=username,
            author=author,
            namespace=repo.namespace,
            status='all') }}">All</a>
  </span>
  <a class="btn btn-outline-dark btn-sm float-right mt-2" href="{{ url_for(
    'ui_ns.request_pulls',
    repo=repo.name,
    username=username,
    namespace=repo.namespace) }}">Reset Filters</a>
</div>
</div>
<div class="card m-t-1 table-responsive">
<table id="pagure-issues-list" class="table table-hover table-striped mb-0">
    <thead class="thead-default">
        <tr>
            <th class="stretch-table-column">Pull Request</th>
            <th class="branch_to nowrap">To</th>
            <th class="open_date nowrap">Opened</th>
            <th class="last_updated nowrap">Modified</th>
            {% if status|lower not in ['open', 'true'] %}
            <th class="closed_date nowrap">Closed</th>
            {% endif %}
            <th class="open_by">
              Reporter(<a href="{{ url_for(
                'ui_ns.request_pulls',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                assignee=assignee, status=status) }}">reset</a>)
            </th>
            {% if status|lower == 'open' %}
            <th class="assigned">
              Assignee(<a href="{{ url_for(
                'ui_ns.request_pulls',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                author=author, status=status) }}">reset</a>)
            </th>
            {% endif %}
        </tr>
    </thead>
    <tfoot>
    </tfoot>
    <tbody>
    {% for request in requests %}
        <tr>
            <td>
              <a href="{{ url_for(
                  'ui_ns.request_pull',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace,
                  requestid=request.id) }}">
                <span class="label label-default">PR#{{ request.id }}</span>
                {% if status|lower not in ['open', 'true'] %}<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>{%
                  endif %} {{ request.title | noJS("img") | safe }}
              </a>
              {% if request.user_comments|count > 0 %}
               &nbsp;&nbsp;
              <span class="text-muted">
                <span class="oi" data-glyph="comment-square"
                    title="Comments on the Pull Request"></span>
                  {{ request.user_comments|count }}
              </span>
              {% endif %}
            </td>
            <td class="nowrap">
              <span>{{ request.branch }}</span>
            </td>
            <td class="nowrap">
              <span title="{{request.date_created | format_datetime}}">{{
                request.date_created | humanize}}</span>
            </td>
            <td class="nowrap">
              <span title="{{request.last_updated | format_datetime}}">{{
                request.updated_on | humanize}}</span>
            </td>
            {% if status|lower not in ['open', 'true'] %}
            <td class="nowrap">
              <span title="{{
                request.closed_at | format_datetime
                if request.closed_at
              }}">{{
                request.closed_at | humanize
                if request.closed_at }}</span>
            </td>
            {% endif %}
            <td class="nowrap">
              <a href="{{ url_for(
                  'ui_ns.request_pulls',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace,
                  author=request.user.user,
                  assignee=assignee, status=status) }}"
                  title="Filter requests by reporter">
                {{ request.user.default_email | avatar(16) | safe }}
                {{ request.user.user }}
              </a>
            </td>
            {% if status|lower in ['open', 'true'] %}
            <td class="nowrap">
              {% if request.assignee %}
              <a href="{{ url_for(
                'ui_ns.request_pulls',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                assignee=request.assignee.username,
                author=author, status=status) }}"
                title="Filter issues by assignee">
                {{ request.assignee.default_email | avatar(16) | safe }}
                {{ request.assignee.user }}
              </a>
              {% else %}
              <a class="text-muted" href="{{ url_for(
                'ui_ns.request_pulls',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                assignee=0,
                author=author, status=status) }}">unassigned</a>
              {% endif %}
            </td>
            {% endif %}
        </tr>
    {% else %}
        <tr>
            <td colspan="6" class="noresult">No Pull Requests found</td>
        </tr>
    {% endfor %}
    </tbody>
</table>
</div>
{{ pagination_link('page', g.page, total_page) }}
{% endblock %}



{% block jscripts %}
{{ super() }}
{% if g.authenticated %}
<script type="text/javascript">

$(function() {
  $.ajax({
    url: '{{ url_for("internal_ns.get_pull_request_ready_branch") }}' ,
    type: 'POST',
    data: {
      namespace: "{{ repo.namespace if repo.namespace }}",
      repo: "{{ repo.name }}",
      repouser: "{{ g.fas_user.username }}",
      csrf_token: "{{ form.csrf_token.current_token }}",
    },
    dataType: 'json',
    error: function(res) {
      $('#spinnergif').hide()
      console.log(res);
    },
    success: function(res) {
      $('#spinnergif').hide()
      console.log("done");
      if (res.code == 'OK'){
        for (branch in res.message.new_branch){
            var url = "{{ url_for(
            'ui_ns.new_request_pull',
            repo=repo.name,
            username=g.fas_user.username,
            namespace=repo.namespace,
            branch_to=head,
            branch_from='') }}" + branch;
          html = '<small><a class="dropdown-item" \
          href="' + url + '">From <span class="pr-toplabel">'
          + '<span class="oi" data-glyph="fork"> </span>'
          +'{{ g.fas_user.username }}/{{ repo.name }}</span> '
          +'<span class="pr-toplabel">'
          +'<span class="oi" data-glyph="random"> </span>'
          + branch + '</span></a></small> ';
          $("#PR-dropdown .dropdown-menu").prepend(html);
        }
      }
    }
  });
});

{% if g.authenticated and g.repo_committer %}
$(function() {
  $.ajax({
    url: '{{ url_for("internal_ns.get_pull_request_ready_branch") }}' ,
    type: 'POST',
    data: {
      repo: "{{ repo.name }}",
      namespace: "{{ repo.namespace if repo.namespace }}",
      repouser: "",
      csrf_token: "{{ form.csrf_token.current_token }}",
    },
    dataType: 'json',
    error: function(res) {
       console.log(res);
    },
    success: function(res) {
      console.log("done");
      if (res.code == 'OK'){
        for (branch in res.message.new_branch){
          var url = "{{ url_for(
            'ui_ns.new_request_pull',
            repo=repo.name,
            username=repo.user.user if repo.is_fork else None,
            namespace=repo.namespace,
            branch_to=head,
            branch_from='') }}";
          html = '<small><a class="dropdown-item" href="' + url + branch + '">'
            + 'From <span class="pr-toplabel">'
              + '<span class="oi" data-glyph="document"> </span>'
              + '{{ repo.name }}'
            + '</span>'
            + '<span class="pr-toplabel">'
              + '<span class="oi" data-glyph="random"> </span>'
              + branch
            + '</span></a></small> ';
          $("#PR-dropdown .dropdown-menu").prepend(html);
        }
      }
    }
  });
});
{% endif %}
</script>
{% endif %}
{% endblock %}