metamaps--metamaps/frontend/src/components/TopicCard/index.js

52 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-01-13 00:45:21 -05:00
import React, { PropTypes, Component } from 'react'
import Title from './Title'
import Links from './Links'
2017-01-25 15:49:11 -05:00
import Desc from './Desc'
import Attachments from './Attachments'
2017-01-25 15:49:11 -05:00
2017-01-13 00:45:21 -05:00
class ReactTopicCard extends Component {
render = () => {
const { topic, ActiveMapper } = this.props
2017-01-13 00:45:21 -05:00
var authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
2017-01-25 17:03:30 -05:00
const hasAttachment = topic.get('link') && topic.get('link') !== ''
const topicId = topic.isNew() ? topic.cid : topic.id // TODO should we be using cid here???
2017-01-24 17:25:28 -05:00
2017-01-13 00:45:21 -05:00
let classname = 'permission'
2017-01-24 17:25:28 -05:00
if (authorizedToEdit) {
classname += ' canEdit'
} else {
classname += ' cannotEdit'
}
2017-01-13 00:45:21 -05:00
if (topic.authorizePermissionChange(ActiveMapper)) classname += ' yourTopic'
return (
<div className={classname}>
<div className={`CardOnGraph ${hasAttachment ? 'hasAttachment' : ''}`} id={`topic_${topicId}`}>
<Title name={topic.get('name')} onChange={this.props.updateTopic} />
2017-01-25 17:03:30 -05:00
<Links topic={topic}
ActiveMapper={this.props.ActiveMapper}
/>
2017-01-25 15:49:11 -05:00
<Desc desc={topic.get('desc')}
authorizedToEdit={topic.authorizeToEdit(ActiveMapper)}
onChange={this.props.updateTopic}
/>
<Attachments topic={this.props.topic}
ActiveMapper={this.props.ActiveMapper}
updateTopic={this.props.updateTopic}
/>
2017-01-13 00:45:21 -05:00
<div className="clearfloat"></div>
</div>
</div>
)
}
}
2017-01-13 00:45:21 -05:00
ReactTopicCard.propTypes = {
topic: PropTypes.object,
ActiveMapper: PropTypes.object,
updateTopic: PropTypes.func
2017-01-13 00:45:21 -05:00
}
export default ReactTopicCard