Fix Gutenberg 3.7 compatibility: Remove APIProvider (https://github.com/woocommerce/woocommerce-admin/pull/390)

* Remove APIProvider

Unused in the project, and deprecated in gutenberg

* Remove wp-api dependency
This commit is contained in:
Kelly Dwan 2018-09-11 15:48:43 -04:00 committed by GitHub
parent fbd91266f0
commit ed1b847067
3 changed files with 10 additions and 26 deletions

View File

@ -2,8 +2,6 @@
/** /**
* External dependencies * External dependencies
*/ */
import { APIProvider } from '@wordpress/components';
import { pick } from 'lodash';
import { render } from '@wordpress/element'; import { render } from '@wordpress/element';
import { Provider as SlotFillProvider } from 'react-slot-fill'; import { Provider as SlotFillProvider } from 'react-slot-fill';
@ -14,13 +12,8 @@ import './stylesheets/_embedded.scss';
import { EmbedLayout } from './layout'; import { EmbedLayout } from './layout';
render( render(
<APIProvider <SlotFillProvider>
{ ...wpApiSettings } <EmbedLayout />
{ ...pick( wp.api, [ 'postTypeRestBaseMapping', 'taxonomyRestBaseMapping' ] ) } </SlotFillProvider>,
>
<SlotFillProvider>
<EmbedLayout />
</SlotFillProvider>
</APIProvider>,
document.getElementById( 'woocommerce-embedded-root' ) document.getElementById( 'woocommerce-embedded-root' )
); );

View File

@ -2,8 +2,6 @@
/** /**
* External dependencies * External dependencies
*/ */
import { APIProvider } from '@wordpress/components';
import { pick } from 'lodash';
import { render } from '@wordpress/element'; import { render } from '@wordpress/element';
import { Provider as SlotFillProvider } from 'react-slot-fill'; import { Provider as SlotFillProvider } from 'react-slot-fill';
@ -15,13 +13,8 @@ import { PageLayout } from './layout';
import 'store'; import 'store';
render( render(
<APIProvider <SlotFillProvider>
{ ...wpApiSettings } <PageLayout />
{ ...pick( wp.api, [ 'postTypeRestBaseMapping', 'taxonomyRestBaseMapping' ] ) } </SlotFillProvider>,
>
<SlotFillProvider>
<PageLayout />
</SlotFillProvider>
</APIProvider>,
document.getElementById( 'root' ) document.getElementById( 'root' )
); );

View File

@ -55,13 +55,11 @@ function wc_admin_register_script() {
$content = 'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ', "wc-admin" );'; $content = 'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ', "wc-admin" );';
wp_add_inline_script( 'wc-components', $content, 'before' ); wp_add_inline_script( 'wc-components', $content, 'before' );
wp_enqueue_script( 'wp-api' ); // Add Tracks script to the DOM if tracking is opted in.
// Add Tracks script to the DOM if tracking is opted in
$tracking_enabled = 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ); $tracking_enabled = 'yes' === get_option( 'woocommerce_allow_tracking', 'no' );
if( $tracking_enabled ) { if ( $tracking_enabled ) {
$tracking_script = "var wc_tracking_script = document.createElement( 'script' );\n"; $tracking_script = "var wc_tracking_script = document.createElement( 'script' );\n";
$tracking_script .= "wc_tracking_script.src = '//stats.wp.com/w.js';\n"; //TODO Version/cache buster $tracking_script .= "wc_tracking_script.src = '//stats.wp.com/w.js';\n"; // TODO Version/cache buster.
$tracking_script .= "wc_tracking_script.type = 'text/javascript';\n"; $tracking_script .= "wc_tracking_script.type = 'text/javascript';\n";
$tracking_script .= "wc_tracking_script.async = true;\n"; $tracking_script .= "wc_tracking_script.async = true;\n";
$tracking_script .= "wc_tracking_script.defer = true;\n"; $tracking_script .= "wc_tracking_script.defer = true;\n";
@ -71,7 +69,7 @@ function wc_admin_register_script() {
} }
/** /**
* TODO: On merge, once plugin images are added to core WooCommerce, `wcAdminAssetUrl` can be retired, and * TODO: On merge, once plugin images are added to core WooCommerce, `wcAdminAssetUrl` can be retired, and
* `wcAssetUrl` can be used in its place throughout the codebase. * `wcAssetUrl` can be used in its place throughout the codebase.
*/ */