#3381 fix pr-dropdown messed up label for forks
Merged 5 years ago by pingou. Opened 5 years ago by ryanlerch.
ryanlerch/pagure pr-dropdown  into  master

@@ -823,6 +823,10 @@ 

    font-size:0.9em;

  }

  

+ .font-size-1{

+   font-size:1em;

+ }

+ 

  .opacity-100{

    opacity:1!important;

  }

@@ -99,9 +99,9 @@ 

                  <i class="fa fa-arrow-circle-down fa-fw"></i> Open PR

                </a>

                <div class="dropdown-menu dropdown-menu-right" id="PR-dropdown">

-                 <a class="dropdown-item ">

-                   <small><img  id="spinnergif"

-                     src="{{ url_for('static', filename='images/spinner.gif') }}">

+                 <a class="dropdown-item" id="spinnergif">

+                   <small><img

+                     src="{{ url_for('static', filename='images/spinner.gif') }}" />

                    </small>

                  </a>

                  {% if head %}
@@ -404,91 +404,102 @@ 

  <script>

  

  {% if g.authenticated and not g.repo_obj.is_empty %}

+ 

+ {% if g.repo_committer %}

  $(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 }}",

+       namespace: "{{ repo.namespace if repo.namespace }}",

+       repouser: "",

        csrf_token: "{{ g.confirmationform.csrf_token.current_token }}",

      },

      dataType: 'json',

      error: function(res) {

-       $('#spinnergif').hide()

-       console.log(res);

+        console.log(res);

      },

      success: function(res) {

-       $('#spinnergif').hide()

-       console.log("done");

        if (res.code == 'OK'){

+         var first_item = true;

          for (branch in res.message.new_branch){

-             var url = "{{ url_for(

+           if (first_item){

+             $("#PR-dropdown").prepend("<div class='dropdown-divider'></div>")

+             first_item = false;

+           }

+           var url = "{{ url_for(

              'ui_ns.new_request_pull',

              repo=repo.name,

-             username=g.fas_user.username,

+             username=repo.user.user if repo.is_fork else None,

              namespace=repo.namespace,

              branch_to='',

              branch_from='') }}";

            url = url.slice(0, -2) + res.message.new_branch[branch]['target_branch'] + '..' + branch;

-           html = '<a class="dropdown-item" \

-           href="' + url + '">From <span class="badge badge-secondary" style="font-size:0.9em;">'

-           + '<i class="fa fa-code-fork fa-fw"> </span> '

-           +'{{ g.fas_user.username }}/{{ repo.name }}</span> '

-           +'<span class="badge badge-secondary" style="font-size:0.9em;">'

-           +'<span class="fa fa-random"> </span> '

-           + branch + '</span></a> ';

+           html = '<a class="dropdown-item" href="' + url + '">'

+             + '<span class="badge badge-light badge-pill border border-secondary font-size-1">'

+               + ' <i class="fa fa-calendar-o fa-rotate-270 fa-fw"></i> '

+               + '{{ repo.name }}'

+             + '</span> '

+             + '<span class="badge badge-secondary border border-secondary badge-pill font-size-1">'

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

+               + branch

+             + '</span></a> ';

            $("#PR-dropdown").prepend(html);

          }

        }

      }

    });

  });

+ {% endif %}

  

- {% 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: "",

+       repo: "{{ repo.name }}",

+       repouser: "{{ g.fas_user.username }}",

        csrf_token: "{{ g.confirmationform.csrf_token.current_token }}",

      },

      dataType: 'json',

      error: function(res) {

-        console.log(res);

+       $('#spinnergif').hide()

+       console.log(res);

      },

      success: function(res) {

+       $('#spinnergif').hide()

        console.log("done");

        if (res.code == 'OK'){

+         var first_item = true;

          for (branch in res.message.new_branch){

+           if (first_item){

+             $("#PR-dropdown").prepend("<div class='dropdown-divider'></div>");

+             first_item = false;

+           }

            var url = "{{ url_for(

              'ui_ns.new_request_pull',

              repo=repo.name,

-             username=repo.user.user if repo.is_fork else None,

+             username=g.fas_user.username,

              namespace=repo.namespace,

              branch_to='',

              branch_from='') }}";

            url = url.slice(0, -2) + res.message.new_branch[branch]['target_branch'] + '..' + branch;

-           html = '<a class="dropdown-item" href="' + url + '">'

-             + 'From <span class="badge badge-secondary" style="font-size:0.9em;">'

-               + ' <i class="fa fa-calendar-o fa-rotate-270 fa-fw"></i> '

-               + '{{ repo.name }}'

-             + '</span> '

-             + '<span class="badge badge-secondary" style="font-size:0.9em;">'

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

-               + branch

-             + '</span></a> ';

+           html = '<a class="dropdown-item" \

+           href="' + url + '"><span class="badge badge-light badge-pill border border-secondary font-size-1">'

+           + '<i class="fa fa-code-fork fa-fw"></i>'

+           +'{{ g.fas_user.username }}/{{ repo.name }}</span> '

+           +'<span class="badge badge-secondary border border-secondary badge-pill font-size-1">'

+           +'<i class="fa fa-random"></i> '

+           + branch + '</span></a> ';

            $("#PR-dropdown").prepend(html);

          }

        }

      }

    });

  });

- {% endif %}

+ 

  {% endif %}

  </script>

  {% endblock %}

Fixes the weird rendering of the labels in the
New PR dropdown when listing branches from Forks

Fixes #3376

This also styles up the labels to be the same as
in the PR page.

Screenshot_from_2018-06-28_12-17-55.png

This seems a little odd, was it changed by accident before?

This looks a little odd, if you're in a fork this won't work no?

@pingou the diff looks a little weird because i swapped the order of the forks and main branches ajax calls, so it kinda looks like they are wrong looking at the diffs, but its because the code is similar, but slightly different...

rebased onto e423f0b5737c060231366ebb162c024d31c1c9d9

5 years ago

We could drop the g.authenticated since we're checking this just above, I'll take care of this

rebased onto 86837c0

5 years ago

Local tests looks fine, let's re-run jenkins and merge :)

Pretty please pagure-ci rebuild

Pull-Request has been merged by pingou

5 years ago