Files
old-tellall/web/src/components/IntentList.js

42 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-11-30 17:43:24 +01:00
import React, { Component } from 'react';
2017-12-01 11:03:48 +01:00
import {Button} from 'react-md';
import IntentItem from './IntentItem';
2017-11-30 17:43:24 +01:00
import '../css/Intent.css'
class IntentList extends Component {
constructor (props){
super(props);
2017-12-01 11:03:48 +01:00
this.state = {intents: props.allIntents, selectedIndex:props.selectedIndex, onIntentClick:props.onIntentClick};
2017-11-30 17:43:24 +01:00
}
componentWillReceiveProps(props){
2017-12-01 11:03:48 +01:00
this.setState({intents: props.allIntents, selectedIndex: props.selectedIndex, onIntentClick: props.onIntentClick});
2017-11-30 17:43:24 +01:00
}
render() {
return (
<div className="IntentList">
<Button className={this.props.selectedIndex===-2 ? "LaunchRequest-selected" : "LaunchRequest"} flat primary
onClick={this.props.onLaunchRequestClick}>Launch request</Button>
2017-11-30 17:43:24 +01:00
<div className="IntentList-title">
2017-12-01 11:03:48 +01:00
<h3>Intents</h3>
2017-11-30 17:43:24 +01:00
</div>
{
this.state.intents.map((intent,index)=>{
2017-12-01 11:03:48 +01:00
return <IntentItem
2017-11-30 17:43:24 +01:00
key={index} intent={intent} index={index}
2017-12-01 11:03:48 +01:00
selectedIndex={this.props.selectedIndex}
2017-11-30 17:43:24 +01:00
onClick={this.state.onIntentClick}>
2017-12-01 11:03:48 +01:00
</IntentItem>
2017-11-30 17:43:24 +01:00
})
}
<br></br>
<Button className={"AddIntent"} flat primary swapTheming onClick={this.props.onAddIntentClick}>Add intent</Button>
2017-11-30 17:43:24 +01:00
</div>
);
}
}
export default IntentList;