Skip to content

Commit bc7c822

Browse files
authored
Revert "Revert "Forms: add integration display filters (#46112)" (#46155)"
This reverts commit 4ee222e.
1 parent 4ee222e commit bc7c822

File tree

8 files changed

+80
-24
lines changed

8 files changed

+80
-24
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: add integrations display filters.

projects/packages/forms/src/blocks/contact-form/edit.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ function JetpackContactFormEdit( {
179179
notificationRecipients,
180180
webhooks,
181181
} = attributes;
182-
const showFormIntegrations = useConfigValue( 'isIntegrationsEnabled' );
182+
const isIntegrationsEnabled = useConfigValue( 'isIntegrationsEnabled' );
183183
const showWebhooks = useConfigValue( 'isWebhooksEnabled' ) && hasFeatureFlag( 'form-webhooks' );
184+
const showBlockIntegrations = useConfigValue( 'showBlockIntegrations' );
184185
const instanceId = useInstanceId( JetpackContactFormEdit );
185186

186187
// Backward compatibility for the deprecated customThankyou attribute.
@@ -921,7 +922,7 @@ function JetpackContactFormEdit( {
921922
setAttributes={ setAttributes }
922923
/>
923924
</PanelBody>
924-
{ showFormIntegrations && (
925+
{ isIntegrationsEnabled && showBlockIntegrations && (
925926
<Suspense fallback={ <div /> }>
926927
<IntegrationControls attributes={ attributes } setAttributes={ setAttributes } />
927928
</Suspense>

projects/packages/forms/src/class-jetpack-forms.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,40 @@ public static function is_webhooks_enabled() {
138138
*/
139139
return apply_filters( 'jetpack_forms_webhooks_enabled', false );
140140
}
141+
142+
/**
143+
* Returns true if the Integrations UI should be shown in the Forms dashboard.
144+
*
145+
* @since $$next-version$$
146+
*
147+
* @return boolean
148+
*/
149+
public static function show_dashboard_integrations() {
150+
/**
151+
* Whether to show Integrations UI in the Forms dashboard.
152+
*
153+
* @since $$next-version$$
154+
*
155+
* @param bool true Whether to show the Integrations UI in the dashboard. Default true.
156+
*/
157+
return apply_filters( 'jetpack_forms_show_dashboard_integrations', true );
158+
}
159+
160+
/**
161+
* Returns true if the Integrations UI should be shown in the Form block editor.
162+
*
163+
* @since $$next-version$$
164+
*
165+
* @return boolean
166+
*/
167+
public static function show_block_integrations() {
168+
/**
169+
* Whether to show Integrations UI in the Form block editor.
170+
*
171+
* @since $$next-version$$
172+
*
173+
* @param bool true Whether to show the Integrations UI in the editor. Default true.
174+
*/
175+
return apply_filters( 'jetpack_forms_show_block_integrations', true );
176+
}
141177
}

projects/packages/forms/src/contact-form/class-contact-form-endpoint.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,24 +1484,26 @@ public function update_read_status( $request ) {
14841484
public function get_forms_config( WP_REST_Request $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
14851485
$config = array(
14861486
// From jpFormsBlocks in class-contact-form-block.php.
1487-
'formsResponsesUrl' => Forms_Dashboard::get_forms_admin_url(),
1488-
'isMailPoetEnabled' => Jetpack_Forms::is_mailpoet_enabled(),
1489-
'isHostingerReachEnabled' => Jetpack_Forms::is_hostinger_reach_enabled(),
1487+
'formsResponsesUrl' => Forms_Dashboard::get_forms_admin_url(),
1488+
'isMailPoetEnabled' => Jetpack_Forms::is_mailpoet_enabled(),
1489+
'isHostingerReachEnabled' => Jetpack_Forms::is_hostinger_reach_enabled(),
14901490
// From config in class-dashboard.php.
1491-
'blogId' => get_current_blog_id(),
1492-
'gdriveConnectSupportURL' => esc_url( Redirect::get_url( 'jetpack-support-contact-form-export' ) ),
1493-
'pluginAssetsURL' => Jetpack_Forms::assets_url(),
1494-
'siteURL' => ( new Status() )->get_site_suffix(),
1495-
'hasFeedback' => ( new Forms_Dashboard() )->has_feedback(),
1496-
'isIntegrationsEnabled' => Jetpack_Forms::is_integrations_enabled(),
1497-
'isWebhooksEnabled' => Jetpack_Forms::is_webhooks_enabled(),
1498-
'dashboardURL' => Forms_Dashboard::get_forms_admin_url(),
1491+
'blogId' => get_current_blog_id(),
1492+
'gdriveConnectSupportURL' => esc_url( Redirect::get_url( 'jetpack-support-contact-form-export' ) ),
1493+
'pluginAssetsURL' => Jetpack_Forms::assets_url(),
1494+
'siteURL' => ( new Status() )->get_site_suffix(),
1495+
'hasFeedback' => ( new Forms_Dashboard() )->has_feedback(),
1496+
'isIntegrationsEnabled' => Jetpack_Forms::is_integrations_enabled(),
1497+
'isWebhooksEnabled' => Jetpack_Forms::is_webhooks_enabled(),
1498+
'showDashboardIntegrations' => Jetpack_Forms::show_dashboard_integrations(),
1499+
'showBlockIntegrations' => Jetpack_Forms::show_block_integrations(),
1500+
'dashboardURL' => Forms_Dashboard::get_forms_admin_url(),
14991501
// New data.
1500-
'canInstallPlugins' => current_user_can( 'install_plugins' ),
1501-
'canActivatePlugins' => current_user_can( 'activate_plugins' ),
1502-
'exportNonce' => wp_create_nonce( 'feedback_export' ),
1503-
'newFormNonce' => wp_create_nonce( 'create_new_form' ),
1504-
'emptyTrashDays' => defined( 'EMPTY_TRASH_DAYS' ) ? EMPTY_TRASH_DAYS : 0,
1502+
'canInstallPlugins' => current_user_can( 'install_plugins' ),
1503+
'canActivatePlugins' => current_user_can( 'activate_plugins' ),
1504+
'exportNonce' => wp_create_nonce( 'feedback_export' ),
1505+
'newFormNonce' => wp_create_nonce( 'create_new_form' ),
1506+
'emptyTrashDays' => defined( 'EMPTY_TRASH_DAYS' ) ? EMPTY_TRASH_DAYS : 0,
15051507
);
15061508

15071509
return rest_ensure_response( $config );

projects/packages/forms/src/dashboard/components/layout/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const Layout = () => {
1717
const location = useLocation();
1818
const [ isSm ] = useBreakpointMatch( 'sm' );
1919

20-
const enableIntegrationsTab = useConfigValue( 'isIntegrationsEnabled' );
21-
const isLoadingConfig = enableIntegrationsTab === undefined;
20+
const isIntegrationsEnabled = useConfigValue( 'isIntegrationsEnabled' );
21+
const showDashboardIntegrations = useConfigValue( 'showDashboardIntegrations' );
22+
const isLoadingConfig =
23+
isIntegrationsEnabled === undefined || showDashboardIntegrations === undefined;
2224

2325
const isIntegrationsOpen = location.pathname === '/integrations';
2426

@@ -32,7 +34,9 @@ const Layout = () => {
3234
<div className="jp-forms-layout">
3335
<div className="jp-forms-layout__content">
3436
{ ! isLoadingConfig && <Outlet /> }
35-
{ isIntegrationsOpen && <Integrations /> }
37+
{ isIntegrationsOpen && isIntegrationsEnabled && showDashboardIntegrations && (
38+
<Integrations />
39+
) }
3640
</div>
3741
</div>
3842
);

projects/packages/forms/src/dashboard/inbox/stage/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ export default function InboxView() {
125125
return setupSidebarWidthObserver();
126126
}, [] );
127127

128-
const enableIntegrationsTab = useConfigValue( 'isIntegrationsEnabled' );
128+
const isIntegrationsEnabled = useConfigValue( 'isIntegrationsEnabled' );
129+
const showDashboardIntegrations = useConfigValue( 'showDashboardIntegrations' );
129130

130131
const {
131132
setCurrentQuery,
@@ -476,13 +477,13 @@ export default function InboxView() {
476477
} else {
477478
headerActionsArray.unshift( <CreateFormButton key="create" /> );
478479
// Only show Create Form and Integrations buttons on inbox (when not in trash or spam)
479-
if ( enableIntegrationsTab ) {
480+
if ( isIntegrationsEnabled && showDashboardIntegrations ) {
480481
headerActionsArray.unshift( <IntegrationsButton key="integrations" /> );
481482
}
482483
}
483484

484485
return headerActionsArray;
485-
}, [ statusFilter, enableIntegrationsTab ] );
486+
}, [ statusFilter, isIntegrationsEnabled, showDashboardIntegrations ] );
486487

487488
const pageContent = (
488489
<Page

projects/packages/forms/src/types/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ export interface FormsConfigData {
236236
isIntegrationsEnabled?: boolean;
237237
/** Whether webhooks are enabled (feature-flagged). */
238238
isWebhooksEnabled?: boolean;
239+
/** Whether to show integrations in the Forms dashboard UI. */
240+
showDashboardIntegrations?: boolean;
241+
/** Whether to show integrations in the Form block editor UI. */
242+
showBlockIntegrations?: boolean;
239243
/** Whether the current user can install plugins (install_plugins). */
240244
canInstallPlugins?: boolean;
241245
/** Whether the current user can activate plugins (activate_plugins). */
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: add integrations display filters.

0 commit comments

Comments
 (0)