Skip to content

1142 connect content planner frontend with backend endpoints #23168

Merged
JorPV merged 28 commits intofeature/content-plannerfrom
1142-connect-content-planner-frontend-with-backend-endpoints-
Apr 17, 2026
Merged

1142 connect content planner frontend with backend endpoints #23168
JorPV merged 28 commits intofeature/content-plannerfrom
1142-connect-content-planner-frontend-with-backend-endpoints-

Conversation

@vraja-pro
Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro commented Apr 16, 2026

Context

Summary

This PR can be summarized in the following changelog entry:

  • Connect the content outline endpoint to the frontend and refactor code.

Relevant technical choices:

  • To improve redability of the content outline modal:
    • Separated drabability logic to a hook
    • Separated the badge outline component to separate file
    • Separated the get progress color function to the helpers folder.
  • To improve redability and decouple the the component from the store I added a hook for fetching the content suggestions and fetching the content outline.
  • Move the intent bade to a separate file and created a reusable component that is used in both thh suggestion and outline modals.
  • Separated the content suggestion block from the initialize file to a designated folder and added the banner block for better readabilty.
  • Removed the skip approve property from the modal store slice and added the feature modal status, refactored the way we assign status to the modal for better access and redability.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • On a live link have the yoast test helper with ai api staged checked.
  • Create a new post and click on the get suggestion button in the editor, check you get the approve modal
  • Click on the get suggestion button in the inline banner and check you get the content suggestion modal
  • click on one of the suggestion and check you get the content outline modal
  • Apply outline and check outline is applied.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • [] QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.
  • I have run grunt build:images and commited the results, if my PR introduces new images or SVGs.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes Connect Content Planner frontend with backend endpoints - needed for zip

@vraja-pro vraja-pro added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Apr 16, 2026
@vraja-pro vraja-pro changed the base branch from feature/content-planner to 1132-create-endpoint-for-sending-the-2nd-request-to-ai-api April 16, 2026 10:19
…api' into 1142-connect-content-planner-frontend-with-backend-endpoints-
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 16, 2026

Coverage Report for CI Build 223

Coverage increased (+0.6%) to 53.554%

Details

  • Coverage increased (+0.6%) from the base build.
  • Patch coverage: 71 uncovered changes across 15 files (128 of 199 lines covered, 64.32%).
  • 33 coverage regressions across 5 files.

Uncovered Changes

Top 10 Files by Coverage Impact Changed Covered %
packages/js/src/ai-content-planner/blocks/content-suggestion-block.js 19 3 15.79%
packages/js/src/ai-content-planner/helpers/apply-post-meta-from-outline.js 11 0 0.0%
packages/js/src/ai-content-planner/store/content-outline.js 10 1 10.0%
packages/js/src/ai-content-planner/store/modal.js 22 14 63.64%
packages/js/src/ai-content-planner/hooks/use-fetch-content-outline.js 7 0 0.0%
packages/js/src/ai-content-planner/containers/feature-modal.js 6 0 0.0%
packages/js/src/ai-content-planner/components/content-planner-editor-item.js 3 0 0.0%
packages/js/src/ai-content-planner/hooks/use-apply-outline.js 19 16 84.21%
packages/js/src/ai-content-planner/components/feature-modal.js 13 11 84.62%
packages/js/src/ai-content-planner/blocks/banner-block.js 1 0 0.0%

Coverage Regressions

33 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
src/ai/content-planner/application/content-suggestion-command-handler.php 28 0.0%
packages/js/src/ai-content-planner/components/feature-modal.js 2 92.54%
packages/js/src/ai-content-planner/components/content-suggestions-modal.js 1 88.46%
packages/js/src/ai-content-planner/components/content-outline-modal.js 1 94.32%
packages/js/src/ai-content-planner/store/content-outline.js 1 36.36%

Coverage Stats

Coverage Status
Relevant Lines: 65902
Covered Lines: 35135
Line Coverage: 53.31%
Relevant Branches: 16830
Covered Branches: 9171
Branch Coverage: 54.49%
Branches in Coverage %: Yes
Coverage Strength: 45645.4 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Connects the AI Content Planner “content outline” flow end-to-end by wiring the frontend modal/state machine to the backend get_outline REST endpoint, and refactors the UI into hooks/blocks for better separation of concerns.

Changes:

  • Refactors modal UI state to a Redux Toolkit slice and drives modal step transitions from async request lifecycle.
  • Implements outline fetching + applying: new outline store, fetch hook, draggable structure hook, and apply-outline hook.
  • Splits block registrations into dedicated block modules and updates metadata/intent UI components.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
