about summary refs log tree commit diff
path: root/app/assets/javascripts/components
diff options
context:
space:
mode:
authorblackle <isabelle@blackle-mori.com>2017-04-10 22:28:52 -0400
committerblackle <isabelle@blackle-mori.com>2017-04-10 22:35:55 -0400
commit01e5447e3582787bf2370b9a483963953bdbb075 (patch)
tree1a4cd5c45f8055a53b40bc03cb26a607175a3c12 /app/assets/javascripts/components
parentb89f007862bb06bbf892c4f37dbc31ed83138b53 (diff)
Add boost confirm modal
Diffstat (limited to 'app/assets/javascripts/components')
-rw-r--r--app/assets/javascripts/components/containers/status_container.jsx6
-rw-r--r--app/assets/javascripts/components/features/status/index.jsx6
-rw-r--r--app/assets/javascripts/components/features/ui/components/boost_modal.jsx64
-rw-r--r--app/assets/javascripts/components/features/ui/components/modal_root.jsx4
4 files changed, 77 insertions, 3 deletions
diff --git a/app/assets/javascripts/components/containers/status_container.jsx b/app/assets/javascripts/components/containers/status_container.jsx
index fd3fbe4c3..918fb91a0 100644
--- a/app/assets/javascripts/components/containers/status_container.jsx
+++ b/app/assets/javascripts/components/containers/status_container.jsx
@@ -38,11 +38,15 @@ const mapDispatchToProps = (dispatch) => ({
     dispatch(replyCompose(status, router));
   },
 
+  onModalReblog (status) {
+    dispatch(reblog(status));
+  },
+
   onReblog (status) {
     if (status.get('reblogged')) {
       dispatch(unreblog(status));
     } else {
-      dispatch(reblog(status));
+      dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
     }
   },
 
diff --git a/app/assets/javascripts/components/features/status/index.jsx b/app/assets/javascripts/components/features/status/index.jsx
index f98fe1b01..8b5019b57 100644
--- a/app/assets/javascripts/components/features/status/index.jsx
+++ b/app/assets/javascripts/components/features/status/index.jsx
@@ -82,11 +82,15 @@ const Status = React.createClass({
     this.props.dispatch(replyCompose(status, this.context.router));
   },
 
+  handleModalReblog (status) {
+    this.props.dispatch(reblog(status));
+  },
+
   handleReblogClick (status) {
     if (status.get('reblogged')) {
       this.props.dispatch(unreblog(status));
     } else {
-      this.props.dispatch(reblog(status));
+      this.props.dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog }));
     }
   },
 
diff --git a/app/assets/javascripts/components/features/ui/components/boost_modal.jsx b/app/assets/javascripts/components/features/ui/components/boost_modal.jsx
new file mode 100644
index 000000000..8b9154183
--- /dev/null
+++ b/app/assets/javascripts/components/features/ui/components/boost_modal.jsx
@@ -0,0 +1,64 @@
+import PureRenderMixin from 'react-addons-pure-render-mixin';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import { defineMessages, injectIntl } from 'react-intl';
+import IconButton from '../../../components/icon_button';
+import Button from '../../../components/button';
+import DetailedStatus from '../../status/components/detailed_status';
+
+const messages = defineMessages({
+  close: { id: 'lightbox.close', defaultMessage: 'Close' },
+  reblog: { id: 'status.reblog', defaultMessage: 'Boost' }
+});
+
+const closeStyle = {
+  position: 'absolute',
+  top: '4px',
+  right: '4px'
+};
+
+const buttonContainerStyle = {
+  textAlign: 'right',
+  padding: '10px'
+};
+
+const BoostModal = React.createClass({
+
+  propTypes: {
+    status: ImmutablePropTypes.map.isRequired,
+    onReblog: React.PropTypes.func.isRequired,
+    onClose: React.PropTypes.func.isRequired,
+    intl: React.PropTypes.object.isRequired
+  },
+
+  mixins: [PureRenderMixin],
+
+  handleReblog() {
+    this.props.onReblog(this.props.status);
+    this.props.onClose();
+  },
+
+  handleOpenMedia() {
+    // do nothing"
+  },
+
+  render () {
+    const { status, intl, onClose } = this.props;
+
+    const reblogButton = <span><i className='fa fa-retweet' /> {intl.formatMessage(messages.reblog)}</span>;
+
+    return (
+      <div className='modal-root__modal boost-modal'>
+        <IconButton title={intl.formatMessage(messages.close)} icon='times' onClick={onClose} size={16} style={closeStyle} />
+        <div>
+          <DetailedStatus status={status} onOpenMedia={this.handleOpenMedia} />
+        </div>
+        <div style={buttonContainerStyle}>
+          <Button text={reblogButton} onClick={this.handleReblog} />
+        </div>
+      </div>
+    );
+  }
+
+});
+
+export default injectIntl(BoostModal);
diff --git a/app/assets/javascripts/components/features/ui/components/modal_root.jsx b/app/assets/javascripts/components/features/ui/components/modal_root.jsx
index d2ae5e145..e7ac02dde 100644
--- a/app/assets/javascripts/components/features/ui/components/modal_root.jsx
+++ b/app/assets/javascripts/components/features/ui/components/modal_root.jsx
@@ -1,9 +1,11 @@
 import PureRenderMixin from 'react-addons-pure-render-mixin';
 import MediaModal from './media_modal';
+import BoostModal from './boost_modal';
 import { TransitionMotion, spring } from 'react-motion';
 
 const MODAL_COMPONENTS = {
-  'MEDIA': MediaModal
+  'MEDIA': MediaModal,
+  'BOOST': BoostModal
 };
 
 const ModalRoot = React.createClass({