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

55 lines
2.1 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'
2018-01-11 04:24:16 +01:00
import {
LAUNCH_REQUEST_SELECTED_INDEX,
CONTACT_SELECTED_INDEX} from '../config'
2017-11-30 17:43:24 +01:00
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">
2018-01-11 04:24:16 +01:00
<Button className={this.props.selectedIndex===LAUNCH_REQUEST_SELECTED_INDEX ? "LaunchRequest-selected" : "LaunchRequest"} flat primary
onClick={this.props.onLaunchRequestClick}
disabled={this.props.waiting} >Launch request</Button>
2018-01-11 04:24:16 +01:00
<Button className={this.props.selectedIndex===CONTACT_SELECTED_INDEX ? "Contact-selected" : "Contact"} flat primary
onClick={this.props.onContactClick}
disabled={this.props.waiting} >Contact</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
key={intent.intentName} intent={intent} index={index}
2017-12-01 11:03:48 +01:00
selectedIndex={this.props.selectedIndex}
onClick={this.state.onIntentClick}
waiting={this.props.waiting}>
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}
disabled={this.props.waiting}>Add intent</Button>
2017-11-30 17:43:24 +01:00
</div>
);
}
}
export default IntentList;