Support email list

merge-requests/527/head
Alex Gleason 3 years ago
parent 0cd0eb6787
commit 6255ba4976
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -78,11 +78,13 @@ class EditProfile extends ImmutablePureComponent {
super(props); super(props);
const { account } = this.props; const { account } = this.props;
const strangerNotifications = account.getIn(['pleroma', 'notification_settings', 'block_from_strangers']); const strangerNotifications = account.getIn(['pleroma', 'notification_settings', 'block_from_strangers']);
const acceptsEmailList = account.getIn(['pleroma', 'accepts_email_list']);
const initialState = account.withMutations(map => { const initialState = account.withMutations(map => {
map.merge(map.get('source')); map.merge(map.get('source'));
map.delete('source'); map.delete('source');
map.set('fields', normalizeFields(map.get('fields'), props.maxFields)); map.set('fields', normalizeFields(map.get('fields'), props.maxFields));
map.set('stranger_notifications', strangerNotifications); map.set('stranger_notifications', strangerNotifications);
map.set('accepts_email_list', acceptsEmailList);
unescapeParams(map, ['display_name', 'bio']); unescapeParams(map, ['display_name', 'bio']);
}); });
this.state = initialState.toObject(); this.state = initialState.toObject();
@ -117,6 +119,7 @@ class EditProfile extends ImmutablePureComponent {
avatar: state.avatar_file, avatar: state.avatar_file,
header: state.header_file, header: state.header_file,
locked: state.locked, locked: state.locked,
accepts_email_list: state.accepts_email_list,
}, this.getFieldParams().toJS()); }, this.getFieldParams().toJS());
} }
@ -246,6 +249,13 @@ class EditProfile extends ImmutablePureComponent {
checked={this.state.stranger_notifications} checked={this.state.stranger_notifications}
onChange={this.handleCheckboxChange} onChange={this.handleCheckboxChange}
/> />
<Checkbox
label={<FormattedMessage id='edit_profile.fields.accepts_email_list_label' defaultMessage='Subscribe to newsletter' />}
hint={<FormattedMessage id='edit_profile.hints.accepts_email_list' defaultMessage='Opt-in to news and marketing updates.' />}
name='accepts_email_list'
checked={this.state.accepts_email_list}
onChange={this.handleCheckboxChange}
/>
</FieldsGroup> </FieldsGroup>
<FieldsGroup> <FieldsGroup>
<div className='fields-row__column fields-group'> <div className='fields-row__column fields-group'>

@ -28,6 +28,7 @@ const messages = defineMessages({
agreement: { id: 'registration.agreement', defaultMessage: 'I agree to the {tos}.' }, agreement: { id: 'registration.agreement', defaultMessage: 'I agree to the {tos}.' },
tos: { id: 'registration.tos', defaultMessage: 'Terms of Service' }, tos: { id: 'registration.tos', defaultMessage: 'Terms of Service' },
close: { id: 'registration.confirmation_modal.close', defaultMessage: 'Close' }, close: { id: 'registration.confirmation_modal.close', defaultMessage: 'Close' },
newsletter: { id: 'registration.newsletter', defaultMessage: 'Subscribe to newsletter.' },
}); });
const mapStateToProps = (state, props) => ({ const mapStateToProps = (state, props) => ({
@ -232,6 +233,11 @@ class RegistrationForm extends ImmutablePureComponent {
onChange={this.onCheckboxChange} onChange={this.onCheckboxChange}
required required
/> />
<Checkbox
label={intl.formatMessage(messages.newsletter)}
name='accepts_email_list'
onChange={this.onCheckboxChange}
/>
</div> </div>
<div className='actions'> <div className='actions'>
<button name='button' type='submit' className='btn button button-primary'> <button name='button' type='submit' className='btn button button-primary'>

Loading…
Cancel
Save