Fix marketing task completion logic (#33676)

* Add marketing action task on clicking Manage

* Revert marketing completion after installing any marketing plugin

* Changelog
This commit is contained in:
Ilyas Foo 2022-07-02 05:28:45 +08:00 committed by GitHub
parent d15770132b
commit dea22904e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 5 deletions

View File

@ -21,6 +21,7 @@ export type PluginProps = {
isInstalled: boolean;
description?: string;
installAndActivate?: ( slug: string ) => void;
onManage?: ( slug: string ) => void;
imageUrl?: string;
manageUrl?: string;
name: string;
@ -31,6 +32,7 @@ export const Plugin: React.FC< PluginProps > = ( {
description,
imageUrl,
installAndActivate = () => {},
onManage = () => {},
isActive,
isBusy,
isBuiltByWC,
@ -72,11 +74,12 @@ export const Plugin: React.FC< PluginProps > = ( {
isBusy={ isBusy }
isSecondary
href={ getAdminLink( manageUrl ) }
onClick={ () =>
onClick={ () => {
recordEvent( 'marketing_manage', {
extension_name: slug,
} )
}
} );
onManage( slug );
} }
>
{ __( 'Manage', 'woocommmerce-admin' ) }
</Button>

View File

@ -13,6 +13,7 @@ export type PluginListProps = {
currentPlugin?: string | null;
key?: string;
installAndActivate?: ( slug: string ) => void;
onManage?: ( slug: string ) => void;
plugins?: PluginProps[];
title?: string;
};
@ -20,6 +21,7 @@ export type PluginListProps = {
export const PluginList: React.FC< PluginListProps > = ( {
currentPlugin,
installAndActivate = () => {},
onManage = () => {},
plugins = [],
title,
} ) => {
@ -51,6 +53,7 @@ export const PluginList: React.FC< PluginListProps > = ( {
name={ name }
imageUrl={ imageUrl }
installAndActivate={ installAndActivate }
onManage={ onManage }
isActive={ isActive }
isBuiltByWC={ isBuiltByWC }
isBusy={ currentPlugin === slug }

View File

@ -145,6 +145,10 @@ const Marketing: React.FC< MarketingProps > = ( { onComplete } ) => {
} );
};
const onManage = () => {
actionTask( 'marketing' );
};
if ( isResolving ) {
return <Spinner />;
}
@ -168,6 +172,7 @@ const Marketing: React.FC< MarketingProps > = ( { onComplete } ) => {
<PluginList
currentPlugin={ currentPlugin }
installAndActivate={ installAndActivate }
onManage={ onManage }
plugins={ installedExtensions }
/>
</Card>
@ -198,6 +203,7 @@ const Marketing: React.FC< MarketingProps > = ( { onComplete } ) => {
<PluginList
currentPlugin={ currentPlugin }
installAndActivate={ installAndActivate }
onManage={ onManage }
key={ key }
plugins={ plugins }
title={ title }

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Revert marketing task completion logic to only complete after actioned by user

View File

@ -125,8 +125,8 @@ class Marketing extends Task {
}
}
// Make sure the task has been actioned or a marketing extension has been installed.
if ( count( $installed ) > 0 || Task::is_task_actioned( 'marketing' ) ) {
// Make sure the task has been actioned and a marketing extension has been installed.
if ( count( $installed ) > 0 && Task::is_task_actioned( 'marketing' ) ) {
return true;
}