about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/account_timeline
diff options
context:
space:
mode:
authorEugen <eugen@zeonfederated.com>2017-04-23 04:39:50 +0200
committerGitHub <noreply@github.com>2017-04-23 04:39:50 +0200
commit59b1de0bcf39473106e5380c129d7436be1ad89a (patch)
tree348ac6a815dafa69baea150c2e69be3274fbdc3f /app/assets/javascripts/components/features/account_timeline
parentdf46864b39b0ba26aedb65d2984b9be08ff5e35a (diff)
Add a confirmation modal: (#2279)
- Deleting a toot
- Muting, blocking someone
- Clearing notifications

Remove source map generation from development environment, as it is a huge
performance sink hole with little gains
Diffstat (limited to 'app/assets/javascripts/components/features/account_timeline')
-rw-r--r--app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx23
1 files changed, 19 insertions, 4 deletions
diff --git a/app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx b/app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx
index 8472d25a5..f924e7f5e 100644
--- a/app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx
+++ b/app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx
@@ -11,6 +11,13 @@ import {
 } from '../../../actions/accounts';
 import { mentionCompose } from '../../../actions/compose';
 import { initReport } from '../../../actions/reports';
+import { openModal } from '../../../actions/modal';
+import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
+
+const messages = defineMessages({
+  blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
+  muteConfirm: { id: 'confirmations.mute.confirm', defaultMessage: 'Mute' }
+});
 
 const makeMapStateToProps = () => {
   const getAccount = makeGetAccount();
@@ -23,7 +30,7 @@ const makeMapStateToProps = () => {
   return mapStateToProps;
 };
 
-const mapDispatchToProps = dispatch => ({
+const mapDispatchToProps = (dispatch, { intl }) => ({
   onFollow (account) {
     if (account.getIn(['relationship', 'following'])) {
       dispatch(unfollowAccount(account.get('id')));
@@ -36,7 +43,11 @@ const mapDispatchToProps = dispatch => ({
     if (account.getIn(['relationship', 'blocking'])) {
       dispatch(unblockAccount(account.get('id')));
     } else {
-      dispatch(blockAccount(account.get('id')));
+      dispatch(openModal('CONFIRM', {
+        message: <FormattedMessage id='confirmations.block.message' defaultMessage='Are you sure you want to block {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
+        confirm: intl.formatMessage(messages.blockConfirm),
+        onConfirm: () => dispatch(blockAccount(account.get('id')))
+      }));
     }
   },
 
@@ -52,9 +63,13 @@ const mapDispatchToProps = dispatch => ({
     if (account.getIn(['relationship', 'muting'])) {
       dispatch(unmuteAccount(account.get('id')));
     } else {
-      dispatch(muteAccount(account.get('id')));
+      dispatch(openModal('CONFIRM', {
+        message: <FormattedMessage id='confirmations.mute.message' defaultMessage='Are you sure you want to mute {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
+        confirm: intl.formatMessage(messages.muteConfirm),
+        onConfirm: () => dispatch(muteAccount(account.get('id')))
+      }));
     }
   }
 });
 
-export default connect(makeMapStateToProps, mapDispatchToProps)(Header);
+export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));