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
37 changes: 16 additions & 21 deletions src/projects/list/components/Projects/ProjectCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,32 @@ import { getProjectRoleForCurrentUser } from '../../../../helpers/projectHelper'
import ProjectCardHeader from './ProjectCardHeader'
import ProjectCardBody from './ProjectCardBody'
import ProjectManagerAvatars from './ProjectManagerAvatars'
import MediaQuery from 'react-responsive'
import { SCREEN_BREAKPOINT_MD } from '../../../../config/constants'
import './ProjectCard.scss'

function ProjectCard({ project, duration, disabled, currentUser, history, onChangeStatus}) {
const className = `ProjectCard ${ disabled ? 'disabled' : 'enabled'}`
if (!project) return null
const currentMemberRole = getProjectRoleForCurrentUser({ project, currentUserId: currentUser.userId})
return (
<div className={className}>
<div
className={className}
onClick={() => {
history.push(`/projects/${project.id}/`)
}}
>
<div className="card-header">
<ProjectCardHeader
project={project}
onClick={() => {
history.push(`/projects/${project.id}/`)
}}
/>
<ProjectCardHeader project={project} />
</div>
<div className="card-body">
<MediaQuery minWidth={SCREEN_BREAKPOINT_MD}>
{(matches) => (
<ProjectCardBody
project={project}
currentMemberRole={currentMemberRole}
duration={duration}
onChangeStatus={onChangeStatus}
showLink
showLinkURL={matches ? `/projects/${project.id}/specification` : `/projects/${project.id}`}
/>
)}
</MediaQuery>
<ProjectCardBody
project={project}
currentMemberRole={currentMemberRole}
duration={duration}
onChangeStatus={onChangeStatus}
showLink
showLinkURL={`/projects/${project.id}/specification`}
canEditStatus={false}
/>
</div>
<div className="card-footer">
<ProjectManagerAvatars managers={project.members} maxShownNum={10} />
Expand Down
2 changes: 1 addition & 1 deletion src/projects/list/components/Projects/ProjectCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:global {
.ProjectCard {
position: relative;
cursor: pointer;
display: flex;
flex-direction: column;
height: 100%;
Expand Down Expand Up @@ -65,7 +66,6 @@
}

.card-header {
cursor: pointer;
margin-bottom: 4 * $base_unit;

@media screen and (max-width: $screen-md - 1px) {
Expand Down
12 changes: 8 additions & 4 deletions src/projects/list/components/Projects/ProjectCardBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import _ from 'lodash'
const EnhancedProjectStatus = editableProjectStatus(ProjectStatus)

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

const canEdit = project.status !== PROJECT_STATUS_COMPLETED && (isSuperUser || (currentMemberRole
const canEdit = canEditStatus && (
project.status !== PROJECT_STATUS_COMPLETED && (isSuperUser || (currentMemberRole
&& (_.indexOf([PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER], currentMemberRole) > -1)))
)

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

Expand Down Expand Up @@ -54,15 +56,17 @@ function ProjectCardBody({ project, duration, currentMemberRole, descLinesCount

ProjectCardBody.defaultTypes = {
showLink: false,
showLinkURL: ''
showLinkURL: '',
canEditStatus: true
}

ProjectCardBody.propTypes = {
project: PT.object.isRequired,
currentMemberRole: PT.string,
duration: PT.object.isRequired,
showLink: PT.bool,
showLinkURL: PT.string
showLinkURL: PT.string,
canEditStatus: PT.bool
}

export default ProjectCardBody