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 b3723f7a7d
commit 05a608399a
4 changed files with 13 additions and 14 deletions

View File

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

View File

@ -1,2 +1,2 @@
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 { Button } from '@wordpress/components';
import classNames from 'classnames';
import { getQuery, getNewPath, navigateTo } from '@woocommerce/navigation';
import { getNewPath, navigateTo, useQuery } from '@woocommerce/navigation';
/**
* Internal dependencies
@ -80,16 +80,15 @@ const Tabs = ( props: TabsProps ): JSX.Element => {
tab?: string;
}
useEffect( () => {
const query: Query = getQuery();
const query: Query = useQuery();
useEffect( () => {
if ( query?.tab && tabs[ query.tab ] ) {
setSelectedTab( query.tab );
return;
} else {
setSelectedTab( DEFAULT_TAB_KEY );
}
setSelectedTab( DEFAULT_TAB_KEY );
}, [ setSelectedTab ] );
}, [ query, setSelectedTab ] );
return (
<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.
*/
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(
'id' => 'woocommerce-marketplace',
'parent' => 'woocommerce',
'title' => __( 'Marketplace', 'woocommerce' ),
'path' => '/marketplace',
'title' => __( 'Extensions', 'woocommerce' ),
'path' => '/extensions',
),
);