add leading slash in path for Leaderboards
This commit is contained in:
parent
d72a0edc0a
commit
563e94b7a2
|
@ -10,7 +10,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|||
* WooCommerce dependencies
|
||||
*/
|
||||
import { Card } from '@woocommerce/components';
|
||||
import { getAdminLink, getHistory } from '@woocommerce/navigation';
|
||||
import { getAdminLink, getHistory, getNewPath, getPersistedQuery } from '@woocommerce/navigation';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -26,9 +26,13 @@ class ChartBlock extends Component {
|
|||
return null;
|
||||
}
|
||||
|
||||
getHistory().push( 'analytics/' + charts[ 0 ].endpoint + '?chart=' + charts[ 0 ].key );
|
||||
getHistory().push( this.getChartPath( charts[ 0 ] ) );
|
||||
};
|
||||
|
||||
getChartPath( chart ) {
|
||||
return getNewPath( { chart: chart.key }, '/analytics/' + chart.endpoint, getPersistedQuery() );
|
||||
}
|
||||
|
||||
render() {
|
||||
const { charts, endpoint, path, query } = this.props;
|
||||
|
||||
|
@ -48,12 +52,7 @@ class ChartBlock extends Component {
|
|||
>
|
||||
<a
|
||||
className="screen-reader-text"
|
||||
href={ getAdminLink(
|
||||
'admin.php?page=wc-admin&path=/analytics/' +
|
||||
charts[ 0 ].endpoint +
|
||||
'&chart=' +
|
||||
charts[ 0 ].key
|
||||
) }
|
||||
href={ getAdminLink( this.getChartPath( charts[ 0 ] ) ) }
|
||||
>
|
||||
{ /* translators: %s is the chart type */
|
||||
sprintf( __( '%s Report', 'woocommerce-admin' ), charts[ 0 ].label ) }
|
||||
|
|
|
@ -46,6 +46,8 @@ export function getLeaderboard( options ) {
|
|||
return { ...response, isError: true };
|
||||
}
|
||||
|
||||
console.log( leaderboard.rows );
|
||||
|
||||
return { ...response, rows: leaderboard.rows };
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ class WC_Admin_REST_Leaderboards_Controller extends WC_REST_Data_Controller {
|
|||
),
|
||||
$persisted_query
|
||||
);
|
||||
$category_url = wc_admin_url( 'analytics/categories', $url_query );
|
||||
$category_url = wc_admin_url( '/analytics/categories', $url_query );
|
||||
$category_name = isset( $category['extended_info'] ) && isset( $category['extended_info']['name'] ) ? $category['extended_info']['name'] : '';
|
||||
$rows[] = array(
|
||||
array(
|
||||
|
@ -223,7 +223,7 @@ class WC_Admin_REST_Leaderboards_Controller extends WC_REST_Data_Controller {
|
|||
),
|
||||
$persisted_query
|
||||
);
|
||||
$customer_url = wc_admin_url( 'analytics/customers', $url_query );
|
||||
$customer_url = wc_admin_url( '/analytics/customers', $url_query );
|
||||
$rows[] = array(
|
||||
array(
|
||||
'display' => "<a href='{$customer_url}'>{$customer['name']}</a>",
|
||||
|
@ -288,7 +288,7 @@ class WC_Admin_REST_Leaderboards_Controller extends WC_REST_Data_Controller {
|
|||
),
|
||||
$persisted_query
|
||||
);
|
||||
$product_url = wc_admin_url( 'analytics/products', $url_query );
|
||||
$product_url = wc_admin_url( '/analytics/products', $url_query );
|
||||
$product_name = isset( $product['extended_info'] ) && isset( $product['extended_info']['name'] ) ? $product['extended_info']['name'] : '';
|
||||
$rows[] = array(
|
||||
array(
|
||||
|
|
|
@ -141,7 +141,7 @@ class WC_Tests_API_Leaderboards extends WC_REST_Unit_Test_Case {
|
|||
$widgets_leaderboard = end( $data );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 'top_widgets', $widgets_leaderboard['id'] );
|
||||
$this->assertEquals( admin_url( 'admin.php?page=wc-admin&path=test/path&persisted_param=1' ), $widgets_leaderboard['rows'][0]['display'] );
|
||||
$this->assertEquals( admin_url( 'admin.php?page=wc-admin&path=/test/path&persisted_param=1' ), $widgets_leaderboard['rows'][0]['display'] );
|
||||
|
||||
$request = new WP_REST_Request( 'GET', $this->endpoint . '/allowed' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
|
|
Loading…
Reference in New Issue