Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show right-hand column for yanked versions to crate owners. #1759

Merged
merged 4 commits into from
Aug 30, 2019

Conversation

smarnach
Copy link
Contributor

@smarnach smarnach commented Jun 5, 2019

Fixes #1660.

Without this change, the page for a yanked version looks like this:

image

With this change applied, crate owners see this page instead:

image

@smarnach smarnach force-pushed the manage-owners-yanked branch from df74424 to c7823b4 Compare June 5, 2019 20:06
Among other things, this makes the "Manage owners" link available even if all versions of a crate were yanked.
@smarnach smarnach force-pushed the manage-owners-yanked branch from c7823b4 to 3bde7dd Compare June 5, 2019 20:19
@smarnach smarnach changed the title Show right-hand column on version page to crate owners. Show right-hand column for yanked versions to crate owners. Jun 5, 2019
@@ -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() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add unit tests for this computed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure we could, but I'm not familiar with Ember or Mirage, so I'm not sure what's the best way to do this. I've added an attempt as a new commit that tries to use Mirage to set up a new crate and a version. The test passes in its current form, but has a few problems:

  • I was only able to use the Mirage factories when running the whole application with setupApplicationTest(). This seems unnecessary and makes the test much slower than it should be.
  • Testing the other cases (yanked crate, with the user being owner or not) requires also faking an active session and user accounts. I couldn't find any existing infrastructure to do so in a unit test.

We may be able to test this with an acceptance test instead, but at least for me this would involve significant effort. Maybe someone more experienced with Ember could add this test?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies @smarnach, I should've added a bit more direction here. Ember can generate default unit tests that should avoid needing to use mirage. The problems you point out highlight the many concerns of acceptance / integration testing I hoped to avoid by suggesting a unit test. I'll open a PR against your branch with a simple unit test.

Copy link

@ghost ghost Jun 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing this in my fork, but you can create test files using ember generate commands.

ember generate controller-test crate/version

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was lazy and didn't fork your copy, but here is the working example of the unit test: https://github.com/rust-lang/crates.io/compare/master...efx:unit-test-controller?expand=1#diff-a30cef8546b1174ebf3c37a550e2357f

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, this looks a lot more reasonable than my attempt! I guess I should learn a bit more about Ember before doing any more work on the frontend. :)

I've copied your test to this branch (and force-pushed, since my attempt isn't worth being preserved in the Git history).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

certainly @smarnach. Eh, learning on the go seems most efficient 😄. Grand!

@locks locks self-assigned this Jun 18, 2019
@smarnach smarnach force-pushed the manage-owners-yanked branch from 4656a9e to 234a9ac Compare June 19, 2019 16:01
@kzys
Copy link
Contributor

kzys commented Jul 17, 2019

Looks good to me.

@smarnach
Copy link
Contributor Author

smarnach commented Aug 4, 2019

@locks @kzys Is there anything I can do to move this forward? It would be great if we could get this merged.

@ghost
Copy link

ghost commented Aug 29, 2019

@locks any objections to merging this?

@smarnach smarnach mentioned this pull request Aug 30, 2019
@carols10cents
Copy link
Member

The text wrapping is different now if you're not an owner, but I'm fine with it.

Screen Shot 2019-08-30 at 4 46 00 PM

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 30, 2019

📌 Commit 234a9ac has been approved by carols10cents

@bors
Copy link
Contributor

bors commented Aug 30, 2019

⌛ Testing commit 234a9ac with merge 27bd9a8...

bors added a commit that referenced this pull request Aug 30, 2019
Show right-hand column for yanked versions to crate owners.

Fixes #1660.

Without this change, the page for a yanked version looks like this:

![image](https://user-images.githubusercontent.com/249196/58944345-ec823d00-8781-11e9-9322-019250a6fb1d.png)

With this change applied, crate owners see this page instead:

![image](https://user-images.githubusercontent.com/249196/58944390-0de32900-8782-11e9-9c58-ac649c9c23c0.png)
@bors
Copy link
Contributor

bors commented Aug 30, 2019

☀️ Test successful - checks-travis
Approved by: carols10cents
Pushing 27bd9a8 to master...

@bors bors merged commit 234a9ac into rust-lang:master Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to manage ownership of a crate through the UI if all versions have been yanked
6 participants