2018-05-10 18:35:55 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2018-05-24 16:03:03 +00:00
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
|
|
|
import { decodeEntities } from '@wordpress/utils';
|
2018-05-18 17:31:08 +00:00
|
|
|
import { Fill } from 'react-slot-fill';
|
2018-06-28 13:52:45 +00:00
|
|
|
import { isArray } from 'lodash';
|
2018-06-26 14:49:42 +00:00
|
|
|
import Link from 'components/link';
|
2018-05-10 18:35:55 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
2018-06-28 13:52:45 +00:00
|
|
|
import ActivityPanel from '../activity-panel';
|
2018-05-10 18:35:55 +00:00
|
|
|
|
2018-06-28 13:52:45 +00:00
|
|
|
const Header = ( { sections, isEmbedded } ) => {
|
2018-05-18 17:31:08 +00:00
|
|
|
const _sections = isArray( sections ) ? sections : [ sections ];
|
2018-05-10 18:35:55 +00:00
|
|
|
|
2018-05-24 16:03:03 +00:00
|
|
|
const documentTitle = _sections
|
|
|
|
.map( section => {
|
|
|
|
return isArray( section ) ? section[ 1 ] : section;
|
|
|
|
} )
|
|
|
|
.reverse()
|
|
|
|
.join( ' ‹ ' );
|
|
|
|
|
|
|
|
document.title = decodeEntities(
|
|
|
|
sprintf(
|
|
|
|
__( '%1$s ‹ %2$s — WooCommerce', 'woo-dash' ),
|
|
|
|
documentTitle,
|
|
|
|
wpApiSettings.schema.name
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2018-05-18 17:31:08 +00:00
|
|
|
return (
|
2018-06-28 13:52:45 +00:00
|
|
|
<div className="woocommerce-layout__header">
|
|
|
|
<h1 className="woocommerce-layout__header-breadcrumbs">
|
2018-05-14 13:41:30 +00:00
|
|
|
<span>
|
2018-05-22 15:19:56 +00:00
|
|
|
<Link to="/">WooCommerce</Link>
|
2018-05-14 13:41:30 +00:00
|
|
|
</span>
|
2018-05-24 16:03:03 +00:00
|
|
|
{ _sections.map( ( section, i ) => {
|
|
|
|
const sectionPiece = isArray( section ) ? (
|
2018-06-26 14:49:42 +00:00
|
|
|
<Link to={ section[ 0 ] } wpAdmin={ isEmbedded }>
|
|
|
|
{ section[ 1 ] }
|
|
|
|
</Link>
|
2018-05-24 16:03:03 +00:00
|
|
|
) : (
|
|
|
|
section
|
|
|
|
);
|
|
|
|
return <span key={ i }>{ sectionPiece }</span>;
|
|
|
|
} ) }
|
2018-05-10 18:35:55 +00:00
|
|
|
</h1>
|
2018-06-29 15:20:08 +00:00
|
|
|
<ActivityPanel />
|
2018-05-10 18:35:55 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Header.propTypes = {
|
|
|
|
sections: PropTypes.node.isRequired,
|
2018-06-26 14:49:42 +00:00
|
|
|
isEmbedded: PropTypes.bool,
|
2018-05-10 18:35:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Header.defaultProps = {
|
2018-06-26 14:49:42 +00:00
|
|
|
isEmbedded: false,
|
2018-05-22 15:19:56 +00:00
|
|
|
};
|
2018-05-10 18:35:55 +00:00
|
|
|
|
2018-05-18 17:31:08 +00:00
|
|
|
export default function( props ) {
|
|
|
|
return (
|
|
|
|
<Fill name="header">
|
|
|
|
<Header { ...props } />
|
|
|
|
</Fill>
|
|
|
|
);
|
|
|
|
}
|