-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/3 ali login page #11
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
base: development
Are you sure you want to change the base?
Conversation
83bc803 to
1f6046c
Compare
| "react-router-redux": "^4.0.5", | ||
| "redux": "^3.5.2", | ||
| "redux-action": "^1.0.0", | ||
| "redux-actions": "^1.2.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.
Use both redux-action and redux-actions?
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.
only redux-actions
| "redux": "^3.5.2", | ||
| "redux-action": "^1.0.0", | ||
| "redux-actions": "^1.2.0", | ||
| "redux-devtools-extension": "^1.0.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.
Is it possible to move to redux-devtools-extension to devDependencies?
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 it not ...
| "redux-saga": "^0.13.0" | ||
| }, | ||
| "devDependencies": { | ||
| "ava": "^0.17.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.
This test runner is interesting. How did you know it?
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.
hmm I saw it on Evan's repo
src/Auth/LoginContainer.js
Outdated
| this.onFormLogin = this.onFormLogin.bind(this); | ||
| } | ||
|
|
||
| onChangeUsername(event) { |
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.
onChangeUsername({ target: { value: username } = {}} = {})?
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.
Hmm, it seems to be a good idea to introduce redux-form to get rid of handling controlled elements by ourself. Thoughts?
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.
onChangeUsername? onUsernameChange?
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.
- okay,
redux-form, I survey it. If I want to useredux-formandgrommet, I should customize the component.onUsernameChange, because another one isonFormLogin, it's notonLoginForm
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.
onUsernameChange, because another one is onFormLogin, it's not onLoginForm
Why do you mention this?
src/Auth/LoginContainer.js
Outdated
|
|
||
| onFormLogin() { | ||
| const { username } = this.props; | ||
| if (username.length === 0) return; |
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.
if (this.props.username.length === 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.
okay
| type: 'CHANGE_USERNAME', | ||
| payload: { username }, | ||
| }, | ||
| )); |
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 need another test to prove that changeUsername is not returning a hard-coded string that happens to be Ali.
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.
okay, add the other test for bill
| type: 'LOGIN_REQUEST', | ||
| payload: {}, | ||
| }, | ||
| )); |
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 need another test to prove that it always returns an empty object as the payload.
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.
hmm 不懂意思 0 _ 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.
或者該說,這是這樣的單元測試能夠呈現出來的嗎 ="=?
你後面提的需求
- 確保每次都回傳空的 object(意思是要傳值進去,出來的結果還是 object嗎?)
- username 是不是串接而成(感覺這要兩次測試確保是不是兩次結果的 contact)
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.
ping?
| { username: '' }, | ||
| changeUsername({ username }), | ||
| { username }, | ||
| )); |
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 need another test to prove that its not doing string concat of username
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.
同上
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.
ping?
| gen.next().value, | ||
| select(), | ||
| ); | ||
| }); |
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 need another test to prove that it does get authModule from the store and use authModule.username to update localStorage
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.
想一下...
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.
ping?
| import { LOGIN_REQUEST } from '../../src/Auth/authModule'; | ||
| import loginFlow from '../../src/Auth/authSaga'; | ||
|
|
||
| test('loginFlow', (t) => { |
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.
t is not descriptive at all. Is it a convention to use t when you use ava?
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.
hmm . just follow the document sample @@
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.
ok. It is a convention to use ava then.
|
Also this PR is super complex. I suggest do one thing in one PR. |
|
|
||
| onChangeUsername(event) { | ||
| const username = event.target.value.trim(); | ||
| onUsernameChange({ target: { value: username } = {} } = {}) { |
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.
No more .trim()?
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.
done
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.
ping?
.babelrc
Outdated
| @@ -1,5 +1,5 @@ | |||
| { | |||
| "presets": ["react", "es2015"], | |||
| "presets": ["react", "es2015", "stage-2"], | |||
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.
How about "presets": ["react", "es2015", "transform-object-rest-spread"], 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.
Whatever way it is, package.json should be updated right?
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.
done!
src/store/localStorage.js
Outdated
| import localStoragePackage from 'localStorage'; | ||
|
|
||
| let localStorage = localStoragePackage; // eslint-disable-line | ||
| // eslint-disable-next-line import/no-mutable-exports |
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.
In stead of disabling eslint, do you think it's better to just do:
const localStorage = process.env.NODE_ENV === 'test' ? localStoragePackage ? global.window.localStorage;
?
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.
okay
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.
ping?
NOT YET
|
src/Root/routes.js
Outdated
| } else if (!isAuthenticated && pathname !== '/login') { | ||
| replace('/login'); | ||
| } else if (isAuthenticated) { | ||
| return; |
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 just realise why this looks strange to me. Basically, /login is a public page. However, you nest /login beneath private page root. Thus you are working around your own auth check code.
| const theOtherUsername = 'Bill'; | ||
|
|
||
| test('Action: changeUsername', actionTest( | ||
| test('Action: changeUsername: Alice', actionTest( |
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.
This test description doesn't really help in terms of understanding what's the purpose of this test. Same as the next test.
|
argh.... It seems that I review your work in progress ........... |
|
I guess we need a protocol. how about when you are done, ping me on fb? |
|
Do you want to give https://reviewable.io/ a try? I can set it up. |
|
Review status: 0 of 20 files reviewed at latest revision, 37 unresolved discussions. src/Auth/LoginContainer.js, line 20 at r1 (raw file): Previously, sharils (sharils) wrote…
I just want to tell you that I use onUsernameChange . Because it's same rule with src/Auth/LoginContainer.js, line 39 at r1 (raw file): Previously, sharils (sharils) wrote…
okay src/Auth/LoginContainer.js, line 48 at r1 (raw file): Previously, sharils (sharils) wrote…
I think the pull request is too big. If I real want to change the template, I will open the other issue to resolve this problem. src/Auth/LoginContainer.js, line 50 at r1 (raw file): Previously, sharils (sharils) wrote…
got it , 3Q! src/Auth/LoginContainer.js, line 20 at r3 (raw file): Previously, sharils (sharils) wrote…
why you ping this? src/store/localStorage.js, line 3 at r5 (raw file): Previously, sharils (sharils) wrote…
done test/Auth/authModule.js, line 10 at r1 (raw file): Previously, sharils (sharils) wrote…
uh oh ... test/Auth/authSaga.js, line 6 at r1 (raw file): Previously, sharils (sharils) wrote…
hmm Comments from Reviewable |
|
ok Review status: 0 of 20 files reviewed at latest revision, 37 unresolved discussions. Comments from Reviewable |
|
Review status: 0 of 20 files reviewed at latest revision, 37 unresolved discussions. src/Root/routes.js, line 16 at r8 (raw file): Previously, sharils (sharils) wrote…
摁,如果你把 checkAuth 當作是判斷 private 和 public 的依據來看就會很奇怪。 可是如果他只是會依據權限而有所不同的角度看就不會,另外一種就是在全拆分成這樣:
test/Auth/authModule.js, line 15 at r9 (raw file): Previously, sharils (sharils) wrote…
got it Comments from Reviewable |
|
Reviewed 3 of 18 files at r1, 5 of 5 files at r7. src/Auth/authModule.js, line 11 at r1 (raw file):
You have to choose whether you scatter all these localStorage code across the whole code base or in one place. I guess the answer is obvious. And that's why I said it's a good reason to look for a middleware to sync the store and localStorage.
aye Comments from Reviewable |
This change is