Skip to content

Commit

Permalink
Show right-hand column on version page to crate owners.
Browse files Browse the repository at this point in the history
Among other things, this makes the "Manage owners" link available even if all versions of a crate were yanked.
  • Loading branch information
smarnach committed Jun 5, 2019
1 parent 293a3fb commit c7823b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
5 changes: 5 additions & 0 deletions app/controllers/crate/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export default Controller.extend({
isOwner: computed('crate.owner_user', 'session.currentUser.id', function() {
return this.get('crate.owner_user').findBy('id', this.get('session.currentUser.id'));
}),
notYankedOrIsOwner: computed('model', 'crate.owner_user', 'session.currentUser.id', function() {
return (
!this.get('model').yanked || this.get('crate.owner_user').findBy('id', this.get('session.currentUser.id'))
);
}),

sortedVersions: readOnly('crate.versions'),

Expand Down
28 changes: 15 additions & 13 deletions app/templates/crate/version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@
</div>
</div>

{{#if currentVersion.yanked}}
<div class='crate-info'>
<div>
<p>This crate has been yanked, but it is still available for download for
other crates that may be depending on it.</p>
<p>You may wish to
{{#link-to 'crate.versions' crate}}view all versions{{/link-to}} to find one that
has not been yanked.
</p>
</div>
</div>
{{else}}
<div class='crate-info'>
<div class='docs'>
{{#if currentVersion.yanked}}
<p>
This crate has been yanked, but it is still available for download for other crates that
may be depending on it.
</p>
<p>
You may wish to {{#link-to 'crate.versions' crate}}view all versions{{/link-to}} to find
one that has not been yanked.
</p>
{{else}}
<div class='install'>
<div class='action'>Cargo.toml</div>
<code id="crate-toml">{{ crate.name }} = "{{ currentVersion.num }}"</code>
Expand Down Expand Up @@ -99,7 +97,9 @@
</div>
{{/if}}
{{/if}}
{{/if}}
</div>
{{#if notYankedOrIsOwner}}
<section class='authorship' aria-label="Crate metadata">
<div class='top'>
<div>
Expand Down Expand Up @@ -240,8 +240,10 @@
{{/if}}
</div>
</section>
{{/if}}
</div>

{{#unless currentVersion.yanked}}
<div id='crate-downloads'>
<div class='stats'>
<h3>Stats Overview</h3>
Expand Down Expand Up @@ -293,4 +295,4 @@
{{download-graph data=downloadData}}
</div>
</div>
{{/if}}
{{/unless}}

0 comments on commit c7823b4

Please sign in to comment.