From 72591cc6d59d774e66d1d42af44bdc00f71f99f8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 31 Aug 2016 16:15:12 +0200 Subject: Cleaning up action names and compose drawer --- .../javascripts/components/components/avatar.jsx | 4 ++++ .../javascripts/components/components/button.jsx | 13 +++++++++-- .../components/components/character_counter.jsx | 5 +++++ .../javascripts/components/components/column.jsx | 7 +++++- .../components/components/column_header.jsx | 8 ++++++- .../components/components/columns_area.jsx | 8 +++++-- .../components/components/composer_drawer.jsx | 26 ++++++++++------------ .../components/components/display_name.jsx | 4 ++++ .../javascripts/components/components/frontend.jsx | 8 ++++--- .../javascripts/components/components/nav_bar.jsx | 12 ---------- .../components/components/relative_timestamp.jsx | 6 ++++- .../javascripts/components/components/status.jsx | 5 +++++ .../components/components/status_list.jsx | 7 +++++- 13 files changed, 76 insertions(+), 37 deletions(-) delete mode 100644 app/assets/javascripts/components/components/nav_bar.jsx (limited to 'app/assets/javascripts/components/components') diff --git a/app/assets/javascripts/components/components/avatar.jsx b/app/assets/javascripts/components/components/avatar.jsx index 7db3eeff7..abbef72f8 100644 --- a/app/assets/javascripts/components/components/avatar.jsx +++ b/app/assets/javascripts/components/components/avatar.jsx @@ -1,9 +1,13 @@ +import PureRenderMixin from 'react-addons-pure-render-mixin'; + const Avatar = React.createClass({ propTypes: { src: React.PropTypes.string.isRequired }, + mixins: [PureRenderMixin], + render () { return (
diff --git a/app/assets/javascripts/components/components/button.jsx b/app/assets/javascripts/components/components/button.jsx index b2d7ba9a9..e70382142 100644 --- a/app/assets/javascripts/components/components/button.jsx +++ b/app/assets/javascripts/components/components/button.jsx @@ -1,12 +1,21 @@ +import PureRenderMixin from 'react-addons-pure-render-mixin'; + const Button = React.createClass({ + propTypes: { text: React.PropTypes.string.isRequired, - onClick: React.PropTypes.func + onClick: React.PropTypes.func, + disabled: React.PropTypes.boolean }, + mixins: [PureRenderMixin], + handleClick (e) { e.preventDefault(); - this.props.onClick(); + + if (!this.props.disabled) { + this.props.onClick(); + } }, render () { diff --git a/app/assets/javascripts/components/components/character_counter.jsx b/app/assets/javascripts/components/components/character_counter.jsx index b58d9fe32..dd9218844 100644 --- a/app/assets/javascripts/components/components/character_counter.jsx +++ b/app/assets/javascripts/components/components/character_counter.jsx @@ -1,8 +1,13 @@ +import PureRenderMixin from 'react-addons-pure-render-mixin'; + const CharacterCounter = React.createClass({ + propTypes: { text: React.PropTypes.string.isRequired }, + mixins: [PureRenderMixin], + render () { return ( diff --git a/app/assets/javascripts/components/components/column.jsx b/app/assets/javascripts/components/components/column.jsx index c1f5b84a2..b347ee3a8 100644 --- a/app/assets/javascripts/components/components/column.jsx +++ b/app/assets/javascripts/components/components/column.jsx @@ -1,12 +1,16 @@ import StatusListContainer from '../containers/status_list_container'; import ColumnHeader from './column_header'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; const Column = React.createClass({ + propTypes: { type: React.PropTypes.string }, - render: function() { + mixins: [PureRenderMixin], + + render () { return (
@@ -14,6 +18,7 @@ const Column = React.createClass({
); } + }); export default Column; diff --git a/app/assets/javascripts/components/components/column_header.jsx b/app/assets/javascripts/components/components/column_header.jsx index e2f7d7c1c..15a195898 100644 --- a/app/assets/javascripts/components/components/column_header.jsx +++ b/app/assets/javascripts/components/components/column_header.jsx @@ -1,15 +1,21 @@ +import PureRenderMixin from 'react-addons-pure-render-mixin'; + const ColumnHeader = React.createClass({ + propTypes: { type: React.PropTypes.string }, - render: function() { + mixins: [PureRenderMixin], + + render () { return (
{this.props.type}
); } + }); export default ColumnHeader; diff --git a/app/assets/javascripts/components/components/columns_area.jsx b/app/assets/javascripts/components/components/columns_area.jsx index 1c46f722d..149fdfcf4 100644 --- a/app/assets/javascripts/components/components/columns_area.jsx +++ b/app/assets/javascripts/components/components/columns_area.jsx @@ -1,8 +1,11 @@ -import Column from './column'; +import Column from './column'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; const ColumnsArea = React.createClass({ - render: function() { + mixins: [PureRenderMixin], + + render () { return (
@@ -10,6 +13,7 @@ const ColumnsArea = React.createClass({
); } + }); export default ColumnsArea; diff --git a/app/assets/javascripts/components/components/composer_drawer.jsx b/app/assets/javascripts/components/components/composer_drawer.jsx index 7b742f64e..71455967f 100644 --- a/app/assets/javascripts/components/components/composer_drawer.jsx +++ b/app/assets/javascripts/components/components/composer_drawer.jsx @@ -1,42 +1,40 @@ import CharacterCounter from './character_counter'; import Button from './button'; -import { publish } from '../actions/statuses'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; const ComposerDrawer = React.createClass({ propTypes: { + text: React.PropTypes.string.isRequired, + isSubmitting: React.PropTypes.boolean, + onChange: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired }, - getInitialState() { - return { - text: '' - }; - }, + mixins: [PureRenderMixin], handleChange (e) { - this.setState({ text: e.target.value }); + this.props.onChange(e.target.value); }, handleKeyUp (e) { if (e.keyCode === 13 && e.ctrlKey) { - this.handleSubmit(); + this.props.onSubmit(); } }, handleSubmit () { - this.props.onSubmit(this.state.text, null); - this.setState({ text: '' }); + this.props.onSubmit(); }, render () { return ( -
-