Skip to content

Commit e14ef0b

Browse files
authored
Forms: Remove notifications feature flag (#45682)
* Enable form notifications Remove the feature flag to enable form notifications for everyone. * changelog * Revert "Enable form notifications" This reverts commit 7df5261. * Enable form notifications (take 2) Cursor tab autocompletion tried to be too smart and deleted code that it shouldn't have.
1 parent 632c573 commit e14ef0b

File tree

4 files changed

+74
-72
lines changed

4 files changed

+74
-72
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Forms: enable forms push notifications functionality.

projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public static function register_feature( $features ) {
6363
// Features that are only available to users with a paid plan.
6464
$features['multistep-form'] = Current_Plan::supports( 'multistep-form' );
6565

66-
// Form notifications feature flag - can be controlled via filter
67-
$features['form-notifications'] = apply_filters( 'jetpack_forms_enable_notifications', false );
68-
6966
return $features;
7067
}
7168

projects/packages/forms/src/blocks/contact-form/components/notifications-settings.js

Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { isWpcomPlatformSite } from '@automattic/jetpack-script-data';
2-
import { hasFeatureFlag } from '@automattic/jetpack-shared-extension-utils';
32
import { FormTokenField, ToggleControl, ExternalLink } from '@wordpress/components';
43
import { store as coreStore } from '@wordpress/core-data';
54
import { useSelect } from '@wordpress/data';
@@ -71,78 +70,76 @@ const NotificationsSettings = ( {
7170
postAuthorEmail={ postAuthorEmail }
7271
setAttributes={ setAttributes }
7372
/>
74-
{ hasFeatureFlag( 'form-notifications' ) && (
75-
<>
76-
<ToggleControl
77-
label={ __( 'Enable notifications for responses', 'jetpack-forms' ) }
78-
help={ createInterpolateElement(
79-
__(
80-
'Receive push notifications when someone fills out your form. <pushNotificationsLink>Learn more.</pushNotificationsLink>',
81-
'jetpack-forms'
82-
),
83-
{
84-
pushNotificationsLink: <ExternalLink href={ supportNotificationsLink } />,
85-
}
86-
) }
87-
checked={ localFormNotifications }
88-
onChange={ value => {
89-
if ( value ) {
90-
// Auto-select post author when enabling notifications
91-
const authorIdStr = postAuthorId?.toString();
92-
let recipientsToSet = localNotificationRecipients;
93-
94-
if (
95-
recipientsToSet.length === 0 &&
96-
authorIdStr &&
97-
eligibleUsers.some( user => user.id === postAuthorId )
98-
) {
99-
recipientsToSet = [ authorIdStr ];
100-
}
73+
<>
74+
<ToggleControl
75+
label={ __( 'Enable notifications for responses', 'jetpack-forms' ) }
76+
help={ createInterpolateElement(
77+
__(
78+
'Receive push notifications when someone fills out your form. <pushNotificationsLink>Learn more.</pushNotificationsLink>',
79+
'jetpack-forms'
80+
),
81+
{
82+
pushNotificationsLink: <ExternalLink href={ supportNotificationsLink } />,
83+
}
84+
) }
85+
checked={ localFormNotifications }
86+
onChange={ value => {
87+
if ( value ) {
88+
// Auto-select post author when enabling notifications
89+
const authorIdStr = postAuthorId?.toString();
90+
let recipientsToSet = localNotificationRecipients;
10191

102-
setLocalNotificationRecipients( recipientsToSet );
103-
setAttributes( { notificationRecipients: recipientsToSet } );
104-
} else {
105-
setAttributes( { notificationRecipients: [] } );
92+
if (
93+
recipientsToSet.length === 0 &&
94+
authorIdStr &&
95+
eligibleUsers.some( user => user.id === postAuthorId )
96+
) {
97+
recipientsToSet = [ authorIdStr ];
10698
}
107-
setLocalFormNotifications( value );
108-
} }
109-
__nextHasNoMarginBottom={ true }
110-
/>
111-
{ localFormNotifications && (
112-
<>
113-
<FormTokenField
114-
label={ __( 'Send notifications to', 'jetpack-forms' ) }
115-
value={ selectedUserNames }
116-
suggestions={ allUserNames }
117-
onChange={ selectedNames => {
118-
// If field is empty, default to post author
119-
if ( selectedNames.length === 0 ) {
120-
const authorIdStr = postAuthorId?.toString();
121-
if ( authorIdStr && eligibleUsers.some( user => user.id === postAuthorId ) ) {
122-
const defaultRecipients = [ authorIdStr ];
123-
setLocalNotificationRecipients( defaultRecipients );
124-
setAttributes( { notificationRecipients: defaultRecipients } );
125-
return;
126-
}
99+
100+
setLocalNotificationRecipients( recipientsToSet );
101+
setAttributes( { notificationRecipients: recipientsToSet } );
102+
} else {
103+
setAttributes( { notificationRecipients: [] } );
104+
}
105+
setLocalFormNotifications( value );
106+
} }
107+
__nextHasNoMarginBottom={ true }
108+
/>
109+
{ localFormNotifications && (
110+
<>
111+
<FormTokenField
112+
label={ __( 'Send notifications to', 'jetpack-forms' ) }
113+
value={ selectedUserNames }
114+
suggestions={ allUserNames }
115+
onChange={ selectedNames => {
116+
// If field is empty, default to post author
117+
if ( selectedNames.length === 0 ) {
118+
const authorIdStr = postAuthorId?.toString();
119+
if ( authorIdStr && eligibleUsers.some( user => user.id === postAuthorId ) ) {
120+
const defaultRecipients = [ authorIdStr ];
121+
setLocalNotificationRecipients( defaultRecipients );
122+
setAttributes( { notificationRecipients: defaultRecipients } );
123+
return;
127124
}
125+
}
128126

129-
// Convert user names back to IDs
130-
const newRecipients = selectedNames
131-
.map( name => {
132-
const user = eligibleUsers.find( u => ( u.name || u.slug ) === name );
133-
return user ? user.id.toString() : null;
134-
} )
135-
.filter( Boolean );
136-
setLocalNotificationRecipients( newRecipients );
137-
setAttributes( { notificationRecipients: newRecipients } );
138-
} }
139-
__nextHasNoMarginBottom={ true }
140-
__next40pxDefaultSize={ true }
141-
/>
142-
</>
143-
) }
144-
</>
145-
) }
127+
// Convert user names back to IDs
128+
const newRecipients = selectedNames
129+
.map( name => {
130+
const user = eligibleUsers.find( u => ( u.name || u.slug ) === name );
131+
return user ? user.id.toString() : null;
132+
} )
133+
.filter( Boolean );
134+
setLocalNotificationRecipients( newRecipients );
135+
setAttributes( { notificationRecipients: newRecipients } );
136+
} }
137+
__nextHasNoMarginBottom={ true }
138+
__next40pxDefaultSize={ true }
139+
/>
140+
</>
141+
) }
142+
</>
146143
</>
147144
);
148145
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: enhancement
3+
4+
Forms: enable forms push notifications functionality.

0 commit comments

Comments
 (0)