Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/projects/components/projectsCard/ProjectCardBody.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PT from 'prop-types'
import TextTruncate from 'react-text-truncate'
import { Link } from 'react-router-dom'
import { withRouter } from 'react-router-dom'
import ProjectStatus from '../../../components/ProjectStatus/ProjectStatus'
import editableProjectStatus from '../../../components/ProjectStatus/editableProjectStatus'
import {
Expand All @@ -17,7 +17,7 @@ import _ from 'lodash'
const EnhancedProjectStatus = editableProjectStatus(ProjectStatus)

function ProjectCardBody({ project, projectCanBeActive, currentMemberRole, descLinesCount = 8,
onChangeStatus, isSuperUser, showLink, showLinkURL, canEditStatus = true, hideStatus }) {
onChangeStatus, isSuperUser, showLink, showLinkURL, canEditStatus = true, hideStatus, history }) {
if (!project) return null

const canEdit = canEditStatus && (
Expand All @@ -31,6 +31,13 @@ function ProjectCardBody({ project, projectCanBeActive, currentMemberRole, descL
], currentMemberRole) > -1)))
)

const goToProjectDetails = (evt, showLinkURL, projectDetailsURL) => {
evt.stopPropagation()
evt.preventDefault()
evt.nativeEvent.stopImmediatePropagation()
history.push(showLinkURL || projectDetailsURL)
}

const progress = _.get(process, 'percent', 0)

const projectDetailsURL = project.version === 'v3'
Expand All @@ -44,7 +51,7 @@ function ProjectCardBody({ project, projectCanBeActive, currentMemberRole, descL
line={descLinesCount}
truncateText="..."
text={_.unescape(project.description)}
textTruncateChild={showLink ? <Link className="read-more-link" to={showLinkURL || projectDetailsURL}>read more</Link> : <span className="read-more-link">read more</span>}
textTruncateChild={showLink ? <span className="read-more-link" onClick={(evt) => { goToProjectDetails(evt, showLinkURL, projectDetailsURL) }}>read more</span> : <span className="read-more-link">read more</span>}
/>
{!hideStatus && <div className="project-status">
{(project.status !== PROJECT_STATUS_ACTIVE || progress === 0) &&
Expand Down Expand Up @@ -82,4 +89,4 @@ ProjectCardBody.propTypes = {
hideStatus: PT.bool
}

export default ProjectCardBody
export default withRouter(ProjectCardBody)
1 change: 1 addition & 0 deletions src/projects/components/projectsCard/ProjectCardBody.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.read-more-link {
white-space: nowrap;
color: $tc-dark-blue;
cursor: pointer;
}
}

Expand Down