Add warning when tracking is disabled

This commit is contained in:
moon 2022-05-09 17:16:41 -07:00
parent 4d4c4a1dd9
commit 9f00243985
2 changed files with 41 additions and 2 deletions

View File

@ -4,17 +4,45 @@
import { withDispatch, withSelect } from '@wordpress/data'; import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose'; import { compose } from '@wordpress/compose';
import { Button } from '@wordpress/components'; import { Button } from '@wordpress/components';
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { STORE_KEY } from './data/constants'; import { STORE_KEY } from './data/constants';
import './data'; import './data';
function Experiments( { experiments, toggleExperiment } ) { function Experiments( {
experiments,
toggleExperiment,
isTrackingEnabled,
isResolving,
} ) {
if ( isResolving ) {
return null;
}
return ( return (
<div id="wc-admin-test-helper-experiments"> <div id="wc-admin-test-helper-experiments">
<h2>Experiments</h2> <h2>Experiments</h2>
{ isTrackingEnabled === 'no' && (
<p className="tracking-disabled">
The following list might not be complete without tracking
enabled. <br />
Please visit&nbsp;
<a
target="_blank"
href={
wcSettings.adminUrl +
'/admin.php?page=wc-settings&tab=advanced&section=woocommerce_com'
}
rel="noreferrer"
>
WooCommerce &#8594; Settings &#8594; Advanced &#8594;
Woocommerce.com
</a>
&nbsp;and check{ ' ' }
<b>Allow usage of WooCommerce to be tracked</b>.
</p>
) }
<table className="experiments wp-list-table striped table-view-list widefat"> <table className="experiments wp-list-table striped table-view-list widefat">
<thead> <thead>
<tr> <tr>
@ -61,8 +89,12 @@ function Experiments( { experiments, toggleExperiment } ) {
export default compose( export default compose(
withSelect( ( select ) => { withSelect( ( select ) => {
const { getExperiments } = select( STORE_KEY ); const { getExperiments } = select( STORE_KEY );
const { getOption, isResolving } = select( OPTIONS_STORE_NAME );
return { return {
experiments: getExperiments(), experiments: getExperiments(),
isTrackingEnabled: getOption( 'woocommerce_allow_tracking' ),
isResolving: isResolving( 'getOption', [ 'getExperiments' ] ),
}; };
} ), } ),
withDispatch( ( dispatch ) => { withDispatch( ( dispatch ) => {

View File

@ -83,6 +83,13 @@
.components-notice { .components-notice {
margin: 0px 0px 10px 0px; margin: 0px 0px 10px 0px;
} }
.tracking-disabled {
border: 1px solid #cc99c2;
border-left: 4px solid #cc99c2;
line-height: 1.5em;
background: #fff;
padding: 10px;
}
} }
#wc-admin-test-helper-rest-api-filters { #wc-admin-test-helper-rest-api-filters {