UNPKG

ih-portal

Version:

A project for connecting interaction hub services with catalyst-ui components

52 lines (41 loc) 1.47 kB
import React, { Component, PropTypes } from 'react'; import { NavigationDrawerCollection } from 'catalyst-ui'; const { func, string } = PropTypes; export default class NavigationDrawerCollectionProv extends Component { constructor() { super(...arguments); this.fetch = this.fetch.bind(this); } componentDidMount() { const { navigationCollection: navCol, pageletName } = this.props; if (!navCol || (navCol.lastAction && navCol.lastAction.status === 'error') || !navCol.data || !navCol.data[pageletName]) { this.fetch(); } } fetch() { const requestParams = { url: __PAGELET_URL__, auth: [__USERNAME__, __PASSWORD__], }; this.props.fetch(requestParams, this.props.pageletName); } render() { const { navigationCollection, pageletName, pageletTitle } = this.props; let navigationDrawerCollection = null; if (navigationCollection.data[pageletName]) { navigationDrawerCollection = <NavigationDrawerCollection isFetching={navigationCollection.isFetching} navName={pageletTitle} ncd={navigationCollection.data[pageletName]} />; } return ( <div className="piglet"> {navigationDrawerCollection} </div> ); } } NavigationDrawerCollectionProv.propTypes = { fetch: func.isRequired, invalidate: func.isRequired, pageletName: string.isRequired, pageletTitle: string, }; export { NavigationDrawerCollectionProv as NavigationDrawerCollectionProvDumb };