Changed `Tabs` to use `useQuery` instead of `getQuery`, so the browser back button will work.

Changed submenu item name back to `Extensions`, and keeping it in the current order within the WooCommerce menu.
Changed `path` value to `extensions`.
This commit is contained in:
And Finally 2023-07-20 17:00:22 +01:00
parent a2b878e8e7
commit 30e23d22d5
4 changed files with 13 additions and 14 deletions

View File

@ -182,10 +182,10 @@ export const getPages = () => {
layout: { layout: {
header: false, header: false,
}, },
path: '/marketplace', path: '/extensions',
breadcrumbs: [ breadcrumbs: [
[ '/marketplace', __( 'Marketplace', 'woocommerce' ) ], [ '/extensions', __( 'Extensions', 'woocommerce' ) ],
__( 'Marketplace', 'woocommerce' ), __( 'Extensions', 'woocommerce' ),
], ],
wpOpenMenu: 'toplevel_page_woocommerce', wpOpenMenu: 'toplevel_page_woocommerce',
capability: 'manage_woocommerce', capability: 'manage_woocommerce',

View File

@ -1,2 +1,2 @@
export const DEFAULT_TAB_KEY = 'discover'; export const DEFAULT_TAB_KEY = 'discover';
export const MARKETPLACE_PATH = '/marketplace'; export const MARKETPLACE_PATH = '/extensions';

View File

@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n';
import { useEffect } from '@wordpress/element'; import { useEffect } from '@wordpress/element';
import { Button } from '@wordpress/components'; import { Button } from '@wordpress/components';
import classNames from 'classnames'; import classNames from 'classnames';
import { getQuery, getNewPath, navigateTo } from '@woocommerce/navigation'; import { getNewPath, navigateTo, useQuery } from '@woocommerce/navigation';
/** /**
* Internal dependencies * Internal dependencies
@ -80,16 +80,15 @@ const Tabs = ( props: TabsProps ): JSX.Element => {
tab?: string; tab?: string;
} }
useEffect( () => { const query: Query = useQuery();
const query: Query = getQuery();
useEffect( () => {
if ( query?.tab && tabs[ query.tab ] ) { if ( query?.tab && tabs[ query.tab ] ) {
setSelectedTab( query.tab ); setSelectedTab( query.tab );
return; } else {
}
setSelectedTab( DEFAULT_TAB_KEY ); setSelectedTab( DEFAULT_TAB_KEY );
}, [ setSelectedTab ] ); }
}, [ query, setSelectedTab ] );
return ( return (
<nav className="woocommerce-marketplace__tabs"> <nav className="woocommerce-marketplace__tabs">

View File

@ -16,7 +16,7 @@ class Marketplace {
* Class initialization, to be executed when the class is resolved by the container. * Class initialization, to be executed when the class is resolved by the container.
*/ */
final public function init() { final public function init() {
add_action( 'admin_menu', array( $this, 'register_pages' ), 45 ); add_action( 'admin_menu', array( $this, 'register_pages' ), 70 );
} }
/** /**
@ -39,8 +39,8 @@ class Marketplace {
array( array(
'id' => 'woocommerce-marketplace', 'id' => 'woocommerce-marketplace',
'parent' => 'woocommerce', 'parent' => 'woocommerce',
'title' => __( 'Marketplace', 'woocommerce' ), 'title' => __( 'Extensions', 'woocommerce' ),
'path' => '/marketplace', 'path' => '/extensions',
), ),
); );