Change design of account notes in web UI (#14208)
* Change design of account notes in web UI * Fix `for` -> `htmlFor`master
parent
83fd046107
commit
c3187411c2
@ -1,34 +1,17 @@ |
|||||||
import { connect } from 'react-redux'; |
import { connect } from 'react-redux'; |
||||||
import { changeAccountNoteComment, submitAccountNote, initEditAccountNote, cancelAccountNote } from 'mastodon/actions/account_notes'; |
import { submitAccountNote } from 'mastodon/actions/account_notes'; |
||||||
import AccountNote from '../components/account_note'; |
import AccountNote from '../components/account_note'; |
||||||
|
|
||||||
const mapStateToProps = (state, { account }) => { |
const mapStateToProps = (state, { account }) => ({ |
||||||
const isEditing = state.getIn(['account_notes', 'edit', 'account_id']) === account.get('id'); |
value: account.getIn(['relationship', 'note']), |
||||||
|
}); |
||||||
return { |
|
||||||
isSubmitting: state.getIn(['account_notes', 'edit', 'isSubmitting']), |
|
||||||
accountNote: isEditing ? state.getIn(['account_notes', 'edit', 'comment']) : account.getIn(['relationship', 'note']), |
|
||||||
isEditing, |
|
||||||
}; |
|
||||||
}; |
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch, { account }) => ({ |
const mapDispatchToProps = (dispatch, { account }) => ({ |
||||||
|
|
||||||
onEditAccountNote() { |
onSave (value) { |
||||||
dispatch(initEditAccountNote(account)); |
dispatch(submitAccountNote(account.get('id'), value)); |
||||||
}, |
|
||||||
|
|
||||||
onSaveAccountNote() { |
|
||||||
dispatch(submitAccountNote()); |
|
||||||
}, |
}, |
||||||
|
|
||||||
onCancelAccountNote() { |
|
||||||
dispatch(cancelAccountNote()); |
|
||||||
}, |
|
||||||
|
|
||||||
onChangeAccountNote(comment) { |
|
||||||
dispatch(changeAccountNoteComment(comment)); |
|
||||||
}, |
|
||||||
}); |
}); |
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(AccountNote); |
export default connect(mapStateToProps, mapDispatchToProps)(AccountNote); |
||||||
|
@ -1,44 +0,0 @@ |
|||||||
import { Map as ImmutableMap } from 'immutable'; |
|
||||||
|
|
||||||
import { |
|
||||||
ACCOUNT_NOTE_INIT_EDIT, |
|
||||||
ACCOUNT_NOTE_CANCEL, |
|
||||||
ACCOUNT_NOTE_CHANGE_COMMENT, |
|
||||||
ACCOUNT_NOTE_SUBMIT_REQUEST, |
|
||||||
ACCOUNT_NOTE_SUBMIT_FAIL, |
|
||||||
ACCOUNT_NOTE_SUBMIT_SUCCESS, |
|
||||||
} from '../actions/account_notes'; |
|
||||||
|
|
||||||
const initialState = ImmutableMap({ |
|
||||||
edit: ImmutableMap({ |
|
||||||
isSubmitting: false, |
|
||||||
account_id: null, |
|
||||||
comment: null, |
|
||||||
}), |
|
||||||
}); |
|
||||||
|
|
||||||
export default function account_notes(state = initialState, action) { |
|
||||||
switch (action.type) { |
|
||||||
case ACCOUNT_NOTE_INIT_EDIT: |
|
||||||
return state.withMutations((state) => { |
|
||||||
state.setIn(['edit', 'isSubmitting'], false); |
|
||||||
state.setIn(['edit', 'account_id'], action.account.get('id')); |
|
||||||
state.setIn(['edit', 'comment'], action.comment); |
|
||||||
}); |
|
||||||
case ACCOUNT_NOTE_CHANGE_COMMENT: |
|
||||||
return state.setIn(['edit', 'comment'], action.comment); |
|
||||||
case ACCOUNT_NOTE_SUBMIT_REQUEST: |
|
||||||
return state.setIn(['edit', 'isSubmitting'], true); |
|
||||||
case ACCOUNT_NOTE_SUBMIT_FAIL: |
|
||||||
return state.setIn(['edit', 'isSubmitting'], false); |
|
||||||
case ACCOUNT_NOTE_SUBMIT_SUCCESS: |
|
||||||
case ACCOUNT_NOTE_CANCEL: |
|
||||||
return state.withMutations((state) => { |
|
||||||
state.setIn(['edit', 'isSubmitting'], false); |
|
||||||
state.setIn(['edit', 'account_id'], null); |
|
||||||
state.setIn(['edit', 'comment'], null); |
|
||||||
}); |
|
||||||
default: |
|
||||||
return state; |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue