add topic following for internal testing
This commit is contained in:
parent
9df389060e
commit
55b031ccb7
4 changed files with 49 additions and 1 deletions
|
@ -3139,3 +3139,13 @@ script.data-gratipay-username {
|
||||||
.inline {
|
.inline {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.topicFollow {
|
||||||
|
text-align: center;
|
||||||
|
height: 48px;
|
||||||
|
line-height: 48px;
|
||||||
|
border-top: 1px solid #BDBDBD;
|
||||||
|
background: #FFF;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: din-regular;
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import ReactDOM from 'react-dom'
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import Visualize from '../Visualize'
|
import Visualize from '../Visualize'
|
||||||
|
import GlobalUI from '../GlobalUI'
|
||||||
|
|
||||||
import ReactTopicCard from '../../components/TopicCard'
|
import ReactTopicCard from '../../components/TopicCard'
|
||||||
|
|
||||||
|
@ -24,6 +25,20 @@ const TopicCard = {
|
||||||
updateTopic: obj => {
|
updateTopic: obj => {
|
||||||
topic.save(obj, { success: topic => self.populateShowCard(topic) })
|
topic.save(obj, { success: topic => self.populateShowCard(topic) })
|
||||||
},
|
},
|
||||||
|
onFollow: () => {
|
||||||
|
const isFollowing = topic.isFollowedBy(Active.Mapper)
|
||||||
|
$.post({
|
||||||
|
url: `/topics/${topic.id}/${isFollowing ? 'un' : ''}follow`
|
||||||
|
})
|
||||||
|
if (isFollowing) {
|
||||||
|
GlobalUI.notifyUser('You are no longer following this topic')
|
||||||
|
Active.Mapper.unfollowTopic(topic.id)
|
||||||
|
} else {
|
||||||
|
GlobalUI.notifyUser('You are now following this topic')
|
||||||
|
Active.Mapper.followTopic(topic.id)
|
||||||
|
}
|
||||||
|
self.populateShowCard(topic)
|
||||||
|
},
|
||||||
metacodeSets: self.metacodeSets,
|
metacodeSets: self.metacodeSets,
|
||||||
redrawCanvas: () => {
|
redrawCanvas: () => {
|
||||||
Visualize.mGraph.plot()
|
Visualize.mGraph.plot()
|
||||||
|
|
17
frontend/src/components/TopicCard/Follow.js
Normal file
17
frontend/src/components/TopicCard/Follow.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import React, { PropTypes, Component } from 'react'
|
||||||
|
|
||||||
|
class Follow extends Component {
|
||||||
|
render = () => {
|
||||||
|
const { isFollowing, onFollow } = this.props
|
||||||
|
return <div className='topicFollow' onClick={onFollow}>
|
||||||
|
{isFollowing ? 'Unfollow' : 'Follow'}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Follow.propTypes = {
|
||||||
|
isFollowing: PropTypes.bool,
|
||||||
|
onFollow: PropTypes.func
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Follow
|
|
@ -4,11 +4,15 @@ import Title from './Title'
|
||||||
import Links from './Links'
|
import Links from './Links'
|
||||||
import Desc from './Desc'
|
import Desc from './Desc'
|
||||||
import Attachments from './Attachments'
|
import Attachments from './Attachments'
|
||||||
|
import Follow from './Follow'
|
||||||
|
import Util from '../../Metamaps/Util'
|
||||||
|
|
||||||
|
|
||||||
class ReactTopicCard extends Component {
|
class ReactTopicCard extends Component {
|
||||||
render = () => {
|
render = () => {
|
||||||
const { topic, ActiveMapper } = this.props
|
const { topic, ActiveMapper, onFollow } = this.props
|
||||||
const authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
const authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
||||||
|
const isFollowing = topic.isFollowedBy(ActiveMapper)
|
||||||
const hasAttachment = topic.get('link') && topic.get('link') !== ''
|
const hasAttachment = topic.get('link') && topic.get('link') !== ''
|
||||||
|
|
||||||
let classname = 'permission'
|
let classname = 'permission'
|
||||||
|
@ -40,6 +44,7 @@ class ReactTopicCard extends Component {
|
||||||
authorizedToEdit={authorizedToEdit}
|
authorizedToEdit={authorizedToEdit}
|
||||||
updateTopic={this.props.updateTopic}
|
updateTopic={this.props.updateTopic}
|
||||||
/>
|
/>
|
||||||
|
{Util.isTester(ActiveMapper) && <Follow isFollowing={isFollowing} onFollow={onFollow} />}
|
||||||
<div className="clearfloat"></div>
|
<div className="clearfloat"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -51,6 +56,7 @@ ReactTopicCard.propTypes = {
|
||||||
topic: PropTypes.object,
|
topic: PropTypes.object,
|
||||||
ActiveMapper: PropTypes.object,
|
ActiveMapper: PropTypes.object,
|
||||||
updateTopic: PropTypes.func,
|
updateTopic: PropTypes.func,
|
||||||
|
onFollow: PropTypes.func,
|
||||||
metacodeSets: PropTypes.arrayOf(PropTypes.shape({
|
metacodeSets: PropTypes.arrayOf(PropTypes.shape({
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
metacodes: PropTypes.arrayOf(PropTypes.shape({
|
metacodes: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
|
Loading…
Add table
Reference in a new issue