import React from "react" import { withRouter } from "react-router-dom" import { Form, FormGroup, FormControl, ControlLabel } from "react-bootstrap" class ExplorerOptions extends React.PureComponent { constructor(props) { super(props); this.handleSourceChange = this.handleSourceChange.bind(this); this.handleCategoryChange = this.handleCategoryChange.bind(this); } handleSourceChange(event) { let source = event.target.value; let category = this.props.options.get(event.target.value).first(); this.props.history.push(`/${this.props.type}/explore/${source}/${category}`); } handleCategoryChange(event) { let source = this.props.params.source; let category = event.target.value; this.props.history.push(`/${this.props.type}/explore/${source}/${category}`); } propsValid(props) { if (!props.params || !props.params.source || !props.params.category || (props.params.source === "") || (props.params.category === "")) { return false } return true; } prettyName(name) { return name.replace("_", " ") .split(" ") .map((w) => w[0].toUpperCase() + w.substr(1)) .join(" "); } render() { // Should this componennt be displayed if (!this.props.display) { return null; } // Options are not yet fetched if (this.props.options.size === 0) { return null; } // Invalid props if (!this.propsValid(this.props)) { return } let source = this.props.params.source; let category = this.props.params.category; let categories = this.props.options.get(this.props.params.source); return (
Source {this.props.options.keySeq().map(function(source) { return ( ) }, this)}
Category {categories.map(function(category) { return () }, this)}
); } } export default withRouter(ExplorerOptions);