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
11 changes: 2 additions & 9 deletions src/components/ProjectInfo/ProjectInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DeleteProjectModal from './DeleteProjectModal'
import ProjectCardBody from '../../projects/components/projectsCard/ProjectCardBody'
import MobileExpandable from '../MobileExpandable/MobileExpandable'
import MediaQuery from 'react-responsive'
import { SCREEN_BREAKPOINT_MD, PROJECT_STATUS_ACTIVE, PHASE_STATUS_ACTIVE, PHASE_STATUS_REVIEWED, PROJECT_ROLE_OWNER, PROJECT_ROLE_CUSTOMER } from '../../config/constants'
import { SCREEN_BREAKPOINT_MD, PROJECT_ROLE_OWNER, PROJECT_ROLE_CUSTOMER } from '../../config/constants'
import ReviewProjectButton from '../../projects/detail/components/ReviewProjectButton'
import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip'
import { TOOLTIP_DEFAULT_DELAY } from '../../config/constants'
Expand All @@ -24,17 +24,11 @@ class ProjectInfo extends Component {

render() {
const { project, currentMemberRole,
onChangeStatus, isSuperUser, phases, onSubmitForReview, isProjectProcessing,
onChangeStatus, isSuperUser, onSubmitForReview, isProjectProcessing,
showDeleteConfirm, toggleProjectDelete, onConfirmDelete, projectTemplates } = this.props

const code = _.get(project, 'details.utm.code', '')

const hasReviewedOrActivePhases = !!_.find(phases, (phase) => _.includes([PHASE_STATUS_REVIEWED, PHASE_STATUS_ACTIVE], phase.status))
const isProjectActive = project.status === PROJECT_STATUS_ACTIVE
const isV3Project = project.version === 'v3'
const projectCanBeActive = !isV3Project || (!isProjectActive && hasReviewedOrActivePhases) || isProjectActive


// prepare review button
const showReviewBtn = project.status === 'draft' &&
_.indexOf([PROJECT_ROLE_OWNER, PROJECT_ROLE_CUSTOMER], currentMemberRole) > -1
Expand Down Expand Up @@ -108,7 +102,6 @@ class ProjectInfo extends Component {
{matches => (
<ProjectCardBody
project={project}
projectCanBeActive={projectCanBeActive}
currentMemberRole={currentMemberRole}
descLinesCount={
/* has to be not too big value here,
Expand Down
16 changes: 0 additions & 16 deletions src/components/ProjectStatus/ProjectStatus.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,6 @@
&.active {
background: $tc-gray-10;
}

&.disabled {
cursor: default;

svg {
filter: grayscale(1);
}

span {
color: $tc-gray-30;
}

&:hover {
background: transparent;
}
}

svg {
margin-top: 7px;
Expand Down
45 changes: 6 additions & 39 deletions src/components/ProjectStatus/editableProjectStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ import ProjectStatusChangeConfirmation from './ProjectStatusChangeConfirmation'
import cn from 'classnames'
import _ from 'lodash'
import enhanceDropdown from 'appirio-tech-react-components/components/Dropdown/enhanceDropdown'
import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip'
import {
PROJECT_STATUS,
PROJECT_STATUS_ACTIVE,
PROJECT_STATUS_COMPLETED,
PROJECT_STATUS_CANCELLED,
TOOLTIP_DEFAULT_DELAY,
PROJECT_STATUS_DRAFT
} from '../../config/constants'
import CarretDownNormal9px from '../../assets/icons/arrow-9px-carret-down-normal.svg'


const hocStatusDropdown = (CompositeComponent, statusList, projectCanBeActive) => {
const hocStatusDropdown = (CompositeComponent, statusList) => {
class StatusDropdown extends Component {
shouldDropdownUp() {
if (this.refs.dropdown) {
Expand All @@ -36,12 +33,6 @@ const hocStatusDropdown = (CompositeComponent, statusList, projectCanBeActive) =
return null
}

const activestatusList = statusList.map((status) => ({
...status,
disabled: !projectCanBeActive && status.value === PROJECT_STATUS_ACTIVE,
toolTipMessage: (!projectCanBeActive && status.value === PROJECT_STATUS_ACTIVE) ? 'To activate project there should be at least one phase in "Planned" status. Please, check "Project Plan" tab.' : null,
}))

this.shouldDropdownUp()
return (
<div className="project-status-dropdown" ref="dropdown">
Expand All @@ -64,28 +55,8 @@ const hocStatusDropdown = (CompositeComponent, statusList, projectCanBeActive) =
<div className="status-header">Project Status</div>
<ul>
{
activestatusList.sort((a, b) => a.order - b.order).map((item) =>
item.toolTipMessage ? (
<Tooltip key={item.value} theme="light" tooltipDelay={TOOLTIP_DEFAULT_DELAY}>
<div className="tooltip-target">
<li>
<a
href="javascript:"
className={cn('status-option', 'status-' + item.value, { active: item.value === status, disabled: item.disabled })}
onClick={(e) => {
if (!item.disabled)
onItemSelect(item.value, e)
}}
>
<CompositeComponent status={item} showText />
</a>
</li>
</div>
<div className="tooltip-body">
{item.toolTipMessage}
</div>
</Tooltip>
) : (
statusList.sort((a, b) => a.order - b.order).map((item) =>
(
<div key={item.value} className="tooltip-target">
<li>
<a
Expand Down Expand Up @@ -169,11 +140,11 @@ const editableProjectStatus = (CompositeComponent) => class extends Component {

render() {
const { showStatusChangeDialog, newStatus, statusChangeReason } = this.state
const { canEdit, projectCanBeActive, status } = this.props
const { canEdit, status } = this.props
const PROJECT_STATUS_VALUES = this.getProjectStatusDropdownValues(status)
const StatusDropdown = canEdit
? enhanceDropdown(hocStatusDropdown(CompositeComponent, PROJECT_STATUS_VALUES, projectCanBeActive))
: hocStatusDropdown(CompositeComponent, PROJECT_STATUS_VALUES, projectCanBeActive)
? enhanceDropdown(hocStatusDropdown(CompositeComponent, PROJECT_STATUS_VALUES))
: hocStatusDropdown(CompositeComponent, PROJECT_STATUS_VALUES)
return (
<div className={cn('EditableProjectStatus', {'modal-active': showStatusChangeDialog})}>
<div className="modal-overlay" onClick={ this.hideStatusChangeDialog }/>
Expand All @@ -197,10 +168,6 @@ editableProjectStatus.propTypes = {
* Boolean flag to control editability of the project status. It does not render the dropdown if it is not editable.
*/
canEdit: PropTypes.bool,
/**
* Boolean flag to control if project status can be switched to active.
*/
projectCanBeActive: PropTypes.bool,
/**
* String representing project status
*/
Expand Down
4 changes: 1 addition & 3 deletions src/projects/components/projectsCard/ProjectCardBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import _ from 'lodash'

const EnhancedProjectStatus = editableProjectStatus(ProjectStatus)

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

Expand Down Expand Up @@ -57,7 +57,6 @@ function ProjectCardBody({ project, projectCanBeActive, currentMemberRole, descL
{(project.status !== PROJECT_STATUS_ACTIVE || progress === 0) &&
<EnhancedProjectStatus
status={project.status}
projectCanBeActive={projectCanBeActive}
showText
withoutLabel
currentMemberRole={currentMemberRole}
Expand All @@ -81,7 +80,6 @@ ProjectCardBody.defaultTypes = {

ProjectCardBody.propTypes = {
project: PT.object.isRequired,
projectCanBeActive: PT.bool,
currentMemberRole: PT.string,
showLink: PT.bool,
showLinkURL: PT.string,
Expand Down