#4937 Add orphan button to project page
Merged 3 years ago by pingou. Opened 3 years ago by zlopez.
zlopez/pagure orphan  into  master

@@ -105,7 +105,7 @@ 

              {% endif %}

              {% if not repo.is_fork %}

              <div class="text-muted">Created {{repo.date_created|humanize}}</div>

-             <div class="text-muted">

+             <div class="text-muted" id="point_of_contact_div">

                {% if repo.user.user != 'orphan' %}

                  Maintained by

                  <a href="{{ url_for('ui_ns.view_user', username=repo.user.user)}}"

@@ -118,6 +118,21 @@ 

      {% endif %}

    </div>

  

+   {% if g.authenticated and repo.user.user == g.fas_user.username %}

+   <div id="orphan-section" class="pt-3">

+       <div class="col-xs-2 line-height-1"></div>

+       <h6>Orphaned:</h6>

+       <div class="btn-group">

+           <a href="#" title="Orphan this package"

+              class="btn btn-sm btn-outline-primary"

+              id="orphan-button">

+               <i id="orphan-icon" class="fa fa-fw fa-hand-paper-o"></i>

+               Orphan

+           </a>

+       </div>

+   </div>

+   {% endif %}

+ 

    {% if g.authenticated and repo.user.user == "orphan" %}

    <div id="take-orphan-section" class="pt-3">

      <div class="col-xs-2 line-height-1"></div>
@@ -331,6 +346,7 @@ 

            success: function(res) {

              $("#point_of_contact").html("{{ g.fas_user.username }}");

              $("#take-orphan-section").hide();

+             $("#orphan-section").show();

            },

            error: function(res) {

              if (res.responseJSON.errors) {
@@ -365,6 +381,28 @@ 

        });

        {% endif %}

  

+       {% if g.authenticated and repo.user.user == g.fas_user.username %}

+       $("#orphan-button").click(function(){

+ 

+         $.ajax({

+           url: "{{ url_for('distgit_ns.orphan_endpoint', repo=repo.name, namespace=repo.namespace) }}",

+           type: 'POST',

+           dataType: 'json',

+           success: function(res) {

+             $("#point_of_contact_div").html("Package is currently unmaintained");

+             $("#orphan-section").hide();

+             $("#take-orphan-section").show();

+           },

+           error: function(res) {

+             if (res.responseJSON.errors) {

+               alert('Unable to orphan the package: ' + res.responseJSON.errors);

+             } else {

+               alert('Unable to orphan the package: ' + res.responseJSON.error);

+             }

+           }

+         });

+       });

+       {% endif %}

      });

    </script>

    {% endif %}

The API endpoint only allows calls from the current POC, so we could simply check if repo.user.user == g.fas_user.username

rebased onto e0ac0d178762fa4bf9c41c8b93355650522bf316

3 years ago

The API endpoint only allows calls from the current POC, so we could simply check if repo.user.user == g.fas_user.username

Fixed

I believe we may not want the button disabled :)

I believe we may not want the button disabled :)

Hm, I actually copied the take-orphan section :-D

rebased onto 887303e1bae658eb17530fcac41f73048b0c845d

3 years ago

rebased onto b80a3c976691162f9b17572dd7d3460f66649b39

3 years ago

rebased onto aa953ae

3 years ago

Working great, thanks!

Pull-Request has been merged by pingou

3 years ago