-
Notifications
You must be signed in to change notification settings - Fork 853
Forms: Show status notice and publish for synced forms #46914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
Add an editor notice for synced forms that are not published and provide a "Publish now" action. Changes include: new changelog entry; import Button, useState and sprintf in edit.tsx; add saveEditedEntityRecord dispatch and isPublishing state; implement handlePublishForm to set status to publish and save the entity; add a statusNotice config and render it above the block content; include SCSS for notice spacing and button margin; update the JetpackForm type to include status. Purpose: inform editors when a synced form won't display on the frontend and allow quick publishing from the block editor.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds an editor-only status notice for synced Contact Form blocks so editors can see when the referenced jetpack_form is not publish, and (when possible) publish it directly from the notice.
Changes:
- Extend synced form loading to include the referenced form’s
status. - Render a non-dismissible Notice above the synced form in the block editor for non-
publishstatuses, with a “Publish now” action for eligible statuses. - Add styling and a changelog entry for the new editor notice.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
projects/packages/forms/src/blocks/contact-form/hooks/use-synced-form.ts |
Adds status to the typed shape of the fetched synced form record. |
projects/packages/forms/src/blocks/contact-form/editor.scss |
Styles the new synced-form status notice and its button spacing. |
projects/packages/forms/src/blocks/contact-form/edit.tsx |
Implements status notice UI and publish action for synced forms in the editor. |
projects/packages/forms/changelog/fix-form-statuses-notice |
Adds a patch-level changelog entry for the editor status notice feature. |
| setIsPublishingForm( true ); | ||
| try { | ||
| await editEntityRecord( 'postType', FORM_POST_TYPE, ref, { status: 'publish' } ); | ||
| await saveEditedEntityRecord( 'postType', FORM_POST_TYPE, ref ); | ||
| } finally { |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handlePublishForm doesn’t handle save failures. If saveEditedEntityRecord rejects (permissions/network/etc.), the button just stops spinning with no feedback. Please add error handling (e.g., show a createErrorNotice from @wordpress/notices, similar to convert-form-toolbar.tsx) so users understand the publish action failed.
|
|
||
| .components-button { | ||
| margin-left: 8px; | ||
| } |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SCSS uses physical direction (margin-left) which is not RTL/writing-mode friendly. Prefer logical properties here (e.g., margin-inline-start) so spacing works automatically in RTL layouts. See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Claude finished @lezama's task in 1m 3s —— View job Reviewing wording and design for synced form status notices
Wording FeedbackCritical Issues
Minor Suggestions
Design FeedbackStyling Issues
UX Improvements
SummaryStrengths:
Areas for improvement:
The copilot review also caught several of these issues. I'd prioritize:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| status: 'info', | ||
| message: __( | ||
| 'This form is private and will not be displayed on the frontend until published.', | ||
| 'jetpack-forms' | ||
| ), |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “private” status notice text is inaccurate. Synced forms are only rendered on the frontend when the referenced jetpack_form post status is publish (see projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php where render_synced_form() returns empty for any non-publish status). The notice should not imply private forms are visible to administrators; it should instead state that private forms won’t be displayed on the frontend unless/until published (or otherwise match the actual rendering rules).
| const handlePublishForm = useCallback( async () => { | ||
| if ( ! ref ) { | ||
| return; | ||
| } | ||
| setIsPublishingForm( true ); | ||
| try { | ||
| await editEntityRecord( 'postType', FORM_POST_TYPE, ref, { status: 'publish' } ); | ||
| await saveEditedEntityRecord( 'postType', FORM_POST_TYPE, ref ); | ||
| } finally { | ||
| setIsPublishingForm( false ); | ||
| } | ||
| }, [ ref, editEntityRecord, saveEditedEntityRecord ] ); |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handlePublishForm always clears the busy state in finally, but it swallows save/publish failures (no catch) so users get no feedback if the publish request is rejected (permissions, network, validation, etc.). Consider catching errors and surfacing them via the notices store (snackbar) and/or keeping the status notice visible until the save succeeds (matching the error-handling pattern used elsewhere, e.g. the convert toolbar).
| Significance: patch | ||
| Type: added | ||
|
|
||
| Contact Form: Add status notice for non-published synced forms in block editor. |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelog entry text doesn’t follow the repo’s changelog style guidance: after the component prefix it should use imperative mood with a capitalized verb (e.g., “Contact Form: Add …” / “Contact Form: Show …”), rather than “Contact Form: add …”.
| Contact Form: Add status notice for non-published synced forms in block editor. | |
| Contact Form: Show status notice for non-published synced forms in the block editor. |
- Fix RTL support by using margin-inline-start instead of margin-left - Update private status to warning (since it blocks display) - Clarify private status message with actionable guidance - Add context to pending review message about approval workflow - Add error handling for publish action with snackbar notifications Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
| } catch { | ||
| createErrorNotice( | ||
| __( | ||
| 'Failed to publish form. Please try again or check your permissions.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's clarify which permissions they can check to make this more actionable.
| try { | ||
| await editEntityRecord( 'postType', FORM_POST_TYPE, ref, { status: 'publish' } ); | ||
| await saveEditedEntityRecord( 'postType', FORM_POST_TYPE, ref ); | ||
| createSuccessNotice( __( 'Form published successfully.', 'jetpack-forms' ), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| createSuccessNotice( __( 'Form published successfully.', 'jetpack-forms' ), { | |
| createSuccessNotice( __( 'Form published.', 'jetpack-forms' ), { |
"Successfully" feels a bit formal but shorter feels blunt; I wonder if this would be a good place to spice up the copy a bit? "Great!" in the front for example. @ilonagl
It's a copy likely seen rarely and recovers from a kind of "alert/error" state, so little congrats seems in place. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand the full context of this state, but maybe something like "Your form is live and ready to collect responses." would be more helpful? Even "Congrats! Your form is live." could work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are great 👍
| > = { | ||
| trash: { | ||
| status: 'error', | ||
| message: __( 'Trashed — not visible to visitors.', 'jetpack-forms' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if there's a way to smooth these copies to more natural language without —
| ? sprintf( | ||
| /* translators: %s: scheduled publish date */ | ||
| __( 'Hidden until publication on %s.', 'jetpack-forms' ), | ||
| dateI18n( 'F j, Y g:i a', syncedForm.date ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fully localize the datetime you can pull the setting like so — it differs between locales:
import { dateI18n, getSettings as getDateSettings } from '@wordpress/date';
const dateSettings = getDateSettings();
dateI18n( dateSettings.formats.datetime, syncedForm.date );| .jetpack-contact-form__status-notice { | ||
| margin-bottom: 16px; | ||
|
|
||
| .components-button { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give the button a class and target that so that we avoid using internal classes, which aren't considered stable API and can change; imagine, e.g. swapping the button to @wordpress/ui without noticing this CSS, someone adding extra buttons to the notice, etc.
Although using the component API for actions is much better: https://github.com/Automattic/jetpack/pull/46914/changes#r2757755847
| formStatus | ||
| ) } | ||
| { formStatus !== 'trash' && ( | ||
| <Button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's pass actions to Notice instead. It'll style and place the CTA consistently and doesn't require extra CSS to make it look good.
https://wordpress.github.io/gutenberg/?path=/story/components-notice--with-actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the component we want to use instead of the ones in the PR screenshots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already using it in this PR but not sure why it looks different in the editor than Gutenberg storybook :-)
|
Great work in showing these info notices! Here are the copy suggestions: DraftCurrent
Proposed
Primary action
Why
Pending reviewCurrent
Proposed
Primary action
Why
PrivateCurrent
Proposed
Primary action
Why
ScheduledCurrent
Proposed
Secondary actions
Why
TrashedCurrent
Proposed
Primary actions
|
Move the form status notice logic into a dedicated FormStatusNotice component for better separation of concerns and reusability. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Refine the changelog wording to generalize the entry. Replaced 'Contact Form: Add status notice for non-published synced forms in block editor.' with 'Show status notice for non-published synced forms in block editor.' to clarify the scope and phrasing of the added notice.
Allow users to undo the publish action via a snackbar action button, reverting the form to its previous status. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Allow draft, pending, and scheduled forms to preview on frontend for editors - Display status notice above form explaining visibility - Trashed forms remain hidden for everyone - Private forms visible only to editors with notice Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add an "Edit form" link to the frontend status notice that takes editors directly to the form editor. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
I can't speak from designs, but I love that we have this. Information to the user, specially on new things, is always a must. In terms of code, it looks good to me. As always, Mikael has good points, specially with the locale trick. The only thing I'd say, looking at @ilonagl careful review, is on the scheduled status.
Since I read around "spice things up", could this also be "It will go live in [live countdown timer here]"? |
Draft:

Pending:

Private:

Scheduled:

Trashed:

Proposed changes:
When a synced form is displayed in the block editor, users
currently have no indication of the form's post status. A form
could be trashed or in draft status, but this is invisible to
editors.
This PR adds a notice that displays when a synced form has a
status other than "publish":
For non-trashed forms, a "Publish now" button allows users to
publish the form directly from the notice.
Other information:
Jetpack product discussion
No
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Enable CFM via
save)
2. In the WordPress admin, go to Posts > All Posts (or use the
database) and find the
jetpack_formpost type entry3. Change the form's status to
draftvia quick edit or thedatabase
4. Insert the same form into a post using the Form block with
a reference
5. Verify that a warning notice appears above the form
stating "This form is a draft and will not be displayed on the frontend until published."
6. Verify there is a "Publish now" button in the notice
7. Click "Publish now" and verify the notice disappears after the form is published
8. Repeat testing with other statuses:
-
trash- should show error notice without publish button-
pending- should show warning notice with publish button-
private- should show info notice with publish button9. Verify that published forms show no notice