about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/composer/poll_form/index.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-06 12:30:11 +0100
committerThibG <thib@sitedethib.com>2019-03-06 23:56:53 +0100
commit8fe86cebaa30e77e50c8223a1ff83759dbd7ca62 (patch)
treeb82bd62f5d7dd41e6c70361e93ffcaa9b0114e74 /app/javascript/flavours/glitch/features/composer/poll_form/index.js
parent3e5a0bc8250b3dc806e97e8370c319c40fc5ea28 (diff)
[Glitch] Port polls creation UI from upstream
Diffstat (limited to 'app/javascript/flavours/glitch/features/composer/poll_form/index.js')
-rw-r--r--app/javascript/flavours/glitch/features/composer/poll_form/index.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/composer/poll_form/index.js b/app/javascript/flavours/glitch/features/composer/poll_form/index.js
new file mode 100644
index 000000000..5232c3b31
--- /dev/null
+++ b/app/javascript/flavours/glitch/features/composer/poll_form/index.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);