Skip to content

create volunteer-headshot component - #788

Merged
joshsmith merged 1 commit into
code-corps:developfrom
WenInCode:add-volunteer-headshot-component
Mar 29, 2017
Merged

create volunteer-headshot component#788
joshsmith merged 1 commit into
code-corps:developfrom
WenInCode:add-volunteer-headshot-component

Conversation

@WenInCode

Copy link
Copy Markdown
Contributor

What's in this PR?

Changes

  • Created volunteer-headshot component
  • Created volunteer-headshot page-object
  • Added tests

Todo

  • add styling
  • use the component in the thankyou page.

References

Fixes #678

@joshsmith

Copy link
Copy Markdown
Contributor

@WenInCode think maybe there's a misunderstanding here. We want to take one of the roles out of the user's own user-roles and use that for display.

@WenInCode

Copy link
Copy Markdown
Contributor Author

@joshsmith ha that makes so much more sense

@joshsmith

Copy link
Copy Markdown
Contributor

@WenInCode sorry! Did I not explain it well enough in the issue?

@joshsmith

Copy link
Copy Markdown
Contributor

I think I didn't. Was pretty vague.

@joshsmith joshsmith modified the milestones: Donations, Improve Donations Nov 27, 2016
@joshsmith

Copy link
Copy Markdown
Contributor

@WenInCode is this reviewable now?

@WenInCode

Copy link
Copy Markdown
Contributor Author

@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.

@WenInCode
WenInCode force-pushed the add-volunteer-headshot-component branch from 14f26dc to d6a7dee Compare December 1, 2016 05:11
@WenInCode

Copy link
Copy Markdown
Contributor Author

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.

  • styles
  • selecting subset of contributors

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.

code_corps

@joshsmith

Copy link
Copy Markdown
Contributor

@WenInCode this is great progress. Also, you look like a pretty prolific person there! Backend Developer and Tester and Data Scientist. 🔥 🔥 🔥 🚒

@WenInCode

WenInCode commented Dec 4, 2016

Copy link
Copy Markdown
Contributor Author

Updated a bunch of things. The volunteer list loads a bit slowly because the userRoles or roles (forgot which) aren't side loaded.

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.

Here's an image of 12 of me as bill murray:
code_corps

@marineb

marineb commented Dec 4, 2016

Copy link
Copy Markdown
Contributor

@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 sbatson5 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just a few suggestions/questions. This is looking great 👍

Comment thread app/components/thank-you-container.js Outdated
return get(orgMembership, 'member');
});

if (volunteers.length > 12) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ya that sounds good to me. Normally when I'm working with magic numbers I would remember to do this! Good catch 👍

Comment thread app/components/volunteer-headshot.js Outdated
@property volunteerName
@type String
*/
volunteerName: computed('volunteer.name', 'volunteer.firstName', 'volunteer.lastName', function() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I completely forgot about the inline if 😜 - thanks!

'Designer & Developer'
];

function generateUserRoles() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@WenInCode

Copy link
Copy Markdown
Contributor Author

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 remote

git remote add [whatever you want to call the remote] [the remotes url]

# ex.
git remote add wenincode https://github.com/wenincode/code-corps-ember

fetch the changes

git fetch wenincode 

# or get all
git fetch --all

checkout branches

and then you chould be able to checkout into the branch.

git checkout add-volunteer-headshot-component

push changes

When your ready just push to your changes to my remote (I will give you commit access to my repo)

git push wenincode add-volunteer-headshot-component

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.

@WenInCode

Copy link
Copy Markdown
Contributor Author

@sbatson5 I've addressed the feedback you've given - thanks again!
Putting this back into review.

@marineb

marineb commented Dec 5, 2016

Copy link
Copy Markdown
Contributor

@WenInCode I wasn't able to push directly to your codebase, so I sent you a PR.

Comment thread app/components/thank-you-container.js Outdated
@property nonPendingMemberships
@type Ember.Array
*/
nonPendingMemberships: computed('organizationMemberships.[]', 'organizationMemberships.@each.role', function() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the reason for doing .[] and .@each.role?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@WenInCode I figured this was the case and I reviewed top to bottom here, so the other comments are laggard comments.

Comment thread app/components/thank-you-container.js Outdated

if (isPresent(memberships)) {
return memberships.filter((membership) => {
let isPending = get(membership, 'isPending');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread app/components/thank-you-container.js Outdated
if (isPresent(nonPendingMemberships)) {
let volunteers = nonPendingMemberships.map((orgMembership) => {
return get(orgMembership, 'member');
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can do Ember.computed.mapBy instead. See above for how to put an approvedMembers directly on the organization model.

Comment thread app/components/thank-you-container.js Outdated
volunteers: computed('nonPendingMemberships', function() {
let nonPendingMemberships = get(this, 'nonPendingMemberships');

if (isPresent(nonPendingMemberships)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you need isPresent here?

Comment thread app/components/volunteer-headshot.js Outdated
'volunteer.userRoles.@each.user',
function() {
return this.get('volunteer.userRoles');
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just an alias here?

Comment thread app/components/volunteer-headshot.js Outdated
} else if (isPresent(firstName) && isPresent(lastName)) {
return `${firstName} ${lastName}`;
} else {
return '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the else would fallback to their username, which we know must be set.

Comment thread app/components/volunteer-headshot.js Outdated
@property isVolunteerNamePresent
@type Boolean
*/
isVolunteerNamePresent: computed.notEmpty('volunteerName'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can remove this if you implement the above comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ya I had originally put it because I was getting some fun undefined undefined as names, because the members promise hadn't resolved.

Comment thread app/components/volunteer-headshot.js Outdated
altText: computed('volunteerName', function() {
let name = get(this, 'volunteerName');

return `${name}\'s headshot`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use a URL here that doesn't make an extra HTTP request?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@joshsmith that's a good idea... but no more great photos of Bill Murray in tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😢

@WenInCode
WenInCode force-pushed the add-volunteer-headshot-component branch 2 times, most recently from 12baefb to d0816eb Compare December 7, 2016 05:02
@WenInCode

Copy link
Copy Markdown
Contributor Author

I believe I have addressed all the feedback. I rebased as there was a conflict with develop.

This should be ready for review. Thanks to all who have put time into this!

@joshsmith

Copy link
Copy Markdown
Contributor

@WenInCode can you repush to restart the build? Thanks!

@WenInCode
WenInCode force-pushed the add-volunteer-headshot-component branch from d0816eb to d522986 Compare December 8, 2016 15:37
@WenInCode
WenInCode force-pushed the add-volunteer-headshot-component branch from b508ac6 to 0580a9a Compare January 26, 2017 00:40
@joshsmith

Copy link
Copy Markdown
Contributor

@WenInCode to fix the build, try to change circle.yml L30 from ./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info to COVERAGE=true ./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info

@WenInCode
WenInCode force-pushed the add-volunteer-headshot-component branch from 29b9c58 to e7e8f49 Compare February 1, 2017 17:45
@joshsmith

Copy link
Copy Markdown
Contributor

@WenInCode there are some conflicts now due to some upstream CSS changes merging in #846.

@WenInCode
WenInCode force-pushed the add-volunteer-headshot-component branch from e7e8f49 to 2972d36 Compare March 1, 2017 16:37
@WenInCode

Copy link
Copy Markdown
Contributor Author

@joshsmith should be good to review again

@joshsmith
joshsmith force-pushed the add-volunteer-headshot-component branch 3 times, most recently from 74c3d35 to 5f562f2 Compare March 29, 2017 20:59
@joshsmith
joshsmith force-pushed the add-volunteer-headshot-component branch from 5f562f2 to dcbb7e9 Compare March 29, 2017 21:00
@joshsmith
joshsmith merged commit 5488f92 into code-corps:develop Mar 29, 2017
@joshsmith
joshsmith deleted the add-volunteer-headshot-component branch March 29, 2017 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants