// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import * as Utils from 'utils/utils.jsx'; import {Link} from 'react-router'; import LoadingScreen from 'components/loading_screen.jsx'; export default class BackstageList extends React.Component { static propTypes = { children: React.PropTypes.node, header: React.PropTypes.node.isRequired, addLink: React.PropTypes.string, addText: React.PropTypes.node, emptyText: React.PropTypes.node, helpText: React.PropTypes.node, loading: React.PropTypes.bool.isRequired, searchPlaceholder: React.PropTypes.string } static defaultProps = { searchPlaceholder: Utils.localizeMessage('backstage_list.search', 'Search') } constructor(props) { super(props); this.updateFilter = this.updateFilter.bind(this); this.state = { filter: '' }; } updateFilter(e) { this.setState({ filter: e.target.value }); } render() { const filter = this.state.filter.toLowerCase(); let children; if (this.props.loading) { children = ; } else { children = React.Children.map(this.props.children, (child) => { return React.cloneElement(child, {filter}); }); if (children.length === 0 && this.props.emptyText) { children = ( {this.props.emptyText} ); } } let addLink = null; if (this.props.addLink && this.props.addText) { addLink = ( ); } return (

{this.props.header}

{addLink}
{this.props.helpText}
{children}
); } }