2018-04-17 23:51:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2019-07-23 03:26:46 +00:00
|
|
|
import '@wordpress/notices';
|
2018-05-18 17:31:08 +00:00
|
|
|
import { render } from '@wordpress/element';
|
2018-04-17 23:51:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-08-06 15:30:43 +00:00
|
|
|
import './stylesheets/_index.scss';
|
2019-09-24 15:55:39 +00:00
|
|
|
import { PageLayout, EmbedLayout, PrimaryLayout as NoticeArea } from './layout';
|
2020-04-27 09:30:32 +00:00
|
|
|
import Navigation from './navigation';
|
2018-11-29 15:57:49 +00:00
|
|
|
import 'wc-api/wp-data-store';
|
2020-03-25 03:20:17 +00:00
|
|
|
import { withSettingsHydration } from '@woocommerce/data';
|
2018-05-15 15:06:15 +00:00
|
|
|
|
2019-09-24 15:55:39 +00:00
|
|
|
const appRoot = document.getElementById( 'root' );
|
2020-04-27 09:30:32 +00:00
|
|
|
const navigationRoot = document.getElementById( 'woocommerce-embedded-navigation' );
|
2020-03-25 03:20:17 +00:00
|
|
|
const settingsGroup = 'wc_admin';
|
2019-09-24 15:55:39 +00:00
|
|
|
|
2020-04-27 09:30:32 +00:00
|
|
|
if ( navigationRoot ) {
|
|
|
|
const HydratedNavigation = withSettingsHydration( settingsGroup, window.wcSettings )(
|
|
|
|
Navigation
|
|
|
|
);
|
|
|
|
render( <HydratedNavigation />, navigationRoot );
|
|
|
|
|
|
|
|
// Collapse the WP Menu.
|
|
|
|
const adminMenu = document.getElementById( 'adminmenumain' );
|
|
|
|
adminMenu.classList.add( 'folded' );
|
|
|
|
}
|
|
|
|
|
2019-09-24 15:55:39 +00:00
|
|
|
if ( appRoot ) {
|
2020-03-25 03:20:17 +00:00
|
|
|
const HydratedPageLayout = withSettingsHydration( settingsGroup, window.wcSettings )(
|
|
|
|
PageLayout
|
|
|
|
);
|
|
|
|
render( <HydratedPageLayout />, appRoot );
|
2019-09-24 15:55:39 +00:00
|
|
|
} else {
|
|
|
|
const embeddedRoot = document.getElementById( 'woocommerce-embedded-root' );
|
2020-03-25 03:20:17 +00:00
|
|
|
const HydratedEmbedLayout = withSettingsHydration( settingsGroup, window.wcSettings )(
|
|
|
|
EmbedLayout
|
|
|
|
);
|
2019-09-24 15:55:39 +00:00
|
|
|
// Render the header.
|
2020-03-25 03:20:17 +00:00
|
|
|
render( <HydratedEmbedLayout />, embeddedRoot );
|
2019-09-24 15:55:39 +00:00
|
|
|
|
|
|
|
embeddedRoot.classList.remove( 'is-embed-loading' );
|
|
|
|
|
|
|
|
// Render notices just above the WP content div.
|
|
|
|
const wpBody = document.getElementById( 'wpbody-content' );
|
|
|
|
const wrap = wpBody.querySelector( '.wrap' );
|
|
|
|
const noticeContainer = document.createElement( 'div' );
|
|
|
|
|
|
|
|
render(
|
|
|
|
<div className="woocommerce-layout">
|
|
|
|
<NoticeArea />
|
|
|
|
</div>,
|
|
|
|
wpBody.insertBefore( noticeContainer, wrap )
|
|
|
|
);
|
|
|
|
}
|