Skip to content
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

CYS - Core: fix wp-admin page visible when click on start designing #45586

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -224,6 +224,9 @@ export const Intro: CustomizeStoreComponent = ( { sendEvent, context } ) => {
setOpenDesignChangeWarningModal={
setOpenDesignChangeWarningModal
}
redirectToCYSFlow={ () =>
sendEvent( 'DESIGN_WITHOUT_AI' )
}
sendEvent={ sendEvent }
/>

Expand Down
Expand Up @@ -219,7 +219,11 @@ export const ThemeHasModsBanner = ( {
);
};

export const NoAIBanner = () => {
export const NoAIBanner = ( {
redirectToCYSFlow,
}: {
redirectToCYSFlow: () => void;
} ) => {
const [ isModalOpen, setIsModalOpen ] = useState( false );
interface Theme {
stylesheet?: string;
Expand All @@ -230,10 +234,6 @@ export const NoAIBanner = () => {
}, [] );

const isDefaultTheme = currentTheme?.stylesheet === 'twentytwentyfour';
const customizeStoreDesignUrl = addQueryArgs( `${ ADMIN_URL }admin.php`, {
page: 'wc-admin',
path: '/customize-store/design',
} );

return (
<>
Expand All @@ -249,15 +249,15 @@ export const NoAIBanner = () => {
if ( ! isDefaultTheme ) {
setIsModalOpen( true );
} else {
window.location.href = customizeStoreDesignUrl;
redirectToCYSFlow();
}
} }
showAIDisclaimer={ false }
/>
{ isModalOpen && (
<ThemeSwitchWarningModal
setIsModalOpen={ setIsModalOpen }
customizeStoreDesignUrl={ customizeStoreDesignUrl }
redirectToCYSFlow={ redirectToCYSFlow }
/>
) }
</>
Expand Down
Expand Up @@ -197,10 +197,10 @@ export const StartOverWarningModal = ( {

export const ThemeSwitchWarningModal = ( {
setIsModalOpen,
customizeStoreDesignUrl,
redirectToCYSFlow,
}: {
setIsModalOpen: ( arg0: boolean ) => void;
customizeStoreDesignUrl: string;
redirectToCYSFlow: () => void;
} ) => {
return (
<Modal
Expand Down Expand Up @@ -231,11 +231,11 @@ export const ThemeSwitchWarningModal = ( {
</Button>
<Button
onClick={ () => {
window.location.href = customizeStoreDesignUrl;
setIsModalOpen( false );
recordEvent(
'customize_your_store_agree_to_theme_switch_click'
);
redirectToCYSFlow();
} }
variant="primary"
>
Expand Down
Expand Up @@ -21,6 +21,7 @@ import { Product, ProductType } from '../product-list/types';
import { appendURLParams } from '../../utils/functions';
import { ADMIN_URL, getAdminSetting } from '~/utils/admin-settings';
import { NoAIBanner } from '~/customize-store/intro/intro-banners';
import { addQueryArgs } from '@wordpress/url';

export default function ProductListContent( props: {
products: Product[];
Expand Down Expand Up @@ -119,7 +120,22 @@ export default function ProductListContent( props: {
} ),
} }
/>
{ index === bannerPosition && <NoAIBanner /> }
{ index === bannerPosition && (
<NoAIBanner
redirectToCYSFlow={ () => {
const customizeStoreDesignUrl =
addQueryArgs(
`${ ADMIN_URL }admin.php`,
{
page: 'wc-admin',
path: '/customize-store/design',
}
);
window.location.href =
customizeStoreDesignUrl;
} }
/>
) }
</Fragment>
) ) }
</div>
Expand Down
Expand Up @@ -161,7 +161,9 @@ export default function Products( props: ProductsProps ) {
{ isModalOpen && (
<ThemeSwitchWarningModal
setIsModalOpen={ setIsModalOpen }
customizeStoreDesignUrl={ customizeStoreDesignUrl }
redirectToCYSFlow={ () => {
window.location.href = customizeStoreDesignUrl;
} }
/>
) }
<ProductListContent
Expand Down
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

CYS - Core: fix wp-admin page visible when click on start designing