about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/compose/containers/poll_form_container.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-06 04:53:37 +0100
committerGitHub <noreply@github.com>2019-03-06 04:53:37 +0100
commitd97cbb0da60f32c9e7e60445af329173b0df1aa7 (patch)
tree65e465284f132edede32ae8335ef840e8bdef1c7 /app/javascript/mastodon/features/compose/containers/poll_form_container.js
parent4407f07014096bcbaf5a06015a5791984282846d (diff)
Add UI for creating polls (#10184)
* Add actions and reducers for polls

* Add poll button

* Disable media upload if poll enabled

* Add poll form

* Make delete & redraft work with polls
Diffstat (limited to 'app/javascript/mastodon/features/compose/containers/poll_form_container.js')
-rw-r--r--app/javascript/mastodon/features/compose/containers/poll_form_container.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/compose/containers/poll_form_container.js b/app/javascript/mastodon/features/compose/containers/poll_form_container.js
new file mode 100644
index 000000000..da795a291
--- /dev/null
+++ b/app/javascript/mastodon/features/compose/containers/poll_form_container.js
@@ -0,0 +1,29 @@
+import { connect } from 'react-redux';
+import PollForm from '../components/poll_form';
+import { addPollOption, removePollOption, changePollOption, changePollSettings } from '../../../actions/compose';
+
+const mapStateToProps = state => ({
+  options: state.getIn(['compose', 'poll', 'options']),
+  expiresIn: state.getIn(['compose', 'poll', 'expires_in']),
+  isMultiple: state.getIn(['compose', 'poll', 'multiple']),
+});
+
+const mapDispatchToProps = dispatch => ({
+  onAddOption(title) {
+    dispatch(addPollOption(title));
+  },
+
+  onRemoveOption(index) {
+    dispatch(removePollOption(index));
+  },
+
+  onChangeOption(index, title) {
+    dispatch(changePollOption(index, title));
+  },
+
+  onChangeSettings(expiresIn, isMultiple) {
+    dispatch(changePollSettings(expiresIn, isMultiple));
+  },
+});
+
+export default connect(mapStateToProps, mapDispatchToProps)(PollForm);