From 209f826c15d2065a19a7af561b9f38f00c95580d Mon Sep 17 00:00:00 2001 From: Mary Kate Date: Mon, 27 Jul 2020 17:26:03 -0500 Subject: [PATCH 1/3] add reason field on registration when by approval mode is on --- app/soapbox/__fixtures__/intlMessages.json | 1 + app/soapbox/actions/auth.js | 11 ++++++++--- .../landing_page/components/registration_form.js | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/soapbox/__fixtures__/intlMessages.json b/app/soapbox/__fixtures__/intlMessages.json index a8217149e..d46a8934c 100644 --- a/app/soapbox/__fixtures__/intlMessages.json +++ b/app/soapbox/__fixtures__/intlMessages.json @@ -834,6 +834,7 @@ "registration.lead": "With an account on {instance} you\"ll be able to follow people on any server in the fediverse.", "registration.sign_up": "Sign up", "registration.tos": "Terms of Service", + "registration.reason": "Reason for Joining", "relative_time.days": "{number}d", "relative_time.hours": "{number}h", "relative_time.just_now": "now", diff --git a/app/soapbox/actions/auth.js b/app/soapbox/actions/auth.js index c241b801f..a8d6d5f0f 100644 --- a/app/soapbox/actions/auth.js +++ b/app/soapbox/actions/auth.js @@ -133,15 +133,20 @@ export function logOut() { export function register(params) { return (dispatch, getState) => { const needsConfirmation = getState().getIn(['instance', 'pleroma', 'metadata', 'account_activation_required']); + const needsApproval = getState().getIn(['instance', 'approval_required']); dispatch({ type: AUTH_REGISTER_REQUEST }); return dispatch(createAppAndToken()).then(() => { return api(getState, 'app').post('/api/v1/accounts', params); }).then(response => { dispatch({ type: AUTH_REGISTER_SUCCESS, token: response.data }); dispatch(authLoggedIn(response.data)); - return needsConfirmation - ? dispatch(showAlert('', 'Check your email for further instructions.')) - : dispatch(fetchMe()); + if (needsConfirmation) { + return dispatch(showAlert('', 'Check your email for further instructions.')); + } else if (needsApproval) { + return dispatch(showAlert('', 'Your account has been submitted for approval.')); + } else { + return dispatch(fetchMe()); + } }).catch(error => { dispatch({ type: AUTH_REGISTER_FAIL, error }); throw error; diff --git a/app/soapbox/features/landing_page/components/registration_form.js b/app/soapbox/features/landing_page/components/registration_form.js index 36faad103..2b172910c 100644 --- a/app/soapbox/features/landing_page/components/registration_form.js +++ b/app/soapbox/features/landing_page/components/registration_form.js @@ -24,6 +24,7 @@ const messages = defineMessages({ confirm: { id: 'registration.fields.confirm_placeholder', defaultMessage: 'Password (again)' }, agreement: { id: 'registration.agreement', defaultMessage: 'I agree to the {tos}.' }, tos: { id: 'registration.tos', defaultMessage: 'Terms of Service' }, + reason: { id: 'registration.reason', defaultMessage: 'Reason for Joining' }, }); const mapStateToProps = (state, props) => ({ @@ -136,6 +137,15 @@ class RegistrationForm extends ImmutablePureComponent { onChange={this.onInputChange} required /> + {instance.get('approval_required') && + } Date: Tue, 28 Jul 2020 21:19:11 -0500 Subject: [PATCH 2/3] textarea input --- app/soapbox/features/forms/index.js | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/soapbox/features/forms/index.js b/app/soapbox/features/forms/index.js index 75feac6d4..24857c33f 100644 --- a/app/soapbox/features/forms/index.js +++ b/app/soapbox/features/forms/index.js @@ -68,6 +68,17 @@ LabelInput.propTypes = { dispatch: PropTypes.func, }; +export const LabelTextarea = ({ label, dispatch, ...props }) => ( + + + +); + +LabelTextarea.propTypes = { + label: FormPropTypes.label.isRequired, + dispatch: PropTypes.func, +}; + export class SimpleInput extends ImmutablePureComponent { static propTypes = { @@ -88,6 +99,26 @@ export class SimpleInput extends ImmutablePureComponent { } +export class SimpleTextarea extends ImmutablePureComponent { + + static propTypes = { + label: FormPropTypes.label, + hint: PropTypes.node, + } + + render() { + const { hint, ...props } = this.props; + const Input = this.props.label ? LabelTextarea : 'textarea'; + + return ( + + + + ); + } + +} + export class SimpleForm extends ImmutablePureComponent { static propTypes = { From 774adf9baa203588e1c0f7943a826377f5fa8369 Mon Sep 17 00:00:00 2001 From: Mary Kate Date: Tue, 28 Jul 2020 21:30:35 -0500 Subject: [PATCH 3/3] update reason or joining form to simpletextarea --- app/soapbox/features/forms/index.js | 2 +- .../features/landing_page/components/registration_form.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/soapbox/features/forms/index.js b/app/soapbox/features/forms/index.js index 24857c33f..471a173f8 100644 --- a/app/soapbox/features/forms/index.js +++ b/app/soapbox/features/forms/index.js @@ -70,7 +70,7 @@ LabelInput.propTypes = { export const LabelTextarea = ({ label, dispatch, ...props }) => ( - +