packages/js/src/ai-content-planner/store/modal.js Replaces hand-rolled reducer/actions with an RTK slice and adds featureModalStatus state driven by async actions.
packages/js/src/ai-content-planner/store/content-suggestions.js Aligns suggestion shape/constants and updates suggestion transformation.
packages/js/src/ai-content-planner/store/content-outline.js Adds outline slice, saga, and control to call the outline REST endpoint.
packages/js/src/ai-content-planner/initialize.js Registers new blocks and initializes store state with the outline endpoint.
packages/js/src/ai-content-planner/hooks/use-fetch-content-outline.js Adds hook to dispatch outline fetch using store/editor context.
packages/js/src/ai-content-planner/hooks/use-draggable-structure.js Adds hook to manage reorderable outline structure in the modal.
packages/js/src/ai-content-planner/hooks/use-apply-outline.js Adds hook to apply the outline: build blocks, apply meta, remove banner, close modal.
packages/js/src/ai-content-planner/hooks/index.js Barrel export for hooks.
packages/js/src/ai-content-planner/helpers/get-progress-color.js Extracts meta description progress bar color logic.
packages/js/src/ai-content-planner/helpers/build-blocks-from-outline.js Updates block-building to use the new outline section schema.
packages/js/src/ai-content-planner/helpers/apply-post-meta-from-outline.js Simplifies applying post + Yoast meta using provided category id.
packages/js/src/ai-content-planner/containers/feature-modal.js Moves modal props derivation into withSelect and dispatch wiring into withDispatch.
packages/js/src/ai-content-planner/containers/content-planner-editor-item.js Adds dispatch for setting the modal flow status before opening.
packages/js/src/ai-content-planner/containers/content-outline-modal.js Adds container for the outline modal panel and navigation back to suggestions.
packages/js/src/ai-content-planner/constants.js Adds shared constants/types (error default, meta description lengths, suggestion typedef).
packages/js/src/ai-content-planner/components/intent-callout.js Extracts intent reasoning callout UI.
packages/js/src/ai-content-planner/components/intent-badge.js Refactors intent badge rendering using UI library Badge + icons.
packages/js/src/ai-content-planner/components/feature-modal.js Refactors orchestration logic to use hooks and store-driven flow status.
packages/js/src/ai-content-planner/components/content-suggestions-modal.js Updates intent badge usage and Suggestion typedef import.
packages/js/src/ai-content-planner/components/content-planner-editor-item.js Updates click behavior to set flow status and open modal.
packages/js/src/ai-content-planner/components/content-outline-modal.js Refactors outline modal to use real async state + draggable structure hook and shared helpers.
packages/js/src/ai-content-planner/blocks/content-suggestion-block.js Moves yoast-seo/content-suggestion block registration into its own module.
packages/js/src/ai-content-planner/blocks/banner-block.js Updates banner block to open modal and fetch suggestions using new flow.
Comments suppressed due to low confidence (1)

packages/js/src/ai-content-planner/components/feature-modal.js:136

  • handleOnApplyOutline uses setStatus (and setHasVisitedReplace) but they’re not listed in the dependency array. This can break the React Hooks exhaustive-deps linting and can capture stale props in edge cases. Include the missing dependencies (or refactor to avoid them).
	const handleOnApplyOutline = useCallback( ( editedOutline ) => {
		editedOutlineRef.current = editedOutline;
		if ( isEmptyPost ) {
			handleApplyOutline();
			return;
		}
		setHasVisitedReplace( true );
		setStatus( FEATURE_MODAL_STATUS.replaceContent );
	}, [ isEmptyPost, handleApplyOutline ] );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/js/src/ai-content-planner/components/intent-callout.js Outdated
Comment thread packages/js/src/ai-content-planner/containers/content-outline-modal.js Outdated
Comment thread packages/js/src/ai-content-planner/store/content-outline.js Outdated
Comment thread packages/js/src/ai-content-planner/store/content-outline.js Outdated
Comment thread packages/js/src/ai-content-planner/hooks/use-draggable-structure.js Outdated
Comment on lines 87 to 91
isUpsell,
upsellLink,
onAddOutline = noop,
initialStatus = null,
resetBlocks,
getContentOutline,
status,
setStatus,
} ) => {
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The status prop here represents the feature-flow status (FEATURE_MODAL_STATUS), which collides in naming with the status prop used by ContentSuggestionsModal / ContentOutlineModal for async loading (ASYNC_ACTION_STATUS). To avoid accidental prop overriding and blank panels, consider renaming this prop (e.g. flowStatus) and avoid passing it down to async-status components under the same name.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets keep it this way for now not to affect branches that are based on this branch.

Comment thread packages/js/src/ai-content-planner/store/content-suggestions.js
Comment thread packages/js/src/ai-content-planner/components/content-outline-modal.js Outdated
Base automatically changed from 1132-create-endpoint-for-sending-the-2nd-request-to-ai-api to feature/content-planner April 16, 2026 12:22
@vraja-pro vraja-pro added this to the feature/content-planner milestone Apr 16, 2026
Comment thread packages/js/src/ai-content-planner/hooks/use-fetch-content-outline.js Outdated
Comment thread packages/js/src/ai-content-planner/hooks/use-draggable-structure.js
Comment thread packages/js/src/ai-content-planner/components/content-outline-modal.js Outdated
Comment thread packages/js/tests/ai-content-planner/components/feature-modal.test.js Outdated
Copy link
Copy Markdown
Contributor

@JorPV JorPV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR 🚧 Some small findings ☝️ (see comments). I'd also consider adding unit tests for the new hooks (useApplyOutline, useDraggableStructure and useFetchContentOutline).

@JorPV
Copy link
Copy Markdown
Contributor

JorPV commented Apr 17, 2026

CR ✅ ACC ✅

@JorPV JorPV merged commit 9423150 into feature/content-planner Apr 17, 2026
40 checks passed
@JorPV JorPV deleted the 1142-connect-content-planner-frontend-with-backend-endpoints- branch April 17, 2026 09:50
@vraja-pro vraja-pro mentioned this pull request Apr 28, 2026
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants