Skip to content

Commit 35df9af

Browse files
edanzermatticbot
authored andcommitted
Forms: add dashboard tabs with feature flag (#46506)
--------- Co-authored-by: Enej Bajgoric <[email protected]> Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/20932210767 Upstream-Ref: Automattic/jetpack@31a8b3c
1 parent 245b75d commit 35df9af

File tree

16 files changed

+299
-170
lines changed

16 files changed

+299
-170
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"automattic/jetpack-error": "^3.0.6",
3232
"automattic/jetpack-external-connections": "^0.1.11",
3333
"automattic/jetpack-external-media": "^0.7.3",
34-
"automattic/jetpack-forms": "^7.3.0",
34+
"automattic/jetpack-forms": "^7.4.0-alpha",
3535
"automattic/jetpack-image-cdn": "^0.7.24",
3636
"automattic/jetpack-import": "^0.9.13",
3737
"automattic/jetpack-ip": "^0.4.10",

jetpack_vendor/automattic/jetpack-forms/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [7.4.0-alpha] - unreleased
9+
10+
This is an alpha version! The changes listed here are not final.
11+
12+
### Added
13+
- Forms: add centralized dashboard tabs.
14+
815
## [7.3.0] - 2026-01-12
916
### Security
1017
- Add SSRF protection for webhook URLs to prevent requests to internal networks and cloud metadata endpoints. [#46424]
@@ -2043,6 +2050,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
20432050
- Added a new jetpack/forms package [#28409]
20442051
- Added a public load_contact_form method for initializing the contact form module. [#28416]
20452052

2053+
[7.4.0-alpha]: https://github.com/automattic/jetpack-forms/compare/v7.3.0...v7.4.0-alpha
20462054
[7.3.0]: https://github.com/automattic/jetpack-forms/compare/v7.2.0...v7.3.0
20472055
[7.2.0]: https://github.com/automattic/jetpack-forms/compare/v7.1.0...v7.2.0
20482056
[7.1.0]: https://github.com/automattic/jetpack-forms/compare/v7.0.0...v7.1.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('jetpack-script-data', 'lodash', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-dom', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '4da4124d202b6334a254');
1+
<?php return array('dependencies' => array('jetpack-script-data', 'lodash', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-dom', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '73b258659b48830e0d67');

jetpack_vendor/automattic/jetpack-forms/dist/dashboard/jetpack-forms-dashboard.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jetpack_vendor/automattic/jetpack-forms/dist/dashboard/jetpack-forms-dashboard.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jetpack_vendor/automattic/jetpack-forms/dist/dashboard/jetpack-forms-dashboard.rtl.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jetpack_vendor/automattic/jetpack-forms/src/class-jetpack-forms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class Jetpack_Forms {
1616

17-
const PACKAGE_VERSION = '7.3.0';
17+
const PACKAGE_VERSION = '7.4.0-alpha';
1818

1919
/**
2020
* Load the contact form module.

jetpack_vendor/automattic/jetpack-forms/src/contact-form/class-contact-form-endpoint.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,29 +1493,31 @@ public function update_read_status( $request ) {
14931493
*/
14941494
public function get_forms_config( WP_REST_Request $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
14951495
$config = array(
1496+
// Feature flags.
1497+
'isCentralFormManagementEnabled' => Contact_Form_Plugin::has_editor_feature_flag( 'central-form-management' ),
14961498
// From jpFormsBlocks in class-contact-form-block.php.
1497-
'formsResponsesUrl' => Forms_Dashboard::get_forms_admin_url(),
1498-
'isMailPoetEnabled' => Jetpack_Forms::is_mailpoet_enabled(),
1499-
'isHostingerReachEnabled' => Jetpack_Forms::is_hostinger_reach_enabled(),
1499+
'formsResponsesUrl' => Forms_Dashboard::get_forms_admin_url(),
1500+
'isMailPoetEnabled' => Jetpack_Forms::is_mailpoet_enabled(),
1501+
'isHostingerReachEnabled' => Jetpack_Forms::is_hostinger_reach_enabled(),
15001502
// From config in class-dashboard.php.
1501-
'blogId' => get_current_blog_id(),
1502-
'gdriveConnectSupportURL' => esc_url( Redirect::get_url( 'jetpack-support-contact-form-export' ) ),
1503-
'pluginAssetsURL' => Jetpack_Forms::assets_url(),
1504-
'siteURL' => ( new Status() )->get_site_suffix(),
1505-
'hasFeedback' => ( new Forms_Dashboard() )->has_feedback(),
1506-
'isNotesEnabled' => Forms_Dashboard::is_notes_enabled(),
1507-
'isIntegrationsEnabled' => Jetpack_Forms::is_integrations_enabled(),
1508-
'isWebhooksEnabled' => Jetpack_Forms::is_webhooks_enabled(),
1509-
'showDashboardIntegrations' => Jetpack_Forms::show_dashboard_integrations(),
1510-
'showBlockIntegrations' => Jetpack_Forms::show_block_integrations(),
1511-
'showIntegrationIcons' => Jetpack_Forms::show_integration_icons(),
1512-
'dashboardURL' => Forms_Dashboard::get_forms_admin_url(),
1503+
'blogId' => get_current_blog_id(),
1504+
'gdriveConnectSupportURL' => esc_url( Redirect::get_url( 'jetpack-support-contact-form-export' ) ),
1505+
'pluginAssetsURL' => Jetpack_Forms::assets_url(),
1506+
'siteURL' => ( new Status() )->get_site_suffix(),
1507+
'hasFeedback' => ( new Forms_Dashboard() )->has_feedback(),
1508+
'isNotesEnabled' => Forms_Dashboard::is_notes_enabled(),
1509+
'isIntegrationsEnabled' => Jetpack_Forms::is_integrations_enabled(),
1510+
'isWebhooksEnabled' => Jetpack_Forms::is_webhooks_enabled(),
1511+
'showDashboardIntegrations' => Jetpack_Forms::show_dashboard_integrations(),
1512+
'showBlockIntegrations' => Jetpack_Forms::show_block_integrations(),
1513+
'showIntegrationIcons' => Jetpack_Forms::show_integration_icons(),
1514+
'dashboardURL' => Forms_Dashboard::get_forms_admin_url(),
15131515
// New data.
1514-
'canInstallPlugins' => current_user_can( 'install_plugins' ),
1515-
'canActivatePlugins' => current_user_can( 'activate_plugins' ),
1516-
'exportNonce' => wp_create_nonce( 'feedback_export' ),
1517-
'newFormNonce' => wp_create_nonce( 'create_new_form' ),
1518-
'emptyTrashDays' => defined( 'EMPTY_TRASH_DAYS' ) ? EMPTY_TRASH_DAYS : 0,
1516+
'canInstallPlugins' => current_user_can( 'install_plugins' ),
1517+
'canActivatePlugins' => current_user_can( 'activate_plugins' ),
1518+
'exportNonce' => wp_create_nonce( 'feedback_export' ),
1519+
'newFormNonce' => wp_create_nonce( 'create_new_form' ),
1520+
'emptyTrashDays' => defined( 'EMPTY_TRASH_DAYS' ) ? EMPTY_TRASH_DAYS : 0,
15191521
);
15201522

15211523
return rest_ensure_response( $config );
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { useCallback } from '@wordpress/element';
5+
import { __ } from '@wordpress/i18n';
6+
import { useLocation, useNavigate } from 'react-router';
7+
/**
8+
* Internal dependencies
9+
*/
10+
import * as Tabs from '../tabs/index.ts';
11+
12+
type TabValue = 'forms' | 'responses';
13+
14+
/**
15+
* Route-aware top tabs for the Forms dashboard (Forms / All Responses).
16+
* This component controls routing; it does not manage filters.
17+
*
18+
* @return {JSX.Element} The tabs component.
19+
*/
20+
export default function FormsResponsesTabs(): JSX.Element {
21+
const location = useLocation();
22+
const navigate = useNavigate();
23+
24+
const value: TabValue = location.pathname === '/forms' ? 'forms' : 'responses';
25+
26+
const onValueChange = useCallback(
27+
( nextValue: TabValue ) => {
28+
navigate( nextValue === 'forms' ? '/forms' : '/responses' );
29+
},
30+
[ navigate ]
31+
);
32+
33+
return (
34+
<Tabs.Root value={ value } onValueChange={ onValueChange }>
35+
<Tabs.List density="compact">
36+
<Tabs.Tab value="forms">{ __( 'Forms', 'jetpack-forms' ) }</Tabs.Tab>
37+
<Tabs.Tab value="responses">{ __( 'All Responses', 'jetpack-forms' ) }</Tabs.Tab>
38+
</Tabs.List>
39+
</Tabs.Root>
40+
);
41+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { JetpackLogo } from '@automattic/jetpack-components';
5+
import { useEffect } from '@wordpress/element';
6+
import { __ } from '@wordpress/i18n';
7+
import { useNavigate } from 'react-router';
8+
/**
9+
* Internal dependencies
10+
*/
11+
import useConfigValue from '../../hooks/use-config-value.ts';
12+
import FormsResponsesTabs from '../components/forms-responses-tabs/index.tsx';
13+
import Page from '../components/page/index.tsx';
14+
15+
/**
16+
* Forms dashboard "Forms" route placeholder.
17+
*
18+
* @return {JSX.Element|null} The placeholder page, or null when redirecting.
19+
*/
20+
export default function FormsDashboardForms(): JSX.Element | null {
21+
const navigate = useNavigate();
22+
const isCentralFormManagementEnabled = useConfigValue( 'isCentralFormManagementEnabled' );
23+
24+
useEffect( () => {
25+
if ( isCentralFormManagementEnabled === false ) {
26+
navigate( '/responses', { replace: true } );
27+
}
28+
}, [ isCentralFormManagementEnabled, navigate ] );
29+
30+
// Avoid rendering the placeholder if the flag is off (we'll redirect).
31+
if ( isCentralFormManagementEnabled === false ) {
32+
return null;
33+
}
34+
35+
return (
36+
<div className="jp-forms-layout__surface is-stage">
37+
<Page
38+
title={
39+
<div className="jp-forms-page-header-title">
40+
<JetpackLogo showText={ false } width={ 20 } />
41+
{ __( 'Forms', 'jetpack-forms' ) }
42+
</div>
43+
}
44+
subTitle={ __( 'View and manage all your forms in one place.', 'jetpack-forms' ) }
45+
tabs={ <FormsResponsesTabs /> }
46+
hasPadding={ false }
47+
>
48+
<p style={ { fontWeight: 'bold', margin: '20px' } }>
49+
{ __( 'Forms will appear here', 'jetpack-forms' ) }
50+
</p>
51+
</Page>
52+
</div>
53+
);
54+
}

0 commit comments

Comments
 (0)