From d0e2733f63a7bd9601e73adee1107da804f85c41 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 3 Sep 2016 14:01:10 +0200 Subject: Fix reblogs of reblogs in UI, add follow form in UI --- .../javascripts/components/actions/follow.jsx | 16 +++--- .../components/components/compose_form.jsx | 57 ++++++++++++++++++++++ .../components/components/composer_drawer.jsx | 57 ---------------------- .../javascripts/components/components/drawer.jsx | 17 +++++++ .../components/components/follow_form.jsx | 40 +++++++++++++++ .../javascripts/components/components/frontend.jsx | 17 +++++-- .../containers/compose_form_container.jsx | 29 +++++++++++ .../containers/composer_drawer_container.jsx | 29 ----------- .../containers/follow_form_container.jsx | 24 +++++++++ .../javascripts/components/reducers/timelines.jsx | 2 + app/assets/stylesheets/components.scss | 2 +- app/models/account.rb | 4 +- 12 files changed, 193 insertions(+), 101 deletions(-) create mode 100644 app/assets/javascripts/components/components/compose_form.jsx delete mode 100644 app/assets/javascripts/components/components/composer_drawer.jsx create mode 100644 app/assets/javascripts/components/components/drawer.jsx create mode 100644 app/assets/javascripts/components/components/follow_form.jsx create mode 100644 app/assets/javascripts/components/containers/compose_form_container.jsx delete mode 100644 app/assets/javascripts/components/containers/composer_drawer_container.jsx create mode 100644 app/assets/javascripts/components/containers/follow_form_container.jsx (limited to 'app') diff --git a/app/assets/javascripts/components/actions/follow.jsx b/app/assets/javascripts/components/actions/follow.jsx index 1c4e2c66a..a09aded83 100644 --- a/app/assets/javascripts/components/actions/follow.jsx +++ b/app/assets/javascripts/components/actions/follow.jsx @@ -6,41 +6,41 @@ export const FOLLOW_SUBMIT_REQUEST = 'FOLLOW_SUBMIT_REQUEST'; export const FOLLOW_SUBMIT_SUCCESS = 'FOLLOW_SUBMIT_SUCCESS'; export const FOLLOW_SUBMIT_FAIL = 'FOLLOW_SUBMIT_FAIL'; -export function followChange(text) { +export function changeFollow(text) { return { type: FOLLOW_CHANGE, text: text }; } -export function followSubmit() { +export function submitFollow() { return function (dispatch, getState) { - dispatch(followSubmitRequest()); + dispatch(submitFollowRequest()); api(getState).post('/api/follows', { uri: getState().getIn(['follow', 'text']) }).then(function (response) { - dispatch(followSubmitSuccess(response.data)); + dispatch(submitFollowSuccess(response.data)); }).catch(function (error) { - dispatch(followSubmitFail(error)); + dispatch(submitFollowFail(error)); }); }; } -export function followSubmitRequest() { +export function submitFollowRequest() { return { type: FOLLOW_SUBMIT_REQUEST }; } -export function followSubmitSuccess(account) { +export function submitFollowSuccess(account) { return { type: FOLLOW_SUBMIT_SUCCESS, account: account }; } -export function followSubmitFail(error) { +export function submitFollowFail(error) { return { type: FOLLOW_SUBMIT_FAIL, error: error diff --git a/app/assets/javascripts/components/components/compose_form.jsx b/app/assets/javascripts/components/components/compose_form.jsx new file mode 100644 index 000000000..641412012 --- /dev/null +++ b/app/assets/javascripts/components/components/compose_form.jsx @@ -0,0 +1,57 @@ +import CharacterCounter from './character_counter'; +import Button from './button'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import ReplyIndicator from './reply_indicator'; + +const ComposeForm = React.createClass({ + + propTypes: { + text: React.PropTypes.string.isRequired, + is_submitting: React.PropTypes.bool, + in_reply_to: ImmutablePropTypes.map, + onChange: React.PropTypes.func.isRequired, + onSubmit: React.PropTypes.func.isRequired, + onCancelReply: React.PropTypes.func.isRequired + }, + + mixins: [PureRenderMixin], + + handleChange (e) { + this.props.onChange(e.target.value); + }, + + handleKeyUp (e) { + if (e.keyCode === 13 && e.ctrlKey) { + this.props.onSubmit(); + } + }, + + handleSubmit () { + this.props.onSubmit(); + }, + + render () { + let replyArea = ''; + + if (this.props.in_reply_to) { + replyArea = ; + } + + return ( +
+ {replyArea} + +