2024-03-18 07:44:32 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-04-02 07:16:53 +00:00
|
|
|
import {
|
|
|
|
ActorRefFrom,
|
|
|
|
sendTo,
|
|
|
|
setup,
|
|
|
|
fromCallback,
|
|
|
|
fromPromise,
|
|
|
|
assign,
|
2024-04-11 04:48:40 +00:00
|
|
|
spawnChild,
|
2024-06-19 10:23:29 +00:00
|
|
|
enqueueActions,
|
2024-04-02 07:16:53 +00:00
|
|
|
} from 'xstate5';
|
2024-03-18 07:44:32 +00:00
|
|
|
import React from 'react';
|
2024-05-31 03:49:36 +00:00
|
|
|
import clsx from 'clsx';
|
2024-04-05 01:54:30 +00:00
|
|
|
import { getQuery, navigateTo } from '@woocommerce/navigation';
|
2024-06-19 10:23:29 +00:00
|
|
|
import {
|
|
|
|
OPTIONS_STORE_NAME,
|
|
|
|
SETTINGS_STORE_NAME,
|
|
|
|
TaskListType,
|
|
|
|
TaskType,
|
|
|
|
} from '@woocommerce/data';
|
|
|
|
import { dispatch, resolveSelect } from '@wordpress/data';
|
2024-04-12 10:36:56 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2024-05-30 23:19:30 +00:00
|
|
|
import apiFetch from '@wordpress/api-fetch';
|
2024-03-18 07:44:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { LaunchYourStoreHubSidebar } from './components/launch-store-hub';
|
|
|
|
import type { LaunchYourStoreComponentProps } from '..';
|
|
|
|
import type { mainContentMachine } from '../main-content/xstate';
|
2024-03-26 02:29:16 +00:00
|
|
|
import { updateQueryParams, createQueryParamsListener } from '../common';
|
2024-04-05 01:54:30 +00:00
|
|
|
import { taskClickedAction, getLysTasklist } from './tasklist';
|
2024-04-11 04:48:40 +00:00
|
|
|
import { fetchCongratsData } from '../main-content/pages/launch-store-success/services';
|
2024-04-12 10:36:56 +00:00
|
|
|
import { getTimeFrame } from '~/utils';
|
|
|
|
|
|
|
|
export type LYSAugmentedTaskListType = TaskListType & {
|
|
|
|
recentlyActionedTasks: string[];
|
|
|
|
fullLysTaskList: TaskType[];
|
|
|
|
};
|
2024-03-18 07:44:32 +00:00
|
|
|
|
|
|
|
export type SidebarMachineContext = {
|
|
|
|
externalUrl: string | null;
|
|
|
|
mainContentMachineRef: ActorRefFrom< typeof mainContentMachine >;
|
2024-04-12 10:36:56 +00:00
|
|
|
tasklist?: LYSAugmentedTaskListType;
|
2024-04-02 07:16:53 +00:00
|
|
|
testOrderCount: number;
|
|
|
|
removeTestOrders?: boolean;
|
2024-04-12 10:36:56 +00:00
|
|
|
launchStoreAttemptTimestamp?: number;
|
2024-04-05 15:08:23 +00:00
|
|
|
launchStoreError?: {
|
|
|
|
message: string;
|
|
|
|
};
|
2024-06-19 10:23:29 +00:00
|
|
|
siteIsShowingCachedContent?: boolean;
|
2024-03-18 07:44:32 +00:00
|
|
|
};
|
|
|
|
export type SidebarComponentProps = LaunchYourStoreComponentProps & {
|
|
|
|
context: SidebarMachineContext;
|
|
|
|
};
|
|
|
|
export type SidebarMachineEvents =
|
2024-03-26 02:29:16 +00:00
|
|
|
| { type: 'EXTERNAL_URL_UPDATE' }
|
2024-03-18 07:44:32 +00:00
|
|
|
| { type: 'OPEN_EXTERNAL_URL'; url: string }
|
2024-04-02 07:16:53 +00:00
|
|
|
| { type: 'TASK_CLICKED'; task: TaskType }
|
2024-03-18 07:44:32 +00:00
|
|
|
| { type: 'OPEN_WC_ADMIN_URL'; url: string }
|
|
|
|
| { type: 'OPEN_WC_ADMIN_URL_IN_CONTENT_AREA'; url: string }
|
2024-04-02 07:16:53 +00:00
|
|
|
| { type: 'LAUNCH_STORE'; removeTestOrders: boolean }
|
|
|
|
| { type: 'LAUNCH_STORE_SUCCESS' }
|
|
|
|
| { type: 'POP_BROWSER_STACK' };
|
2024-03-26 02:29:16 +00:00
|
|
|
|
|
|
|
const sidebarQueryParamListener = fromCallback( ( { sendBack } ) => {
|
|
|
|
return createQueryParamsListener( 'sidebar', sendBack );
|
|
|
|
} );
|
|
|
|
|
2024-04-05 15:08:23 +00:00
|
|
|
const launchStoreAction = async () => {
|
|
|
|
const results = await dispatch( OPTIONS_STORE_NAME ).updateOptions( {
|
|
|
|
woocommerce_coming_soon: 'no',
|
|
|
|
} );
|
|
|
|
if ( results.success ) {
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
throw new Error( JSON.stringify( results ) );
|
|
|
|
};
|
|
|
|
|
2024-05-30 23:19:30 +00:00
|
|
|
const getTestOrderCount = async () => {
|
|
|
|
const result = ( await apiFetch( {
|
|
|
|
path: '/wc-admin/launch-your-store/woopayments/test-orders/count',
|
|
|
|
method: 'GET',
|
|
|
|
} ) ) as { count: number };
|
|
|
|
|
|
|
|
return result.count;
|
|
|
|
};
|
|
|
|
|
2024-06-19 10:23:29 +00:00
|
|
|
export const pageHasComingSoonMetaTag = async ( {
|
|
|
|
url,
|
|
|
|
}: {
|
|
|
|
url: string;
|
|
|
|
} ): Promise< boolean > => {
|
|
|
|
try {
|
|
|
|
const response = await fetch( url, {
|
|
|
|
method: 'GET',
|
|
|
|
credentials: 'omit',
|
|
|
|
cache: 'no-store',
|
|
|
|
} );
|
|
|
|
if ( ! response.ok ) {
|
|
|
|
throw new Error( `Failed to fetch ${ url }` );
|
|
|
|
}
|
|
|
|
const html = await response.text();
|
|
|
|
const parser = new DOMParser();
|
|
|
|
const doc = parser.parseFromString( html, 'text/html' );
|
|
|
|
const metaTag = doc.querySelector(
|
|
|
|
'meta[name="woo-coming-soon-page"]'
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( metaTag ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} catch ( error ) {
|
|
|
|
throw new Error( `Error fetching ${ url }: ${ error }` );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-06-25 05:50:30 +00:00
|
|
|
export const getSiteCachedStatus = async () => {
|
2024-06-19 10:23:29 +00:00
|
|
|
const settings = await resolveSelect( SETTINGS_STORE_NAME ).getSettings(
|
|
|
|
'wc_admin'
|
|
|
|
);
|
|
|
|
|
|
|
|
// if store URL exists, check both storeUrl and siteUrl otherwise only check siteUrl
|
|
|
|
// we want to check both because there's a chance that caching is especially disabled for woocommerce pages, e.g WPEngine
|
|
|
|
const requests = [] as Promise< boolean >[];
|
|
|
|
if ( settings?.shopUrl ) {
|
|
|
|
requests.push(
|
|
|
|
pageHasComingSoonMetaTag( {
|
|
|
|
url: settings.shopUrl,
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( settings?.siteUrl ) {
|
|
|
|
requests.push(
|
|
|
|
pageHasComingSoonMetaTag( {
|
|
|
|
url: settings.siteUrl,
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const results = await Promise.all( requests );
|
|
|
|
return results.some( ( result ) => result );
|
|
|
|
};
|
|
|
|
|
2024-05-30 23:19:30 +00:00
|
|
|
const deleteTestOrders = async ( {
|
|
|
|
input,
|
|
|
|
}: {
|
|
|
|
input: {
|
|
|
|
removeTestOrders: boolean;
|
|
|
|
};
|
|
|
|
} ) => {
|
|
|
|
if ( ! input.removeTestOrders ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return await apiFetch( {
|
|
|
|
path: '/wc-admin/launch-your-store/woopayments/test-orders',
|
|
|
|
method: 'DELETE',
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2024-04-12 10:36:56 +00:00
|
|
|
const recordStoreLaunchAttempt = ( {
|
|
|
|
context,
|
|
|
|
}: {
|
|
|
|
context: SidebarMachineContext;
|
|
|
|
} ) => {
|
|
|
|
const total_count = context.tasklist?.fullLysTaskList.length || 0;
|
|
|
|
const incomplete_tasks =
|
|
|
|
context.tasklist?.tasks
|
|
|
|
.filter( ( task ) => ! task.isComplete )
|
|
|
|
.map( ( task ) => task.id ) || [];
|
|
|
|
|
|
|
|
const completed =
|
|
|
|
context.tasklist?.fullLysTaskList
|
|
|
|
.filter( ( task ) => task.isComplete )
|
|
|
|
.map( ( task ) => task.id ) || [];
|
|
|
|
|
|
|
|
const tasks_completed_in_lys = completed.filter( ( task ) =>
|
|
|
|
context.tasklist?.recentlyActionedTasks.includes( task )
|
|
|
|
); // recently actioned tasks can include incomplete tasks
|
|
|
|
|
|
|
|
recordEvent( 'launch_your_store_hub_store_launch_attempted', {
|
|
|
|
tasks_total_count: total_count, // all lys eligible tasks
|
|
|
|
tasks_completed: completed, // all lys eligible tasks that are completed
|
|
|
|
tasks_completed_count: completed.length,
|
|
|
|
tasks_completed_in_lys,
|
|
|
|
tasks_completed_in_lys_count: tasks_completed_in_lys.length,
|
|
|
|
incomplete_tasks,
|
|
|
|
incomplete_tasks_count: incomplete_tasks.length,
|
|
|
|
delete_test_orders: context.removeTestOrders || false,
|
|
|
|
} );
|
|
|
|
return performance.now();
|
|
|
|
};
|
|
|
|
|
|
|
|
const recordStoreLaunchResults = ( timestamp: number, success: boolean ) => {
|
|
|
|
recordEvent( 'launch_your_store_hub_store_launch_results', {
|
|
|
|
success,
|
|
|
|
duration: getTimeFrame( performance.now() - timestamp ),
|
|
|
|
} );
|
|
|
|
};
|
2024-03-18 07:44:32 +00:00
|
|
|
export const sidebarMachine = setup( {
|
|
|
|
types: {} as {
|
|
|
|
context: SidebarMachineContext;
|
|
|
|
events: SidebarMachineEvents;
|
|
|
|
input: {
|
|
|
|
mainContentMachineRef: ActorRefFrom< typeof mainContentMachine >;
|
|
|
|
};
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
openExternalUrl: ( { event } ) => {
|
|
|
|
if ( event.type === 'OPEN_EXTERNAL_URL' ) {
|
2024-04-02 07:16:53 +00:00
|
|
|
navigateTo( { url: event.url } );
|
2024-03-18 07:44:32 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
showLaunchStoreSuccessPage: sendTo(
|
|
|
|
( { context } ) => context.mainContentMachineRef,
|
|
|
|
{ type: 'SHOW_LAUNCH_STORE_SUCCESS' }
|
|
|
|
),
|
2024-06-19 10:23:29 +00:00
|
|
|
showLaunchStorePendingCache: sendTo(
|
|
|
|
( { context } ) => context.mainContentMachineRef,
|
|
|
|
{ type: 'SHOW_LAUNCH_STORE_PENDING_CACHE' }
|
|
|
|
),
|
2024-03-18 07:44:32 +00:00
|
|
|
showLoadingPage: sendTo(
|
|
|
|
( { context } ) => context.mainContentMachineRef,
|
|
|
|
{ type: 'SHOW_LOADING' }
|
|
|
|
),
|
2024-03-26 02:29:16 +00:00
|
|
|
updateQueryParams: (
|
|
|
|
_,
|
|
|
|
params: { sidebar?: string; content?: string }
|
|
|
|
) => {
|
|
|
|
updateQueryParams( params );
|
|
|
|
},
|
2024-04-02 07:16:53 +00:00
|
|
|
taskClicked: ( { event } ) => {
|
|
|
|
if ( event.type === 'TASK_CLICKED' ) {
|
2024-04-05 01:54:30 +00:00
|
|
|
taskClickedAction( event );
|
2024-04-02 07:16:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
openWcAdminUrl: ( { event } ) => {
|
|
|
|
if ( event.type === 'OPEN_WC_ADMIN_URL' ) {
|
|
|
|
navigateTo( { url: event.url } );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
windowHistoryBack: () => {
|
|
|
|
window.history.back();
|
|
|
|
},
|
2024-04-12 10:36:56 +00:00
|
|
|
recordStoreLaunchAttempt: assign( {
|
|
|
|
launchStoreAttemptTimestamp: recordStoreLaunchAttempt,
|
|
|
|
} ),
|
|
|
|
recordStoreLaunchResults: (
|
|
|
|
{ context },
|
|
|
|
{ success }: { success: boolean }
|
|
|
|
) => {
|
|
|
|
recordStoreLaunchResults(
|
|
|
|
context.launchStoreAttemptTimestamp || 0,
|
|
|
|
success
|
|
|
|
);
|
|
|
|
},
|
2024-06-19 10:23:29 +00:00
|
|
|
recordStoreLaunchCachedContentDetected: () => {
|
|
|
|
recordEvent(
|
|
|
|
'launch_your_store_hub_store_launch_cached_content_detected'
|
|
|
|
);
|
|
|
|
},
|
2024-03-26 02:29:16 +00:00
|
|
|
},
|
|
|
|
guards: {
|
|
|
|
hasSidebarLocation: (
|
|
|
|
_,
|
|
|
|
{ sidebarLocation }: { sidebarLocation: string }
|
|
|
|
) => {
|
|
|
|
const { sidebar } = getQuery() as { sidebar?: string };
|
|
|
|
return !! sidebar && sidebar === sidebarLocation;
|
|
|
|
},
|
2024-05-30 23:19:30 +00:00
|
|
|
hasWooPayments: () => {
|
|
|
|
return window?.wcSettings?.admin?.plugins?.activePlugins.includes(
|
|
|
|
'woocommerce-payments'
|
|
|
|
);
|
|
|
|
},
|
2024-06-19 10:23:29 +00:00
|
|
|
siteIsShowingCachedContent: ( { context } ) => {
|
|
|
|
return !! context.siteIsShowingCachedContent;
|
|
|
|
},
|
2024-03-26 02:29:16 +00:00
|
|
|
},
|
|
|
|
actors: {
|
|
|
|
sidebarQueryParamListener,
|
2024-04-02 07:16:53 +00:00
|
|
|
getTasklist: fromPromise( getLysTasklist ),
|
2024-05-30 23:19:30 +00:00
|
|
|
getTestOrderCount: fromPromise( getTestOrderCount ),
|
2024-06-19 10:23:29 +00:00
|
|
|
getSiteCachedStatus: fromPromise( getSiteCachedStatus ),
|
2024-04-05 15:08:23 +00:00
|
|
|
updateLaunchStoreOptions: fromPromise( launchStoreAction ),
|
2024-05-30 23:19:30 +00:00
|
|
|
deleteTestOrders: fromPromise( deleteTestOrders ),
|
2024-04-11 04:48:40 +00:00
|
|
|
fetchCongratsData,
|
2024-03-18 07:44:32 +00:00
|
|
|
},
|
|
|
|
} ).createMachine( {
|
|
|
|
id: 'sidebar',
|
2024-03-26 02:29:16 +00:00
|
|
|
initial: 'navigate',
|
2024-03-18 07:44:32 +00:00
|
|
|
context: ( { input } ) => ( {
|
|
|
|
externalUrl: null,
|
2024-04-02 07:16:53 +00:00
|
|
|
testOrderCount: 0,
|
2024-03-18 07:44:32 +00:00
|
|
|
mainContentMachineRef: input.mainContentMachineRef,
|
|
|
|
} ),
|
2024-03-26 02:29:16 +00:00
|
|
|
invoke: {
|
|
|
|
id: 'sidebarQueryParamListener',
|
|
|
|
src: 'sidebarQueryParamListener',
|
|
|
|
},
|
2024-03-18 07:44:32 +00:00
|
|
|
states: {
|
2024-03-26 02:29:16 +00:00
|
|
|
navigate: {
|
|
|
|
always: [
|
|
|
|
{
|
|
|
|
guard: {
|
|
|
|
type: 'hasSidebarLocation',
|
|
|
|
params: { sidebarLocation: 'hub' },
|
|
|
|
},
|
|
|
|
target: 'launchYourStoreHub',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
guard: {
|
|
|
|
type: 'hasSidebarLocation',
|
|
|
|
params: { sidebarLocation: 'launch-success' },
|
|
|
|
},
|
|
|
|
target: 'storeLaunchSuccessful',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: 'launchYourStoreHub',
|
|
|
|
},
|
|
|
|
],
|
2024-03-18 07:44:32 +00:00
|
|
|
},
|
|
|
|
launchYourStoreHub: {
|
|
|
|
initial: 'preLaunchYourStoreHub',
|
|
|
|
states: {
|
|
|
|
preLaunchYourStoreHub: {
|
2024-04-11 04:48:40 +00:00
|
|
|
entry: [
|
|
|
|
spawnChild( 'fetchCongratsData', {
|
|
|
|
id: 'prefetch-congrats-data ',
|
|
|
|
} ),
|
|
|
|
],
|
2024-04-02 07:16:53 +00:00
|
|
|
invoke: {
|
|
|
|
src: 'getTasklist',
|
|
|
|
onDone: {
|
|
|
|
actions: assign( {
|
|
|
|
tasklist: ( { event } ) => event.output,
|
|
|
|
} ),
|
2024-05-30 23:19:30 +00:00
|
|
|
target: 'maybeCountTestOrders',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
maybeCountTestOrders: {
|
|
|
|
always: [
|
|
|
|
{
|
|
|
|
guard: 'hasWooPayments',
|
|
|
|
target: 'countTestOrders',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: 'launchYourStoreHub',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
countTestOrders: {
|
|
|
|
invoke: {
|
|
|
|
src: 'getTestOrderCount',
|
|
|
|
onDone: {
|
|
|
|
actions: assign( {
|
|
|
|
testOrderCount: ( { event } ) => event.output,
|
|
|
|
} ),
|
|
|
|
target: 'launchYourStoreHub',
|
|
|
|
},
|
|
|
|
onError: {
|
2024-04-02 07:16:53 +00:00
|
|
|
target: 'launchYourStoreHub',
|
|
|
|
},
|
|
|
|
},
|
2024-03-18 07:44:32 +00:00
|
|
|
},
|
|
|
|
launchYourStoreHub: {
|
2024-04-05 15:08:23 +00:00
|
|
|
id: 'launchYourStoreHub',
|
2024-03-18 07:44:32 +00:00
|
|
|
tags: 'sidebar-visible',
|
|
|
|
meta: {
|
|
|
|
component: LaunchYourStoreHubSidebar,
|
|
|
|
},
|
|
|
|
on: {
|
|
|
|
LAUNCH_STORE: {
|
|
|
|
target: '#storeLaunching',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
storeLaunching: {
|
|
|
|
id: 'storeLaunching',
|
|
|
|
initial: 'launching',
|
|
|
|
states: {
|
|
|
|
launching: {
|
2024-04-12 10:36:56 +00:00
|
|
|
entry: [
|
|
|
|
assign( { launchStoreError: undefined } ), // clear the errors if any from previously
|
|
|
|
'recordStoreLaunchAttempt',
|
|
|
|
],
|
2024-05-30 23:19:30 +00:00
|
|
|
invoke: [
|
|
|
|
{
|
|
|
|
src: 'updateLaunchStoreOptions',
|
|
|
|
onDone: {
|
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
type: 'recordStoreLaunchResults',
|
|
|
|
params: { success: true },
|
2024-04-12 10:36:56 +00:00
|
|
|
},
|
2024-05-30 23:19:30 +00:00
|
|
|
],
|
2024-06-19 10:23:29 +00:00
|
|
|
target: 'checkingForCachedContent',
|
2024-05-30 23:19:30 +00:00
|
|
|
},
|
|
|
|
onError: {
|
|
|
|
actions: [
|
|
|
|
assign( {
|
|
|
|
launchStoreError: ( { event } ) => {
|
|
|
|
return {
|
|
|
|
message: JSON.stringify(
|
|
|
|
event.error
|
|
|
|
), // for some reason event.error is an empty object, worth investigating if we decide to use the error message somewhere
|
|
|
|
};
|
|
|
|
},
|
|
|
|
} ),
|
|
|
|
{
|
|
|
|
type: 'recordStoreLaunchResults',
|
|
|
|
params: {
|
|
|
|
success: false,
|
|
|
|
},
|
2024-04-12 10:36:56 +00:00
|
|
|
},
|
2024-05-30 23:19:30 +00:00
|
|
|
],
|
|
|
|
target: '#launchYourStoreHub',
|
|
|
|
},
|
2024-04-05 15:08:23 +00:00
|
|
|
},
|
2024-05-30 23:19:30 +00:00
|
|
|
{
|
|
|
|
src: 'deleteTestOrders',
|
|
|
|
input: ( { event } ) => {
|
|
|
|
return {
|
|
|
|
removeTestOrders: (
|
|
|
|
event as {
|
|
|
|
removeTestOrders: boolean;
|
|
|
|
}
|
|
|
|
).removeTestOrders,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2024-03-18 07:44:32 +00:00
|
|
|
},
|
2024-06-19 10:23:29 +00:00
|
|
|
checkingForCachedContent: {
|
|
|
|
invoke: [
|
|
|
|
{
|
|
|
|
src: 'getSiteCachedStatus',
|
|
|
|
onDone: {
|
|
|
|
target: '#storeLaunchSuccessful',
|
|
|
|
actions: assign( {
|
|
|
|
siteIsShowingCachedContent: ( { event } ) =>
|
|
|
|
event.output,
|
|
|
|
} ),
|
|
|
|
},
|
|
|
|
onError: {
|
|
|
|
target: '#storeLaunchSuccessful',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2024-03-18 07:44:32 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
storeLaunchSuccessful: {
|
|
|
|
id: 'storeLaunchSuccessful',
|
|
|
|
tags: 'fullscreen',
|
2024-03-26 02:29:16 +00:00
|
|
|
entry: [
|
|
|
|
{
|
|
|
|
type: 'updateQueryParams',
|
|
|
|
params: {
|
|
|
|
sidebar: 'launch-success',
|
|
|
|
content: 'launch-store-success',
|
|
|
|
},
|
|
|
|
},
|
2024-06-19 10:23:29 +00:00
|
|
|
enqueueActions( ( { check, enqueue } ) => {
|
|
|
|
if ( check( 'siteIsShowingCachedContent' ) ) {
|
|
|
|
enqueue( {
|
|
|
|
type: 'showLaunchStorePendingCache',
|
|
|
|
} );
|
|
|
|
enqueue( {
|
|
|
|
type: 'recordStoreLaunchCachedContentDetected',
|
|
|
|
} );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
enqueue( { type: 'showLaunchStoreSuccessPage' } );
|
|
|
|
} ),
|
2024-03-26 02:29:16 +00:00
|
|
|
],
|
2024-03-18 07:44:32 +00:00
|
|
|
},
|
|
|
|
openExternalUrl: {
|
|
|
|
id: 'openExternalUrl',
|
|
|
|
tags: 'sidebar-visible', // unintuitive but it prevents a layout shift just before leaving
|
|
|
|
entry: [ 'openExternalUrl' ],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
on: {
|
2024-03-26 02:29:16 +00:00
|
|
|
EXTERNAL_URL_UPDATE: {
|
|
|
|
target: '.navigate',
|
|
|
|
},
|
2024-03-18 07:44:32 +00:00
|
|
|
OPEN_EXTERNAL_URL: {
|
|
|
|
target: '#openExternalUrl',
|
|
|
|
},
|
2024-04-02 07:16:53 +00:00
|
|
|
TASK_CLICKED: {
|
|
|
|
actions: 'taskClicked',
|
|
|
|
},
|
|
|
|
OPEN_WC_ADMIN_URL: {
|
|
|
|
actions: 'openWcAdminUrl',
|
|
|
|
},
|
|
|
|
POP_BROWSER_STACK: {
|
|
|
|
actions: 'windowHistoryBack',
|
|
|
|
},
|
2024-03-18 07:44:32 +00:00
|
|
|
OPEN_WC_ADMIN_URL_IN_CONTENT_AREA: {},
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
export const SidebarContainer = ( {
|
|
|
|
children,
|
|
|
|
className,
|
|
|
|
}: {
|
|
|
|
children: React.ReactNode;
|
|
|
|
className?: string;
|
|
|
|
} ) => {
|
|
|
|
return (
|
|
|
|
<div
|
2024-05-31 03:49:36 +00:00
|
|
|
className={ clsx( 'launch-your-store-layout__sidebar', className ) }
|
2024-03-18 07:44:32 +00:00
|
|
|
>
|
|
|
|
{ children }
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|