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

Add task using TaskLists::add_task API #2026

Merged
merged 12 commits into from
Aug 1, 2023
Merged
45 changes: 0 additions & 45 deletions js/src/tasks/complete-setup/index.js

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"check-licenses": "wp-scripts check-licenses",
"dev": "NODE_ENV=development wp-scripts build",
"dewps:woo": "node bin/list-woo-dewped.mjs",
"doc:hooks": "php bin/HooksDocsGenerator.php",
"doc:tracking": "woocommerce-grow-jsdoc ./js/src",
"docker:up": "WP_VERSION=6.1 npx wc-e2e docker:up",
"docker:down": "npx wc-e2e docker:down",
Expand Down
134 changes: 63 additions & 71 deletions src/Hooks/README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Internal/DependencyManagement/CoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ZoneMethodsParser;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ShippingZone;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ZoneLocationsParser;
use Automattic\WooCommerce\GoogleListingsAndAds\TaskList\CompleteSetup;
use Automattic\WooCommerce\GoogleListingsAndAds\TaskList\CompleteSetupTask;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Events\ActivatedEvents;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Events\SiteClaimEvents;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Events\SiteVerificationEvents;
Expand Down Expand Up @@ -146,7 +146,7 @@ class CoreServiceProvider extends AbstractServiceProvider {
AssetsHandlerInterface::class => true,
BulkEditInitializer::class => true,
ContactInformationNote::class => true,
CompleteSetup::class => true,
CompleteSetupTask::class => true,
CompleteSetupNote::class => true,
CouponBulkEdit::class => true,
CouponHelper::class => true,
Expand Down Expand Up @@ -299,7 +299,7 @@ function ( ...$arguments ) {
$this->conditionally_share_with_tags( EventTracking::class, ContainerInterface::class );
$this->conditionally_share_with_tags( RESTControllers::class, ContainerInterface::class );
$this->conditionally_share_with_tags( ConnectionTest::class, ContainerInterface::class );
$this->conditionally_share_with_tags( CompleteSetup::class, AssetsHandlerInterface::class );
$this->share_with_tags( CompleteSetupTask::class );
$this->conditionally_share_with_tags( GlobalSiteTag::class, AssetsHandlerInterface::class, GoogleGtagJs::class, ProductHelper::class, WC::class, WP::class );
$this->share_with_tags( SiteVerificationMeta::class );
$this->conditionally_share_with_tags( MerchantSetupCompleted::class );
Expand Down
104 changes: 0 additions & 104 deletions src/TaskList/CompleteSetup.php

This file was deleted.

109 changes: 109 additions & 0 deletions src/TaskList/CompleteSetupTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\TaskList;

use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Registerable;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterAwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterAwareTrait;

/**
* Complete Setup Task to be added to the extended task list.
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\TaskList
*/
class CompleteSetupTask extends Task implements Service, Registerable, MerchantCenterAwareInterface {

use MerchantCenterAwareTrait;

/**
* Register a service.
*
* Add itself to the extended task list on init.
*/
public function register(): void {
add_action(
'init',
function() {
$list_id = 'extended';

$this->task_list = TaskLists::get_list( $list_id );
TaskLists::add_task( $list_id, $this );
}
);
}
/**
* Get the task id.
*
* @return string
*/
public function get_id() {
return 'gla_complete_setup';
}

/**
* Get the task name.
*
* @return string
*/
public function get_title() {
return __(
'Set up Google Listings & Ads',
'google-listings-and-ads'
);
}

/**
* Get the task description.
*
* @return string empty string
*/
public function get_content() {
return '';
}

/**
* Get the task completion time.
*
* @return string
*/
public function get_time() {
return __( '20 minutes', 'google-listings-and-ads' );
}

/**
* Always dismissable.
*
* @return bool
*/
public function is_dismissable() {
return true;
}

/**
* Get completion status.
* Forwards from the merchant center setup status.
*
* @return bool
*/
public function is_complete() {
return $this->merchant_center->is_setup_complete();
}

/**
* Get the action URL.
*
* @return string Start page or dashboard is the setup is completed.
*/
public function get_action_url() {
if ( ! $this->is_complete() ) {
return admin_url( 'admin.php?page=wc-admin&path=/google/start' );
}

return admin_url( 'admin.php?page=wc-admin&path=/google/dashboard' );
}

}
36 changes: 0 additions & 36 deletions src/TaskList/TaskListTrait.php

This file was deleted.

Loading