Skip to content

Commit

Permalink
Site Assembler - Write Flow (dotcom patterns only) (#72748)
Browse files Browse the repository at this point in the history
* Added query pattern ids in the posts category

* Show the assembler CTA in build and write flows

* Show the assembler CTA in build and write flows

* Use posts from dotcomverticalposts

* Add support to disable the headstart setting that trims the content and limits the posts

* Disable trim_content to create posts in the user site without limit

* Code improvements

* Pass is_assembler_flow to /theme-setup to copy posts from blank-canvas-3 demo site

* Add is_assembler_flow to /theme-setup tests

* Pass posts_source_site_id in /theme-setup to copy starter content from blank-canvas-3 demo site

* rebase

* Code improvement

* Add feature flag pattern-assembler/write-flow

* Enable feature flag pattern-assembler/write-flow on horizon and development envs
  • Loading branch information
miksansegundo authored Feb 3, 2023
1 parent a811290 commit b5e0752
Show file tree
Hide file tree
Showing 13 changed files with 313 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ import type { StarterDesigns } from '@automattic/data-stores';
import type { Design, StyleVariation } from '@automattic/design-picker';

const SiteIntent = Onboard.SiteIntent;
const SITE_ASSEMBLER_AVAILABLE_INTENTS: string[] = [ SiteIntent.Build ];

if ( isEnabled( 'pattern-assembler/write-flow' ) ) {
SITE_ASSEMBLER_AVAILABLE_INTENTS.push( SiteIntent.Write );
}

const UnifiedDesignPickerStep: Step = ( { navigation, flow } ) => {
const { goBack, submit, exitFlow } = navigation;
Expand Down Expand Up @@ -100,9 +105,12 @@ const UnifiedDesignPickerStep: Step = ( { navigation, flow } ) => {

const blankCanvasDesignOffset = allDesigns.static.designs.findIndex( isBlankCanvasDesign );
if ( blankCanvasDesignOffset !== -1 ) {
// Extract the blank canvas design first and then insert it into the last one for the build intent
// Extract the blank canvas design first and then insert it into the last one for the build and write intents
const blankCanvasDesign = allDesigns.static.designs.splice( blankCanvasDesignOffset, 1 );
if ( isEnabled( 'signup/design-picker-pattern-assembler' ) && intent === SiteIntent.Build ) {
if (
isEnabled( 'signup/design-picker-pattern-assembler' ) &&
SITE_ASSEMBLER_AVAILABLE_INTENTS.includes( intent )
) {
allDesigns.static.designs.push( ...blankCanvasDesign );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export const PATTERN_SOURCE_SITE_ID = 174455321; // dotcompatterns
export const PUBLIC_API_URL = 'https://public-api.wordpress.com';
export const PREVIEW_PATTERN_URL = PUBLIC_API_URL + '/wpcom/v2/block-previews/pattern';
export const SITE_TAGLINE = 'Site Tagline';
export const PLACEHOLDER_SITE_ID = 211865921; // blankcanvas3demo.wordpress.com
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useSiteIdParam } from '../../../../hooks/use-site-id-param';
import { useSiteSlugParam } from '../../../../hooks/use-site-slug-param';
import { SITE_STORE, ONBOARD_STORE } from '../../../../stores';
import { recordSelectedDesign } from '../../analytics/record-design';
import { SITE_TAGLINE } from './constants';
import { SITE_TAGLINE, PLACEHOLDER_SITE_ID } from './constants';
import PatternLayout from './pattern-layout';
import PatternSelectorLoader from './pattern-selector-loader';
import { useAllPatterns } from './patterns-data';
Expand Down Expand Up @@ -257,7 +257,12 @@ const PatternAssembler: Step = ( { navigation, flow } ) => {
createCustomHomeTemplateContent( stylesheet, !! header, !! footer, !! sections.length )
)
)
.then( () => runThemeSetupOnSite( siteSlugOrId, design ) )
.then( () =>
runThemeSetupOnSite( siteSlugOrId, design, {
trimContent: false,
posts_source_site_id: PLACEHOLDER_SITE_ID,
} )
)
.then( () => reduxDispatch( requestActiveTheme( site?.ID || -1 ) ) )
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BlockRendererProvider, PatternsRendererProvider } from '@automattic/block-renderer';
import { PLACEHOLDER_SITE_ID } from './constants';
import type { SiteInfo } from '@automattic/block-renderer';

interface Props {
Expand All @@ -18,11 +19,12 @@ const PatternAssemblerContainer = ( {
}: Props ) => (
<BlockRendererProvider siteId={ siteId } stylesheet={ stylesheet }>
<PatternsRendererProvider
// Use theme demo site to render the site-related blocks for now.
// For example, site logo, site title, site tagline, posts.
siteId={ siteId }
// Site used to render site-related things on the previews,
// such as the logo, title, and tagline.
siteId={ PLACEHOLDER_SITE_ID }
stylesheet={ stylesheet }
patternIds={ patternIds }
// Use siteInfo to overwrite site-related things such as title, and tagline.
siteInfo={ siteInfo }
>
{ children }
Expand Down
Loading

0 comments on commit b5e0752

Please sign in to comment.