Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Feature/12711/user autocomplete #39

Merged
merged 44 commits into from
Jul 2, 2018

Conversation

arpanfactual
Copy link
Contributor

📝 Description

Issue #12711

Copy link
Contributor

@joecox joecox left a comment

Choose a reason for hiding this comment

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

Good work @arpanfactual!

A couple things in addition to comments:

  • You can remove the client/app/bundles/KudosApp/reducers/appReducer.jsx file committed here.
  • You can remove the root level package.json that is committed.
  • If you merge master into here, you'll get saraht's husky/prettier fix. That will get you some nice auto-formatting when you commit. It helps you adhere to the code style without having to do anything.

}

const MODAL_STORE = new ModalStore()
export default MODAL_STORE
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's not enough here for a new store. Can you put the action and observable in the AppStore?

}
}

export default AllUsers;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need this model, I don't see that it adds anything over an Array.

@@ -18,13 +20,15 @@ class AppStore {
@action
loadClientData(props) {
this.user = new User(props.user)
this.allUsers = new AllUsers(props.allUsers)
Copy link
Contributor

Choose a reason for hiding this comment

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

per my previous comment, this can just be an array. So assigning props.allUsers directly.

@@ -16,7 +16,7 @@
"@types/jss": {
"version": "9.5.3",
"resolved": "https://registry.npmjs.org/@types/jss/-/jss-9.5.3.tgz",
"integrity": "sha512-RQWhcpOVyIhGryKpnUyZARwsgmp+tB82O7c75lC4Tjbmr3hPiCnM1wc+pJipVEOsikYXW0IHgeiQzmxQXbnAIA==",
"integrity": "sha1-DBBt4/4LMkzUFz+sfasmwSzaYk4=",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why your local is using SHA1 but others are using SHA512. What version of node/npm are you running?

@@ -17,6 +17,9 @@ export const actionTypes = mirrorCreator([
'FETCH_KUDOS_REQUEST',
'FETCH_KUDOS_FAILURE',
'FETCH_KUDOS_SUCCESS',
'MODAL_SWITCH',
'FETCH_ALL_EMAILS',
'FETCH_ALL_USERS'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this file is left over from the redux way, you can remove.

render() {
return(
<div className="give-kudo">
<button className="styled-kudo-button open-modal" onClick={this.modalClick.bind(this)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just pass the modalSwitch/toggleModal function here directly.

onClick={ AppStore.toggleModal }

Since modalSwitch/toggleModal doesn't do anything with arguments, it's fine to call it with the single event argument.

</button>
{MODAL_STORE.showModal ?
<GiveKudo showModal={MODAL_STORE.showModal}
modalClick={this.modalClick}
Copy link
Contributor

Choose a reason for hiding this comment

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

You won't need this here either, since you can use AppStore.toggleModal straight up in GiveKudo.

},
}).then(res => {
return res.data.map(obj => _.pick(obj, ['name', 'email']))
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is going away, you should also remove the action and route in Rails.

return res.data.map(obj => _.pick(obj, ['name', 'email']))
})
const getEmailFromUser = (userString) => {
//react-select gives values as name | email, so must parse email from that
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the react-select docs, it seems like your onChange would get passed an array of objects, and thus you would avoid this issue, if you made simpleValue to be false. Have you tried that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that simpleValue will give one long string that consists of all of the values returned which this function doesn't really deal with (this one deals with the actual content of each of the values) so each element in the array. This does bring up the point that I am splitting the string for no reason in my onchange function as I could just set simpleValue to true and get the array anyways

@@ -67,98 +51,110 @@ export class GiveKudo extends React.Component {
this.setState({ inFlight: true })
AppStore.kudosStore.newKudo(this.state.emails, this.state.message)
this.setState(this._initialState())
this.props.modalClick(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and below I think you can just use AppStore.toggleModal.

@joecox
Copy link
Contributor

joecox commented Jun 28, 2018

I got it running locally, looks really good!!

A couple usability things I noticed:

  1. can the give kudo buttons have cursor: pointer applied?
  2. the self-kudo easter egg is not centered anymore
  3. when you're in the select component, I expect hitting 'tab' to put me into the next field (the message textarea), but it selects the top user from the select instead
  4. can you make the modal not scroll with the page? I don't know if adds much usability, and it can run into a problem where you can't submit or close the modal if you expand the text area enough:

kudo-modal

  1. How difficult would it be to close modal on click outside of the modal?

@arpanfactual
Copy link
Contributor Author

Yeah these are all great comments that I’ll look into; actually a lot of the clicking functionality and movement of the modal was fixed with that modalcover component and it’s styling so I gotta look into what happened there! Thanks again for goin through and catching all of this

@arpanfactual arpanfactual reopened this Jun 29, 2018
@arpanfactual
Copy link
Contributor Author

all the comments have been addressed but the package-lock changes! Not sure what's happening; if I take masters package-lock and then install react-select, everything changes.

Also, the tab issue is a bit more involved than i thought. It might not be something for this PR. The React Select owners have discussed it thoroughly and are still looking for a stand
screen shot 2018-06-29 at 3 31 51 pm

but adjusting the value component was messing up styling for some reason. I'm definitely willing to look into it in another ticket!

JedWatson/react-select#643

Copy link
Contributor

@joecox joecox left a comment

Choose a reason for hiding this comment

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

Really awesome job @arpanfactual!

Thanks for looking into the react-select and package lock shenanigans, and great work with the usability!

Still seeing client/app/bundles/KudosApp/reducers/appReducer.jsx, can you remove?

For the package-lock, to me it seems like https://stackoverflow.com/a/47834854 is the culprit. I think you may have tried this fix given the npm in the package.json - are you running npm install inside or outside the container?

We can meet anytime if you'd like to look at anything together!

@@ -40,6 +40,7 @@
"mirror-creator": "1.1.0",
"mobx": "^4.3.1",
"mobx-react": "^5.2.0",
"npm": "^6.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I saw this get removed from package-lock, but's let's remove from package.json too.

# hsh[u.name] = u.email
# end
# end

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove the commented out sections altogether.

@@ -51,11 +30,11 @@ export class GiveKudo extends React.Component {
// Uses lodash to bind all methods to the context of the object instance, otherwise
// the methods defined here would not refer to the component's class, not the component
// instance itself.
_.bindAll(this, 'handleClick', 'onChangeSearchInput', 'setMessage')
_.bindAll(this, 'handleClick', 'onSelectChange', 'setMessage', 'onSuccess', 'onFailure')
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, not sure why this worked before this PR, since you added the _ lodash import. But let's make it consistent with the other imports: you can refer here to bindAll, and then import bindAll in the spread on line 1, along with isEmpty and trim.

function constructOptions(user) {
const filterValue = `${user[0]} ${user[1]}`
const displayValue = `${user[0]} (${user[1]})`
return { value: filterValue, label: displayValue, email: user[1] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Style tip: you can avoid the magic number-y array accesses here if you use an array destructure in the parameter list:

function constructOptions([ name, email ]) {
  ...
}

Additional style tip: if you assign to value and label instead of filterValue and displayValue, you can use the object assignment es6 shorthand:

return { value, label, email }

@arpanfactual arpanfactual merged commit 4af5f95 into master Jul 2, 2018
@arpanfactual arpanfactual deleted the feature/12711/user_autocomplete branch July 2, 2018 21:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants