Skip to content

Commit

Permalink
Merge branch 'trunk' into f26d/clean-up-hosting-overview-refinements-…
Browse files Browse the repository at this point in the history
…flag
  • Loading branch information
fredrikekelund committed Sep 6, 2024
2 parents 8478614 + b575995 commit b73495e
Show file tree
Hide file tree
Showing 415 changed files with 7,327 additions and 4,374 deletions.
87 changes: 0 additions & 87 deletions .yarn/patches/@wordpress-dataviews-npm-0.4.1-2c01fa0792.patch

This file was deleted.

2 changes: 1 addition & 1 deletion apps/happy-blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@automattic/calypso-build": "workspace:^",
"@automattic/calypso-config": "workspace:^",
"@automattic/calypso-products": "workspace:^",
"@automattic/color-studio": "2.6.0",
"@automattic/color-studio": "^3.0.1",
"@automattic/components": "workspace:^",
"@automattic/format-currency": "workspace:^",
"@automattic/typography": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1075,16 +1075,16 @@ function handleAppBannerShowing( calypsoPort ) {
};
}

function handlePatterns( calypsoPort ) {
const selector = `[data-value="${ __( 'Patterns' ) }"]`;
function handleWpAdminRedirect( { calypsoPort, path, title } ) {
const selector = `[data-value="${ title }"]`;

const callback = ( e ) => {
e.preventDefault();

calypsoPort.postMessage( {
action: 'goToPatterns',
action: 'wpAdminRedirect',
payload: {
destinationUrl: '/wp-admin/site-editor.php?postType=wp_block',
destinationUrl: `/wp-admin/${ path }`,
unsavedChanges: select( 'core/editor' ).isEditedPostDirty(),
},
} );
Expand All @@ -1094,6 +1094,26 @@ function handlePatterns( calypsoPort ) {
addCommandsInputListener( selector, callback );
}

function handlePatterns( calypsoPort ) {
handleWpAdminRedirect( {
calypsoPort,
path: 'site-editor.php?postType=wp_block',
title: __( 'Patterns' ),
} );
}

function handleAddPage( calypsoPort ) {
handleWpAdminRedirect( {
calypsoPort,
path: 'post-new.php?post_type=page',
title: __( 'Add new page' ),
} );
}

function handleAddPost( calypsoPort ) {
handleWpAdminRedirect( { calypsoPort, path: 'post-new.php', title: __( 'Add new post' ) } );
}

function initPort( message ) {
if ( 'initPort' !== message.data.action ) {
return;
Expand Down Expand Up @@ -1196,6 +1216,10 @@ function initPort( message ) {
handleAppBannerShowing( calypsoPort );

handlePatterns( calypsoPort );

handleAddPage( calypsoPort );

handleAddPost( calypsoPort );
}

window.removeEventListener( 'message', initPort, false );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dispatch, select, subscribe } from '@wordpress/data';
import { dispatch, select, subscribe, useSelect } from '@wordpress/data';
import { getQueryArg } from '@wordpress/url';
import { useEffect } from 'react';
import useLaunchpadScreen from './use-launchpad-screen';
Expand All @@ -11,34 +11,31 @@ export function RedirectOnboardingUserAfterPublishingPost() {
const { siteIntent: intent } = useSiteIntent();
const { launchpad_screen: launchpadScreen } = useLaunchpadScreen();

useEffect( () => {
// We check the URL param along with site intent because the param loads faster and prevents element flashing.
const hasStartWritingFlowQueryArg =
getQueryArg( window.location.search, START_WRITING_FLOW ) === 'true';
const currentPostType = useSelect(
( localSelect ) => localSelect( 'core/editor' ).getCurrentPostType(),
[]
);

if (
intent === START_WRITING_FLOW ||
intent === DESIGN_FIRST_FLOW ||
hasStartWritingFlowQueryArg
) {
dispatch( 'core/edit-post' ).closeGeneralSidebar();
document.documentElement.classList.add( 'blog-onboarding-hide' );
}
}, [ intent ] );

// Check the URL parameter first so we can skip later processing ASAP.
// Check the URL parameter first so we can skip later processing ASAP and avoid flashing.
const hasStartWritingFlowQueryArg =
getQueryArg( window.location.search, START_WRITING_FLOW ) === 'true';

if ( ! hasStartWritingFlowQueryArg ) {
return false;
}
const shouldShowMinimalUIAndRedirectToFullscreenLaunchpad =
( intent === START_WRITING_FLOW || intent === DESIGN_FIRST_FLOW ) &&
hasStartWritingFlowQueryArg &&
'full' === launchpadScreen &&
currentPostType === 'post';

if ( intent !== START_WRITING_FLOW && intent !== DESIGN_FIRST_FLOW ) {
return false;
}
useEffect( () => {
if ( shouldShowMinimalUIAndRedirectToFullscreenLaunchpad ) {
dispatch( 'core/edit-post' ).closeGeneralSidebar();
document.documentElement.classList.add( 'blog-onboarding-hide' );
} else {
document.documentElement.classList.remove( 'blog-onboarding-hide' );
}
}, [ shouldShowMinimalUIAndRedirectToFullscreenLaunchpad ] );

if ( 'full' !== launchpadScreen ) {
if ( ! shouldShowMinimalUIAndRedirectToFullscreenLaunchpad ) {
return false;
}

Expand All @@ -56,13 +53,6 @@ export function RedirectOnboardingUserAfterPublishingPost() {
const isCurrentPostPublished = select( 'core/editor' ).isCurrentPostPublished();
const isCurrentPostScheduled = select( 'core/editor' ).isCurrentPostScheduled();
const getCurrentPostRevisionsCount = select( 'core/editor' ).getCurrentPostRevisionsCount();
const currentPostType = select( 'core/editor' ).getCurrentPostType();

// If we're editing anything that is not a post, including pages, templates, and navigation, nothing further needed.
if ( currentPostType && currentPostType !== 'post' ) {
unsubscribe();
return;
}

if (
! isSavingPost &&
Expand Down
Loading

0 comments on commit b73495e

Please sign in to comment.