Navigation: Prep feature flags and option (https://github.com/woocommerce/woocommerce-admin/pull/5292)
* add feature flag * hydrate options on embedded screens * is_feature_enabled * feature class * feedback * better name * fix
This commit is contained in:
parent
61c189f456
commit
c089b49b38
|
@ -222,9 +222,7 @@ export const PageLayout = compose(
|
|||
: identity
|
||||
)( _PageLayout );
|
||||
|
||||
export class EmbedLayout extends Component {
|
||||
render() {
|
||||
return (
|
||||
const _EmbedLayout = () => (
|
||||
<Layout
|
||||
page={ {
|
||||
breadcrumbs: getSetting( 'embedBreadcrumbs', [] ),
|
||||
|
@ -232,5 +230,11 @@ export class EmbedLayout extends Component {
|
|||
isEmbedded
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const EmbedLayout = compose(
|
||||
window.wcSettings.preloadOptions
|
||||
? withOptionsHydration( {
|
||||
...window.wcSettings.preloadOptions,
|
||||
} )
|
||||
: identity
|
||||
)( _EmbedLayout );
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"store-alerts": true,
|
||||
"minified-js": false,
|
||||
"wcpay": true,
|
||||
"mobile-app-banner": true
|
||||
"mobile-app-banner": true,
|
||||
"navigation": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"store-alerts": true,
|
||||
"minified-js": true,
|
||||
"wcpay": true,
|
||||
"mobile-app-banner": true
|
||||
"mobile-app-banner": true,
|
||||
"navigation": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"store-alerts": true,
|
||||
"minified-js": true,
|
||||
"wcpay": true,
|
||||
"mobile-app-banner": true
|
||||
"mobile-app-banner": true,
|
||||
"navigation": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* Navigation Experience
|
||||
*
|
||||
* @package Woocommerce Admin
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Features;
|
||||
|
||||
/**
|
||||
* Contains logic for the Navigation
|
||||
*/
|
||||
class Navigation {
|
||||
/**
|
||||
* Hook into WooCommerce.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'woocommerce_admin_preload_options', array( $this, 'preload_options' ) );
|
||||
add_filter( 'woocommerce_admin_features', array( $this, 'maybe_remove_nav_feature' ), 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the allowed features array using a local `feature-config.php` file.
|
||||
*
|
||||
* @param array $features Array of feature slugs.
|
||||
*/
|
||||
public function maybe_remove_nav_feature( $features ) {
|
||||
if ( in_array( 'navigation', $features, true ) && 'yes' !== get_option( 'woocommerce_navigation_enabled', 'no' ) ) {
|
||||
$features = array_diff( $features, array( 'navigation' ) );
|
||||
}
|
||||
return $features;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload options to prime state of the application.
|
||||
*
|
||||
* @param array $options Array of options to preload.
|
||||
* @return array
|
||||
*/
|
||||
public function preload_options( $options ) {
|
||||
$options[] = 'woocommerce_navigation_enabled';
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue