Skip to content

Commit

Permalink
Add the dedicated shipping settings page.
Browse files Browse the repository at this point in the history
  • Loading branch information
eason9487 committed Jan 6, 2025
1 parent bccc6c4 commit 43d27ec
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
6 changes: 6 additions & 0 deletions js/src/components/main-tab-nav/main-tab-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { glaData } from '~/constants';
import AppTabNav from '~/components/app-tab-nav';
import useMenuEffect from '~/hooks/useMenuEffect';
import GtinMigrationBanner from '~/components/gtin-migration-banner';
import { getShippingUrl } from '~/utils/urls';

let tabs = [
{
Expand Down Expand Up @@ -38,6 +39,11 @@ let tabs = [
title: __( 'Settings', 'google-listings-and-ads' ),
href: getNewPath( {}, '/google/settings', {} ),
},
{
key: 'shipping',
title: __( 'Shipping', 'google-listings-and-ads' ),
href: getShippingUrl(),
},
];

// Hide reports tab.
Expand Down
16 changes: 16 additions & 0 deletions js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const Settings = lazy( () =>
import( /* webpackChunkName: "settings" */ './pages/settings' )
);

const Shipping = lazy( () =>
import( /* webpackChunkName: "shipping" */ './pages/shipping' )
);

export const pagePaths = new Set();

const woocommerceTranslation =
Expand Down Expand Up @@ -152,6 +156,18 @@ addFilter(
id: 'google-settings',
},
},
{
breadcrumbs: [
...initialBreadcrumbs,
__( 'Shipping', 'google-listings-and-ads' ),
],
container: Shipping,
path: '/google/shipping',
wpOpenMenu: 'toplevel_page_woocommerce-marketing',
navArgs: {
id: 'google-shipping',
},
},
];

pluginAdminPages.forEach( ( page ) => {
Expand Down
5 changes: 5 additions & 0 deletions js/src/utils/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const pagePaths = {
reports: '/google/reports',
productFeed: '/google/product-feed',
settings: '/google/settings',
shipping: '/google/shipping',
};

export const subpaths = {
Expand Down Expand Up @@ -79,6 +80,10 @@ export const getSettingsUrl = () => {
return getNewPath( null, settingsPath, null );
};

export const getShippingUrl = () => {
return getNewPath( null, pagePaths.shipping, null );
};

export const geReportsUrl = () => {
return getNewPath( null, reportsPath, null );
};
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/DependencyManagement/CoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\Settings;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\SetupAds;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\SetupMerchantCenter;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\Shipping;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\AccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\AccountService as MerchantAccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\ContactInformation;
Expand Down Expand Up @@ -174,6 +175,7 @@ class CoreServiceProvider extends AbstractServiceProvider {
RESTControllers::class => true,
Service::class => true,
Settings::class => true,
Shipping::class => true,
SetupAds::class => true,
SetupMerchantCenter::class => true,
SetupCampaignNote::class => true,
Expand Down Expand Up @@ -311,6 +313,7 @@ function ( ...$arguments ) {
$this->conditionally_share_with_tags( ProductFeed::class );
$this->conditionally_share_with_tags( AttributeMapping::class );
$this->conditionally_share_with_tags( Settings::class );
$this->conditionally_share_with_tags( Shipping::class );
$this->share_with_tags( TrackerSnapshot::class );
$this->conditionally_share_with_tags( EventTracking::class, ContainerInterface::class );
$this->conditionally_share_with_tags( RESTControllers::class, ContainerInterface::class );
Expand Down
34 changes: 34 additions & 0 deletions src/Menu/Shipping.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Menu;

use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Registerable;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;

/**
* Class Shipping
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Menu
*/
class Shipping implements Service, Registerable {

/**
* Register a service.
*/
public function register(): void {
add_action(
'admin_menu',
function () {
wc_admin_register_page(
[
'id' => 'google-shipping',
'parent' => 'google-listings-and-ads-category',
'title' => __( 'Shipping', 'google-listings-and-ads' ),
'path' => '/google/shipping',
]
);
}
);
}
}

0 comments on commit 43d27ec

Please sign in to comment.