create volunteer-headshot component - #788
Conversation
|
@WenInCode think maybe there's a misunderstanding here. We want to take one of the roles out of the user's own |
|
@joshsmith ha that makes so much more sense |
|
@WenInCode sorry! Did I not explain it well enough in the issue? |
|
I think I didn't. Was pretty vague. |
|
@WenInCode is this reviewable now? |
|
@joshsmith negative, working on putting it on the thank-you page and need to add styling. Working on it right now, but I will likely finish tomorrow as it's pretty late. |
14f26dc to
d6a7dee
Compare
|
I didn't get to work as much as I had hoped to over the past two days, but here is some progress (I only had 1 contributor so I hard coded more). There are still some things that need to be finished.
It has been fun to try and do some scss even if I am not great at it yet. Sorry this is taking longer than expected. |
|
@WenInCode this is great progress. Also, you look like a pretty prolific person there! Backend Developer and Tester and Data Scientist. 🔥 🔥 🔥 🚒 |
|
Updated a bunch of things. The volunteer list loads a bit slowly because the One thing I have not figured out is how to center-align the list of contributors. I could use some help there. Otherwise, I think this is ready for review. Tests are passing locally, not sure why they were killed in circle. |
|
@WenInCode I'd be happy to help center align the contributors (though I'm not sure how to checkout your branch). Let me know if you still want someone to chime in. |
sbatson5
left a comment
There was a problem hiding this comment.
Just a few suggestions/questions. This is looking great 👍
| return get(orgMembership, 'member'); | ||
| }); | ||
|
|
||
| if (volunteers.length > 12) { |
There was a problem hiding this comment.
Thoughts on extracting 12 out to a constant at the top of this component? It seems like a magic number when reading over this. if (volunteers.length > MAX_VOLUNTEERS) may make it a bit more clear.
There was a problem hiding this comment.
Ya that sounds good to me. Normally when I'm working with magic numbers I would remember to do this! Good catch 👍
| @property volunteerName | ||
| @type String | ||
| */ | ||
| volunteerName: computed('volunteer.name', 'volunteer.firstName', 'volunteer.lastName', function() { |
There was a problem hiding this comment.
If we are observing multiple properties on 1 object, we can simplify what we are observing to:
computed('volunteer.{name,firstName,lastName}', ...
| <p class="volunteer-headshot__role" data-test-selector="volunteer role">{{userRole.role.name}}</p> | ||
| {{else}} | ||
| <p class="volunteer-headshot__role" data-test-selector="volunteer role">Volunteer</p> | ||
| {{/if}} |
There was a problem hiding this comment.
Rather than doing the if/else block, it looks like we can get away with an inline if since we are only updating 1 item.
<p class="volunteer-headshot__role" data-test-selector="volunteer role">
{{if userRole userRole.role.name "Volunteer"}}
</p>
There was a problem hiding this comment.
I completely forgot about the inline if 😜 - thanks!
| 'Designer & Developer' | ||
| ]; | ||
|
|
||
| function generateUserRoles() { |
There was a problem hiding this comment.
Since we are just adding 1 object per role to this array (i.e. the number of roles never varies), thoughts on just making it static to start with:
const usersRoles = [
{ role: { name: 'Developer' } },
{ role: { name: 'Ember Developer' } },
{ role: { name: 'UX Designer' } },
{ role: { name: 'Software Engineer' } },
{ role: { name: 'Project Coordinator' } },
{ role: { name: 'Designer & Developer } }'
];
This way we aren't rebuilding this on every test.
|
Thanks @sbatson5 for the feedback! @marineb help would be greatly appreciated! The way I work with someone else's fork is the following: add the remotefetch the changescheckout branchesand then you chould be able to checkout into the branch. push changesWhen your ready just push to your changes to my remote (I will give you commit access to my repo) I have never actually pushed changes to someones remote, but this is the flow I normally use if I want to pull down someones changes. |
|
@sbatson5 I've addressed the feedback you've given - thanks again! |
|
@WenInCode I wasn't able to push directly to your codebase, so I sent you a PR. |
| @property nonPendingMemberships | ||
| @type Ember.Array | ||
| */ | ||
| nonPendingMemberships: computed('organizationMemberships.[]', 'organizationMemberships.@each.role', function() { |
There was a problem hiding this comment.
What is the reason for doing .[] and .@each.role?
There was a problem hiding this comment.
@joshsmith I had an idea of why I was doing this, but I wasn't sure I was right. So I threw together this twiddle to show the differences.
- computed property on an array of objects won't recompute on things being pushed/popped from the array if
obj.[]is not used. - computed property on an array of objects won't recompute if an object in that arrays attributes change without
@each.thatattribute
However, I agree with your statement below, so this will probably be taken out. But I figured I should still investigate.
There was a problem hiding this comment.
@WenInCode I figured this was the case and I reviewed top to bottom here, so the other comments are laggard comments.
|
|
||
| if (isPresent(memberships)) { | ||
| return memberships.filter((membership) => { | ||
| let isPending = get(membership, 'isPending'); |
There was a problem hiding this comment.
The organization model has a line pendingMemberships: filterBy('organizationMemberships', 'isPending'). Maybe we could have an approvedMemberships and then you can just compute on the approvedMemberships?
There was a problem hiding this comment.
agreed. one thing is that the role has to be fetched, so there is a portion of time where role on the memberships is undefined. During that loading, all memberships with undefined roles will be not pending.
I guess what I am getting at is the cleanest way to do it is (and the way I have changed it to):
approvedMemberships: computed.filterBy('organizationMemberships', 'isNotPending'),
but that does not filter properly when role is undefined.
| if (isPresent(nonPendingMemberships)) { | ||
| let volunteers = nonPendingMemberships.map((orgMembership) => { | ||
| return get(orgMembership, 'member'); | ||
| }); |
There was a problem hiding this comment.
You can do Ember.computed.mapBy instead. See above for how to put an approvedMembers directly on the organization model.
| volunteers: computed('nonPendingMemberships', function() { | ||
| let nonPendingMemberships = get(this, 'nonPendingMemberships'); | ||
|
|
||
| if (isPresent(nonPendingMemberships)) { |
There was a problem hiding this comment.
Do you need isPresent here?
| 'volunteer.userRoles.@each.user', | ||
| function() { | ||
| return this.get('volunteer.userRoles'); | ||
| }), |
There was a problem hiding this comment.
Why not just an alias here?
| } else if (isPresent(firstName) && isPresent(lastName)) { | ||
| return `${firstName} ${lastName}`; | ||
| } else { | ||
| return ''; |
There was a problem hiding this comment.
In the else would fallback to their username, which we know must be set.
| @property isVolunteerNamePresent | ||
| @type Boolean | ||
| */ | ||
| isVolunteerNamePresent: computed.notEmpty('volunteerName'), |
There was a problem hiding this comment.
Can remove this if you implement the above comment.
There was a problem hiding this comment.
ya I had originally put it because I was getting some fun undefined undefined as names, because the members promise hadn't resolved.
| altText: computed('volunteerName', function() { | ||
| let name = get(this, 'volunteerName'); | ||
|
|
||
| return `${name}\'s headshot`; |
There was a problem hiding this comment.
Would remove "headshot" here, and let the alt text just be their name.
| beforeEach() { | ||
| this.set('user', { | ||
| name: 'Test User', | ||
| photoThumbUrl: 'http://fillmurray.com/200/200', |
There was a problem hiding this comment.
Can we use a URL here that doesn't make an extra HTTP request?
There was a problem hiding this comment.
@joshsmith that's a good idea... but no more great photos of Bill Murray in tests.
12baefb to
d0816eb
Compare
|
I believe I have addressed all the feedback. I rebased as there was a conflict with This should be ready for review. Thanks to all who have put time into this! |
|
@WenInCode can you repush to restart the build? Thanks! |
d0816eb to
d522986
Compare
b508ac6 to
0580a9a
Compare
|
@WenInCode to fix the build, try to change |
29b9c58 to
e7e8f49
Compare
|
@WenInCode there are some conflicts now due to some upstream CSS changes merging in #846. |
e7e8f49 to
2972d36
Compare
|
@joshsmith should be good to review again |
74c3d35 to
5f562f2
Compare
5f562f2 to
dcbb7e9
Compare


What's in this PR?
Changes
volunteer-headshotcomponentvolunteer-headshotpage-objectTodo
References
Fixes #678