Merge pull request #30380 from woocommerce/update/split-extensions-pages

Split the Extensions page in WP Admin and add respective menu items
This commit is contained in:
Maria Górska-Piszek 2021-08-06 13:47:31 +02:00 committed by GitHub
commit 4a736507bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 32 deletions

View File

@ -36,6 +36,7 @@ class WC_Admin_Menus {
add_filter( 'menu_order', array( $this, 'menu_order' ) );
add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
add_filter( 'parent_file', array( $this, 'update_menu_highlight' ) );
// Add endpoints custom URLs in Appearance > Menus > Pages.
add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
@ -149,8 +150,9 @@ class WC_Admin_Menus {
public function addons_menu() {
$count_html = WC_Helper_Updater::get_updates_count_html();
/* translators: %s: extensions count */
$menu_title = sprintf( __( 'Extensions %s', 'woocommerce' ), $count_html );
add_submenu_page( 'woocommerce', __( 'WooCommerce extensions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) );
$menu_title = sprintf( __( 'My Subscriptions %s', 'woocommerce' ), $count_html );
add_submenu_page( 'woocommerce', __( 'WooCommerce Marketplace', 'woocommerce' ), __( 'Marketplace', 'woocommerce' ), 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) );
add_submenu_page( 'woocommerce', __( 'My WooCommerce.com Subscriptions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons&section=helper', array( $this, 'addons_page' ) );
}
/**
@ -387,6 +389,38 @@ class WC_Admin_Menus {
)
);
}
/**
* Highlight the My Subscriptions menu item when on that page
*
* @param string $parent_file currently opened page.
* @return string
*/
public function update_menu_highlight( $parent_file ) {
global $submenu_file;
if ( 'woocommerce' === $parent_file && isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
$submenu_file = 'wc-addons&section=helper'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
}
return $parent_file;
}
/**
* Update the My Subscriptions document title when on that page.
* We want to maintain existing page URL but add it as a separate page,
* which requires updating it manually.
*
* @param string $admin_title existing page title.
* @return string
*/
public function update_my_subscriptions_title( $admin_title ) {
if (
isset( $_GET['page'] ) && 'wc-addons' === $_GET['page'] &&
isset( $_GET['section'] ) && 'helper' === $_GET['section']
) {
$admin_title = 'My WooCommerce.com Subscriptions';
}
return $admin_title;
}
}
return new WC_Admin_Menus();

View File

@ -9,8 +9,7 @@
<?php defined( 'ABSPATH' ) || exit(); ?>
<div class="wrap woocommerce wc_addons_wrap wc-helper">
<?php require WC_Helper::get_view_filename( 'html-section-nav.php' ); ?>
<h1 class="screen-reader-text"><?php esc_html_e( 'WooCommerce Extensions', 'woocommerce' ); ?></h1>
<h1 class="screen-reader-text"><?php esc_html_e( 'My Subscriptions', 'woocommerce' ); ?></h1>
<?php require WC_Helper::get_view_filename( 'html-section-notices.php' ); ?>
@ -174,7 +173,7 @@
<tr class="wp-list-table__row wp-list-table__ext-updates">
<td class="wp-list-table__ext-status <?php echo sanitize_html_class( $subscription_action['status'] ); ?>">
<p><span class="dashicons <?php echo sanitize_html_class( $subscription_action['icon'] ); ?>"></span>
<?php echo esc_html( $subscription_action['message'] ); ?>
<?php echo wp_kses_post( $subscription_action['message'] ); ?>
</p>
</td>
<td class="wp-list-table__ext-actions">

View File

@ -10,7 +10,6 @@ defined( 'ABSPATH' ) || exit();
?>
<div class="wrap woocommerce wc_addons_wrap wc-helper">
<?php require WC_Helper::get_view_filename( 'html-section-nav.php' ); ?>
<h1 class="screen-reader-text"><?php esc_html_e( 'WooCommerce Extensions', 'woocommerce' ); ?></h1>
<?php require WC_Helper::get_view_filename( 'html-section-notices.php' ); ?>

View File

@ -1,19 +0,0 @@
<?php
/**
* Helper admin navigation.
*
* @package WooCommerce\Helper
*/
defined( 'ABSPATH' ) || exit(); ?>
<nav class="nav-tab-wrapper woo-nav-tab-wrapper">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-addons' ) ); ?>" class="nav-tab"><?php esc_html_e( 'Browse Extensions', 'woocommerce' ); ?></a>
<?php
$count_html = WC_Helper_Updater::get_updates_count_html();
/* translators: %s: WooCommerce.com Subscriptions tab count HTML. */
$menu_title = sprintf( __( 'WooCommerce.com Subscriptions %s', 'woocommerce' ), $count_html );
?>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-addons&section=helper' ) ); ?>" class="nav-tab nav-tab-active"><?php echo wp_kses_post( $menu_title ); ?></a>
</nav>

View File

@ -13,6 +13,8 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div class="wrap woocommerce wc_addons_wrap">
<h1 class="screen-reader-text"><?php esc_html_e( 'Marketplace', 'woocommerce' ); ?></h1>
<?php if ( $sections ) : ?>
<div class="marketplace-header">
<h1 class="marketplace-header__title"><?php esc_html_e( 'WooCommerce Marketplace', 'woocommerce' ); ?></h1>

View File

@ -22,13 +22,7 @@ const runInitiateWccomConnectionTest = () => {
});
it('can initiate WCCOM connection', async () => {
await merchant.openExtensions();
// Click on a tab to choose WooCommerce Subscriptions extension
await Promise.all([
expect(page).toClick('a.nav-tab', {text: "WooCommerce.com Subscriptions"}),
page.waitForNavigation({waitUntil: 'networkidle0'}),
]);
await merchant.openHelper();
// Click on Connect button to initiate a WCCOM connection
await Promise.all([

View File

@ -41,6 +41,7 @@ export const WP_ADMIN_ANALYTICS_PAGES = WP_ADMIN_WC_HOME + '&path=%2Fanalytics%2
export const WP_ADMIN_WC_SETTINGS = WP_ADMIN_PLUGIN_PAGE + 'wc-settings&tab=';
export const WP_ADMIN_NEW_SHIPPING_ZONE = WP_ADMIN_WC_SETTINGS + 'shipping&zone_id=new';
export const WP_ADMIN_WC_EXTENSIONS = WP_ADMIN_PLUGIN_PAGE + 'wc-addons';
export const WP_ADMIN_WC_HELPER = WP_ADMIN_PLUGIN_PAGE + 'wc-addons&section=helper';
/**
* Shop pages.

View File

@ -21,6 +21,7 @@ const {
WP_ADMIN_WC_HOME,
WP_ADMIN_WC_SETTINGS,
WP_ADMIN_WC_EXTENSIONS,
WP_ADMIN_WC_HELPER,
WP_ADMIN_NEW_SHIPPING_ZONE,
WP_ADMIN_ANALYTICS_PAGES,
WP_ADMIN_ALL_USERS_VIEW,
@ -134,6 +135,12 @@ const merchant = {
} );
},
openHelper: async () => {
await page.goto( WP_ADMIN_WC_HELPER, {
waitUntil: 'networkidle0',
} );
},
runSetupWizard: async () => {
const setupWizard = IS_RETEST_MODE ? WP_ADMIN_SETUP_WIZARD : WP_ADMIN_WC_HOME;
await page.goto( setupWizard, {