11import React from 'react'
22import PT from 'prop-types'
33import TextTruncate from 'react-text-truncate'
4- import { Link } from 'react-router-dom'
4+ import { withRouter } from 'react-router-dom'
55import ProjectStatus from '../../../components/ProjectStatus/ProjectStatus'
66import editableProjectStatus from '../../../components/ProjectStatus/editableProjectStatus'
77import {
@@ -17,7 +17,7 @@ import _ from 'lodash'
1717const EnhancedProjectStatus = editableProjectStatus ( ProjectStatus )
1818
1919function ProjectCardBody ( { project, projectCanBeActive, currentMemberRole, descLinesCount = 8 ,
20- onChangeStatus, isSuperUser, showLink, showLinkURL, canEditStatus = true , hideStatus } ) {
20+ onChangeStatus, isSuperUser, showLink, showLinkURL, canEditStatus = true , hideStatus, history } ) {
2121 if ( ! project ) return null
2222
2323 const canEdit = canEditStatus && (
@@ -31,6 +31,13 @@ function ProjectCardBody({ project, projectCanBeActive, currentMemberRole, descL
3131 ] , currentMemberRole ) > - 1 ) ) )
3232 )
3333
34+ const goToProjectDetails = ( evt , showLinkURL , projectDetailsURL ) => {
35+ evt . stopPropagation ( )
36+ evt . preventDefault ( )
37+ evt . nativeEvent . stopImmediatePropagation ( )
38+ history . push ( showLinkURL || projectDetailsURL )
39+ }
40+
3441 const progress = _ . get ( process , 'percent' , 0 )
3542
3643 const projectDetailsURL = project . version === 'v3'
@@ -44,7 +51,7 @@ function ProjectCardBody({ project, projectCanBeActive, currentMemberRole, descL
4451 line = { descLinesCount }
4552 truncateText = "..."
4653 text = { _ . unescape ( project . description ) }
47- textTruncateChild = { showLink ? < Link className = "read-more-link" to = { showLinkURL || projectDetailsURL } > read more</ Link > : < span className = "read-more-link" > read more</ span > }
54+ textTruncateChild = { showLink ? < span className = "read-more-link" onClick = { ( evt ) => { goToProjectDetails ( evt , showLinkURL , projectDetailsURL ) } } > read more</ span > : < span className = "read-more-link" > read more</ span > }
4855 />
4956 { ! hideStatus && < div className = "project-status" >
5057 { ( project . status !== PROJECT_STATUS_ACTIVE || progress === 0 ) &&
@@ -82,4 +89,4 @@ ProjectCardBody.propTypes = {
8289 hideStatus : PT . bool
8390}
8491
85- export default ProjectCardBody
92+ export default withRouter ( ProjectCardBody )
0 commit comments