Skip to content

Commit

Permalink
Add p2 autofollow setting to /me/settings endpoint (#95583)
Browse files Browse the repository at this point in the history
* Add p2 autofollow setting to /me/settings endpoint

* Remove unnecessary translate for automatticians
  • Loading branch information
bor0 authored Oct 23, 2024
1 parent 9448fd1 commit ce739e8
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions client/me/notification-settings/reader-subscriptions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import i18n, { localize } from 'i18n-calypso';
import { flowRight as compose } from 'lodash';
import { Component } from 'react';
import { connect } from 'react-redux';
import QueryReaderTeams from 'calypso/components/data/query-reader-teams';
import FormButton from 'calypso/components/forms/form-button';
import FormCheckbox from 'calypso/components/forms/form-checkbox';
import FormFieldset from 'calypso/components/forms/form-fieldset';
Expand All @@ -19,7 +20,9 @@ import twoStepAuthorization from 'calypso/lib/two-step-authorization';
import withFormBase from 'calypso/me/form-base/with-form-base';
import Navigation from 'calypso/me/notification-settings/navigation';
import ReauthRequired from 'calypso/me/reauth-required';
import { isAutomatticTeamMember } from 'calypso/reader/lib/teams';
import { recordGoogleEvent } from 'calypso/state/analytics/actions';
import { getReaderTeams } from 'calypso/state/teams/selectors';
import SubscriptionManagementBackButton from '../subscription-management-back-button';

class NotificationSubscriptions extends Component {
Expand Down Expand Up @@ -55,10 +58,13 @@ class NotificationSubscriptions extends Component {
}

render() {
const { locale } = this.props;
const { locale, teams } = this.props;
const isAutomattician = isAutomatticTeamMember( teams );

return (
<Main wideLayout className="reader-subscriptions__notifications-settings">
<QueryReaderTeams />

<PageViewTracker
path="/me/notifications/subscriptions"
title="Me > Notifications > Subscriptions Delivery"
Expand Down Expand Up @@ -235,6 +241,26 @@ class NotificationSubscriptions extends Component {
</FormLabel>
</FormFieldset>

{ isAutomattician && (
<FormFieldset>
<FormLegend>Auto-follow P2 posts upon commenting (Automatticians only)</FormLegend>
<FormLabel>
<FormCheckbox
checked={ this.props.getSetting( 'p2_autofollow_on_comment' ) }
disabled={ this.props.getDisabledState() }
id="p2_autofollow_on_comment"
name="p2_autofollow_on_comment"
onChange={ this.props.toggleSetting }
onClick={ this.handleCheckboxEvent( 'Auto-follow P2 Upon Comment' ) }
/>
<span>
Automatically subscribe to notifications for a P2 post whenever you leave a
comment on it.
</span>
</FormLabel>
</FormFieldset>
) }

<FormButton
isSubmitting={ this.props.isUpdatingUserSettings }
disabled={ this.props.isUpdatingUserSettings || ! this.props.hasUnsavedUserSettings }
Expand All @@ -251,8 +277,16 @@ class NotificationSubscriptions extends Component {
}
}

const mapStateToProps = ( state ) => ( {
teams: getReaderTeams( state ),
} );

const mapDispatchToProps = {
recordGoogleEvent,
};

export default compose(
connect( null, { recordGoogleEvent } ),
connect( mapStateToProps, mapDispatchToProps ),
localize,
protectForm,
withLocalizedMoment,
Expand Down

0 comments on commit ce739e8

Please sign in to comment.