From b0d76f2f6a22524b22be1a12dba75fb9d1283350 Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 28 May 2018 14:52:03 -0300 Subject: [PATCH] progress --- .../src/actions/rejectUsernameDialog.js | 14 ++ .../src/components/RejectUsernameDialog.css | 90 +++++++++ .../src/components/RejectUsernameDialog.js | 188 ++++++++++++++++++ .../coral-admin/src/components/UserDetail.js | 8 +- .../src/constants/rejectUsernameDialog.js | 2 + client/coral-admin/src/containers/Layout.js | 2 + .../src/containers/RejectUsernameDialog.js | 79 ++++++++ .../coral-admin/src/containers/UserDetail.js | 4 + client/coral-admin/src/reducers/index.js | 2 + .../src/reducers/rejectUsernameDialog.js | 29 +++ 10 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 client/coral-admin/src/actions/rejectUsernameDialog.js create mode 100644 client/coral-admin/src/components/RejectUsernameDialog.css create mode 100644 client/coral-admin/src/components/RejectUsernameDialog.js create mode 100644 client/coral-admin/src/constants/rejectUsernameDialog.js create mode 100644 client/coral-admin/src/containers/RejectUsernameDialog.js create mode 100644 client/coral-admin/src/reducers/rejectUsernameDialog.js diff --git a/client/coral-admin/src/actions/rejectUsernameDialog.js b/client/coral-admin/src/actions/rejectUsernameDialog.js new file mode 100644 index 000000000..946b36ef7 --- /dev/null +++ b/client/coral-admin/src/actions/rejectUsernameDialog.js @@ -0,0 +1,14 @@ +import { + SHOW_REJECT_USERNAME_DIALOG, + HIDE_REJECT_USERNAME_DIALOG, +} from '../constants/rejectUsernameDialog'; + +export const showRejectUsernameDialog = ({ userId, username }) => ({ + type: SHOW_REJECT_USERNAME_DIALOG, + userId, + username, +}); + +export const hideRejectUsernameDialog = () => ({ + type: HIDE_REJECT_USERNAME_DIALOG, +}); diff --git a/client/coral-admin/src/components/RejectUsernameDialog.css b/client/coral-admin/src/components/RejectUsernameDialog.css new file mode 100644 index 000000000..1c96f509a --- /dev/null +++ b/client/coral-admin/src/components/RejectUsernameDialog.css @@ -0,0 +1,90 @@ +.dialog { + border: none; + box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2); + width: 400px; + top: 50%; + transform: translateY(-50%); + padding: 20px; + border-radius: 4px; +} + +.header { + color: black; + font-size: 1.5em; + font-weight: 500; + margin: 0 0 8px 0; +} + +.close { + display: block; + position: absolute; + top: 24px; + right: 20px; +} + +.closeButton { + userSelect: none; + outline: none; + border: none; + touchAction: manipulation; + &::-moz-focus-inner: { + border: 0; + } + background: 0; + padding: 0; + font-size: 24px; + line-height: 14px; + cursor: pointer; + color: #363636; + &:hover { + color: #6b6b6b; + } +} + +.legend { + padding: 0; + font-weight: bold; +} + +div.radioGroup { + margin-top: 6px; +} + +label.radioGroup { + + &:global(.is-checked) > :global(.mdl-radio__outer-circle), + > :global(.mdl-radio__outer-circle) { + border-color: #212121; + } + + > :global(.mdl-radio__inner-circle) { + background: #212121; + } + + > :global(.mdl-radio__label) { + font-size: 14px; + line-height: 20px; + } +} + +.messageInput { + border-radius: 3px; + width: 100%; + padding: 10px; + font-size: 14px; + box-sizing: border-box; +} + +.cancel { + margin-right: 5px; +} + +.perform { + min-width: 90px; +} + +.buttons { + margin-top: 8px; + margin-bottom: 6px; + text-align: right; +} diff --git a/client/coral-admin/src/components/RejectUsernameDialog.js b/client/coral-admin/src/components/RejectUsernameDialog.js new file mode 100644 index 000000000..cdd211bc4 --- /dev/null +++ b/client/coral-admin/src/components/RejectUsernameDialog.js @@ -0,0 +1,188 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Dialog } from 'coral-ui'; +import { RadioGroup, Radio } from 'react-mdl'; +import styles from './SuspendUserDialog.css'; +import cn from 'classnames'; + +import Button from 'coral-ui/components/Button'; + +import t, { timeago } from 'coral-framework/services/i18n'; +import { dateAdd } from 'coral-framework/utils'; + +const initialState = { step: 0, duration: '3' }; + +function durationsToDate(hours) { + // Add 1 minute more to help `timeago.js` to display the correct duration. + return dateAdd(new Date(), 'minute', hours * 60 + 1); +} + +class SuspendUserDialog extends React.Component { + state = initialState; + + componentWillReceiveProps(next) { + if (this.props.open && !next.open) { + this.setState(initialState); + } + } + + handleDurationChange = event => { + this.setState({ duration: event.target.value }); + }; + + handleMessageChange = event => { + this.setState({ message: event.target.value }); + }; + + goToStep1 = () => { + this.setState({ + step: 1, + message: t( + 'suspenduser.email_message_suspend', + this.props.username, + this.props.organizationName, + timeago(durationsToDate(this.state.duration)) + ), + }); + }; + + handlePerform = () => { + this.props.onPerform({ + message: this.state.message, + + // Add 1 minute more to help `timeago.js` to display the correct duration. + until: durationsToDate(this.state.duration), + }); + }; + + renderStep0() { + const { onCancel, username } = this.props; + const { duration } = this.state; + return ( +
+

{t('suspenduser.title_suspend')}

+

+ {t('suspenduser.description_suspend', username)} +

+
+ + {t('suspenduser.select_duration')} + + + {t('suspenduser.one_hour')} + {t('suspenduser.hours', 3)} + {t('suspenduser.hours', 24)} + {t('suspenduser.days', 7)} + +
+
+ + +
+
+ ); + } + + renderStep1() { + const { message } = this.state; + const { onCancel, username } = this.props; + return ( +
+

{t('suspenduser.title_notify')}

+

+ {t('suspenduser.description_notify', username)} +

+
+ + {t('suspenduser.write_message')} + +