import React, { Component, PropTypes } from 'react' import { find, values } from 'lodash' const IN_CONVERSATION = 1 // shared with /realtime/reducer.js const MapperList = (props) => { } class MapCard extends Component { render = () => { const { map, juntoState, currentUser } = this.props const hasMap = juntoState.liveMaps[map.id] const hasConversation = hasMap && find(values(hasMap), v => v === IN_CONVERSATION) const hasMapper = hasMap && !hasConversation function capitalize (string) { return string.charAt(0).toUpperCase() + string.slice(1) } const n = map.get('name') const d = map.get('desc') const maxNameLength = 32 const maxDescLength = 236 const truncatedName = n ? (n.length > maxNameLength ? n.substring(0, maxNameLength) + '...' : n) : '' const truncatedDesc = d ? (d.length > maxDescLength ? d.substring(0, maxDescLength) + '...' : d) : '' const editPermission = map.authorizeToEdit(currentUser) ? 'canEdit' : 'cannotEdit' return (
{ truncatedName }
{ map.get('user_name') }
{ map.get('contributor_count') }
{ map.get('contributor_count') === 1 ? 'contributor' : 'contributors' }
{ map.get('topic_count') }
{ map.get('topic_count') === 1 ? 'topic' : 'topics' }
{ map.get('star_count') }
{ map.get('star_count') === 1 ? 'star' : 'stars' }
{ map.get('synapse_count') }
{ map.get('synapse_count') === 1 ? 'synapse' : 'synapses' }
{ truncatedDesc }
{ hasMapper &&
} { hasConversation &&
}
) } } MapCard.propTypes = { map: PropTypes.object.isRequired, juntoState: PropTypes.object, currentUser: PropTypes.object } export default MapCard