metamaps--metamaps/frontend/src/components/TopicCard/index.js
Connor Turland 47a74dd77b react-router and rebuild app structure in react (#1091)
* initial restructuring

* stuff

* lock version number

* just keep using current mapinfobox

* fix map upperRightUI layout

* make mapsWidth work and add mobile

* remove filterBoxOpen for now

* redo the mobile menu in react

* get account menu and invite lightbox working

* fixed maps scrolling

* make other routes work

* fix signed out home page

* fix accountbox toggling

* add metacode edit routes

* lots of fixes

* fix map chat layout and tab bug

* improve topic card readability and fix dragging bug

* fixup mapchat stuff

* fix up navigation to use react-router

* jquery no longer handling access requests

* handle case where user hasn't loaded yet

* this shouldn't have been removed

* add frame for topic view

* rewrite map instructions

* fix toast (and sign out bug)

* fix apps pages and missing routes

* made our request invite page look nice

* filter box in react

* forgot to add one proptype

* remove extra comments

* handle page title and mobile title updates

* reenable google analytics

* make filterbox use onclickoutside

* reenable topic view in react

* fix csrf auth token

* fix little homepage styling issue

* try putting preparevizdata in a timeout

* installing render log to count

* little fixes

* fixup filters

* make filter map function names more readable

* eslint helps

* renaming for clarity

* use onclickoutside for account/sign in box

* add some logging to see whether this is source of many renders

* turns out chatview was heavily hogging memory

* tiimeout not needed
2017-03-16 17:58:56 -04:00

80 lines
2.5 KiB
JavaScript

import React, { PropTypes, Component } from 'react'
import Title from './Title'
import Links from './Links'
import Desc from './Desc'
import Attachments from './Attachments'
import Follow from './Follow'
import Util from '../../Metamaps/Util'
class ReactTopicCard extends Component {
render = () => {
const { currentUser, onTopicFollow, updateTopic } = this.props
const topic = this.props.openTopic
if (!topic) return null
const wrappedUpdateTopic = obj => updateTopic(topic, obj)
const wrappedTopicFollow = () => onTopicFollow(topic)
const authorizedToEdit = topic.authorizeToEdit(currentUser)
const isFollowing = topic.isFollowedBy(currentUser)
const hasAttachment = topic.get('link') && topic.get('link') !== ''
let classname = 'permission'
if (authorizedToEdit) {
classname += ' canEdit'
} else {
classname += ' cannotEdit'
}
if (topic.authorizePermissionChange(currentUser)) classname += ' yourTopic'
return (
<div className="showcard mapElement mapElementHidden" id="showcard">
<div className={classname}>
<div className={`CardOnGraph ${hasAttachment ? 'hasAttachment' : ''}`} id={`topic_${topic.id}`}>
<Title name={topic.get('name')}
authorizedToEdit={authorizedToEdit}
onChange={wrappedUpdateTopic}
/>
<Links topic={topic}
ActiveMapper={this.props.currentUser}
updateTopic={wrappedUpdateTopic}
metacodeSets={this.props.metacodeSets}
redrawCanvas={this.props.redrawCanvas}
/>
<Desc desc={topic.get('desc')}
authorizedToEdit={authorizedToEdit}
onChange={wrappedUpdateTopic}
/>
<Attachments topic={topic}
authorizedToEdit={authorizedToEdit}
updateTopic={wrappedUpdateTopic}
/>
{Util.isTester(currentUser) && <Follow isFollowing={isFollowing} onTopicFollow={wrappedTopicFollow} />}
<div className="clearfloat"></div>
</div>
</div>
</div>
)
}
}
ReactTopicCard.propTypes = {
openTopic: PropTypes.object,
currentUser: PropTypes.object,
updateTopic: PropTypes.func,
onTopicFollow: PropTypes.func,
metacodeSets: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string,
metacodes: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.number,
icon_path: PropTypes.string, // url
name: PropTypes.string
}))
})),
redrawCanvas: PropTypes.func
}
export default ReactTopicCard