Skip to content
Snippets Groups Projects
Commit 03d07084 authored by Jack Reed's avatar Jack Reed
Browse files

Add children rendering to PrimaryWindow

parent d74da5c1
Branches
Tags
No related merge requests found
......@@ -20,6 +20,13 @@ describe('PrimaryWindow', () => {
const wrapper = createWrapper();
expect(wrapper.find('.mirador-primary-window')).toHaveLength(1);
});
it('should only render children when available', () => {
const wrapper = createWrapper({ children: <span>hi</span>, isFetching: false });
expect(wrapper.find('span')).toHaveLength(1);
const suspenseComponent = wrapper.find('Suspense');
const lazyComponent = suspenseComponent.dive().find('lazy');
expect(lazyComponent).toHaveLength(0);
});
it('should render <WindowSideBar>', () => {
const wrapper = createWrapper();
expect(wrapper.find(WindowSideBar)).toHaveLength(1);
......
......@@ -75,14 +75,16 @@ export class PrimaryWindow extends Component {
* Render the component
*/
render() {
const { isCollectionDialogVisible, windowId, classes } = this.props;
const {
isCollectionDialogVisible, windowId, classes, children,
} = this.props;
return (
<div className={classNames(ns('primary-window'), classes.primaryWindow)}>
<WindowSideBar windowId={windowId} />
<CompanionArea windowId={windowId} position="left" />
{ isCollectionDialogVisible && <CollectionDialog windowId={windowId} /> }
<Suspense fallback={<div />}>
{this.renderViewer()}
{children || this.renderViewer()}
</Suspense>
</div>
);
......@@ -91,6 +93,7 @@ export class PrimaryWindow extends Component {
PrimaryWindow.propTypes = {
audioResources: PropTypes.arrayOf(PropTypes.object),
children: PropTypes.node,
classes: PropTypes.objectOf(PropTypes.string).isRequired,
isCollection: PropTypes.bool,
isCollectionDialogVisible: PropTypes.bool,
......@@ -102,6 +105,7 @@ PrimaryWindow.propTypes = {
PrimaryWindow.defaultProps = {
audioResources: [],
children: undefined,
isCollection: false,
isCollectionDialogVisible: false,
isFetching: false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment