Prettify the explorer options

This commit is contained in:
Grégoire Delattre 2017-04-14 23:01:40 +02:00
parent b8e55ec498
commit 52281675d0

View File

@ -67,6 +67,12 @@ export default class ExplorerOptions extends React.Component {
}); });
} }
} }
prettyName(name) {
return name.replace("_", " ")
.split(" ")
.map((w) => w[0].toUpperCase() + w.substr(1))
.join(" ");
}
render() { render() {
// Should this componennt be displayed // Should this componennt be displayed
if (!this.props.display) { if (!this.props.display) {
@ -98,8 +104,8 @@ export default class ExplorerOptions extends React.Component {
value={this.state.selectedSource} value={this.state.selectedSource}
> >
{Object.keys(this.props.options).map(function(source) { {Object.keys(this.props.options).map(function(source) {
return (<option key={source} value={source}>{source}</option>) return (<option key={source} value={source}>{this.prettyName(source)}</option>)
})} }, this)}
</FormControl> </FormControl>
</FormGroup> </FormGroup>
</div> </div>
@ -113,7 +119,7 @@ export default class ExplorerOptions extends React.Component {
value={this.state.selectedCategory} value={this.state.selectedCategory}
> >
{this.state.categories.map(function(category) { {this.state.categories.map(function(category) {
return (<option key={category} value={category}>{category}</option>) return (<option key={category} value={category}>{this.prettyName(category)}</option>)
}, this)} }, this)}
</FormControl> </FormControl>
</FormGroup> </FormGroup>