fleet/frontend/layouts/CoreLayout/CoreLayout.jsx
Mike Stone a81f08b07b Sidepanel refactor (#329)
* Moves side panels into the side_panel directory

* Adds SecondarySidePanelContainer component

* Renames MainSidePanel to SiteNavSidePanel
2016-10-20 08:43:25 -04:00

62 lines
1.5 KiB
JavaScript

import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { StyleRoot } from 'radium';
import componentStyles from './styles';
import FlashMessage from '../../components/FlashMessage';
import SiteNavSidePanel from '../../components/side_panels/SiteNavSidePanel';
export class CoreLayout extends Component {
static propTypes = {
children: PropTypes.node,
config: PropTypes.shape({
org_logo_url: PropTypes.string,
org_name: PropTypes.string,
}),
dispatch: PropTypes.func,
notifications: PropTypes.object,
showRightSidePanel: PropTypes.bool,
user: PropTypes.object,
};
render () {
const { children, config, dispatch, notifications, showRightSidePanel, user } = this.props;
const { wrapperStyles } = componentStyles;
if (!user) return false;
const { pathname } = global.window.location;
return (
<StyleRoot>
<SiteNavSidePanel
config={config}
pathname={pathname}
user={user}
/>
<div style={wrapperStyles(showRightSidePanel)}>
<FlashMessage notification={notifications} dispatch={dispatch} />
{children}
</div>
</StyleRoot>
);
}
}
const mapStateToProps = (state) => {
const {
app: { config, showRightSidePanel },
auth: { user },
notifications,
} = state;
return {
config,
notifications,
showRightSidePanel,
user,
};
};
export default connect(mapStateToProps)(CoreLayout);