-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
…Factual/kudos into feature/12711/user_autocomplete
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.
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 |
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.
I think there's not enough here for a new store. Can you put the action and observable in the AppStore
?
} | ||
} | ||
|
||
export default AllUsers; |
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.
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) |
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.
per my previous comment, this can just be an array. So assigning props.allUsers
directly.
client/package-lock.json
Outdated
@@ -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=", |
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.
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' |
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.
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)}> |
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.
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} |
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.
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'])) | ||
}) |
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.
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 |
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.
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?
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.
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); |
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.
Here and below I think you can just use AppStore.toggleModal
.
I got it running locally, looks really good!! A couple usability things I noticed:
|
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 |
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.
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!
client/package.json
Outdated
@@ -40,6 +40,7 @@ | |||
"mirror-creator": "1.1.0", | |||
"mobx": "^4.3.1", | |||
"mobx-react": "^5.2.0", | |||
"npm": "^6.1.0", |
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.
I think I saw this get removed from package-lock, but's let's remove from package.json too.
app/models/user.rb
Outdated
# hsh[u.name] = u.email | ||
# end | ||
# end | ||
|
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.
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') |
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.
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] } |
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.
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 }
📝 Description
Issue #12711