-
Notifications
You must be signed in to change notification settings - Fork 610
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 user details. #416
Merged
Merged
Show user details. #416
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4f02499
[WIP] Show user details.
wlonk 3f42fe8
Fix linting errors in user unit test.
wlonk 0b60db6
Improve per-user crate display.
wlonk f23672c
Add long crate views for arbitrary users.
wlonk 320c437
Remove placeholder tests.
wlonk 49a944a
Fix linting errors.
wlonk 9f37091
Actually search crates by user_id, not username
wlonk c790e33
Remove auth-required on route.
wlonk 4176b21
Show crates properly on user profile pages
wlonk 1d9cbac
Fix linting problems
wlonk 135dcd6
Collapse /users/:user_id and /users/:user_id/crates
wlonk 0fbd282
Move crate version owner link targets to Crates' own user pages
wlonk 224c741
Add github profile link.
wlonk 6f7fc78
Add padding around crate author heading
wlonk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Ember from 'ember'; | ||
|
||
const TO_SHOW = 5; | ||
const { computed } = Ember; | ||
|
||
export default Ember.Controller.extend({ | ||
init() { | ||
this._super(...arguments); | ||
|
||
this.fetchingFeed = true; | ||
this.loadingMore = false; | ||
this.hasMore = false; | ||
this.crates = []; | ||
}, | ||
|
||
visibleCrates: computed('crates', function() { | ||
return this.get('crates').slice(0, TO_SHOW); | ||
}), | ||
|
||
hasMoreCrates: computed('crates', function() { | ||
return this.get('crates.length') > TO_SHOW; | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Ember from 'ember'; | ||
import PaginationMixin from '../../mixins/pagination'; | ||
|
||
const { computed } = Ember; | ||
// TODO: reduce duplicatoin with controllers/crates | ||
|
||
export default Ember.Controller.extend(PaginationMixin, { | ||
queryParams: ['page', 'per_page', 'sort'], | ||
page: '1', | ||
per_page: 10, | ||
sort: 'alpha', | ||
|
||
totalItems: computed.readOnly('model.crates.meta.total'), | ||
|
||
currentSortBy: computed('sort', function() { | ||
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical'; | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
data: {}, | ||
|
||
setupController(controller, model) { | ||
this._super(controller, model); | ||
|
||
controller.set('fetchingFeed', true); | ||
controller.set('crates', this.get('data.crates')); | ||
}, | ||
|
||
model(params) { | ||
return this.store.find('user', params.user_id).catch(e => { | ||
if (e.errors.any(e => e.detail === 'Not Found')) { | ||
this.controllerFor('application').set('nextFlashError', `User '${params.user_id}' does not exist`); | ||
return this.replaceWith('index'); | ||
} | ||
}); | ||
}, | ||
|
||
afterModel(user) { | ||
let crates = this.store.query('crate', { | ||
user_id: user.get('id') | ||
}); | ||
|
||
return Ember.RSVP.hash({ | ||
crates, | ||
}).then((hash) => this.set('data', hash)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
queryParams: { | ||
page: { refreshModel: true }, | ||
sort: { refreshModel: true }, | ||
}, | ||
|
||
model(params) { | ||
const { user_id } = this.paramsFor('user'); | ||
return this.store.find('user', user_id).then( | ||
(user) => { | ||
params.user_id = user.get('id'); | ||
return Ember.RSVP.hash({ | ||
crates: this.store.query('crate', params), | ||
user | ||
}); | ||
}, | ||
(e) => { | ||
if (e.errors.any(e => e.detail === 'Not Found')) { | ||
this | ||
.controllerFor('application') | ||
.set('nextFlashError', `User '${params.user_id}' does not exist`); | ||
return this.replaceWith('index'); | ||
} | ||
} | ||
); | ||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div id='crates-heading'> | ||
{{#user-link user=model}} | ||
{{user-avatar user=model size='medium'}} | ||
{{/user-link}} | ||
<h1> | ||
{{#link-to 'user' model}} | ||
{{ model.login }} | ||
{{/link-to}} | ||
</h1> | ||
</div> | ||
|
||
<div id='user-profile'> | ||
<div class='info'> | ||
{{outlet}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{{! TODO: reduce duplication with templates/crates.hbs }} | ||
|
||
<div id='results'> | ||
<div class='nav'> | ||
<span class='amt small'> | ||
Displaying | ||
<span class='cur'>{{ currentPageStart }}-{{ currentPageEnd }}</span> | ||
of <span class='total'>{{ totalItems }}</span> total results | ||
</span> | ||
</div> | ||
|
||
<div class='sort'> | ||
<span class='small'>Sort by</span> | ||
{{#rl-dropdown-container class="dropdown-container"}} | ||
{{#rl-dropdown-toggle tagName="a" class="dropdown"}} | ||
<img class="sort" src="/assets/sort.png"/> | ||
{{ currentSortBy }} | ||
<span class='arrow'></span> | ||
{{/rl-dropdown-toggle}} | ||
|
||
{{#rl-dropdown tagName="ul" class="dropdown" closeOnChildClick="a:link"}} | ||
<li> | ||
{{#link-to (query-params sort="alpha")}} | ||
Alphabetical | ||
{{/link-to}} | ||
</li> | ||
<li> | ||
{{#link-to (query-params sort="downloads")}} | ||
Downloads | ||
{{/link-to}} | ||
</li> | ||
{{/rl-dropdown}} | ||
{{/rl-dropdown-container}} | ||
</div> | ||
</div> | ||
|
||
<div id='crates' class='white-rows'> | ||
{{#each model.crates as |crate|}} | ||
{{crate-row crate=crate}} | ||
{{/each}} | ||
</div> | ||
|
||
<div class='pagination'> | ||
{{#link-to (query-params page=prevPage) class="prev" rel="prev" title="previous page"}} | ||
<img class="left-pag" src="/assets/left-pag.png"/> | ||
{{/link-to}} | ||
{{#each pages as |page|}} | ||
{{#link-to (query-params page=page)}}{{ page }}{{/link-to}} | ||
{{/each}} | ||
{{#link-to (query-params page=nextPage) class="next" rel="next" title="next page"}} | ||
<img class="right-pag" src="/assets/right-pag.png"/> | ||
{{/link-to}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p> | ||
Generic profile information here. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what should we do about this? More in the main thread. |
||
</p> | ||
|
||
{{#link-to 'user.crates' model.login}} | ||
See all their crates | ||
{{/link-to}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small note here; eventually, controllers are going away in Ember, so this might be extra-fine for now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah; I've been trying to train myself out of them, with little success so far!