@@ -10,7 +10,8 @@ import {
1010 PROJECT_STATUS_ACTIVE ,
1111 PROJECT_STATUS_COMPLETED ,
1212 PROJECT_STATUS_CANCELLED ,
13- TOOLTIP_DEFAULT_DELAY
13+ TOOLTIP_DEFAULT_DELAY ,
14+ PROJECT_STATUS_DRAFT
1415} from '../../config/constants'
1516import CarretDownNormal9px from '../../assets/icons/arrow-9px-carret-down-normal.svg'
1617
@@ -63,7 +64,7 @@ const hocStatusDropdown = (CompositeComponent, statusList, projectCanBeActive) =
6364 < div className = "status-header" > Project Status</ div >
6465 < ul >
6566 {
66- activestatusList . sort ( ( a , b ) => a . dropDownOrder > b . dropDownOrder ) . map ( ( item ) =>
67+ activestatusList . sort ( ( a , b ) => a . order - b . order ) . map ( ( item ) =>
6768 item . toolTipMessage ? (
6869 < Tooltip key = { item . value } theme = "light" tooltipDelay = { TOOLTIP_DEFAULT_DELAY } >
6970 < div className = "tooltip-target" >
@@ -121,6 +122,7 @@ const editableProjectStatus = (CompositeComponent) => class extends Component {
121122 this . showStatusChangeDialog = this . showStatusChangeDialog . bind ( this )
122123 this . changeStatus = this . changeStatus . bind ( this )
123124 this . handleReasonUpdate = this . handleReasonUpdate . bind ( this )
125+ this . getProjectStatusDropdownValues = this . getProjectStatusDropdownValues . bind ( this )
124126 }
125127
126128 componentWillReceiveProps ( ) {
@@ -158,12 +160,20 @@ const editableProjectStatus = (CompositeComponent) => class extends Component {
158160 this . setState ( { statusChangeReason : _ . get ( reason , 'value' ) } )
159161 }
160162
163+ getProjectStatusDropdownValues ( status ) {
164+ if ( status === PROJECT_STATUS_DRAFT ) {
165+ return [ { color : 'gray' , name : 'Draft' , fullName : 'Project is in draft' , value : PROJECT_STATUS_DRAFT , order : 2 , dropDownOrder : 1 } ] . concat ( PROJECT_STATUS )
166+ }
167+ return PROJECT_STATUS
168+ }
169+
161170 render ( ) {
162171 const { showStatusChangeDialog, newStatus, statusChangeReason } = this . state
163- const { canEdit, projectCanBeActive } = this . props
172+ const { canEdit, projectCanBeActive, status } = this . props
173+ const PROJECT_STATUS_VALUES = this . getProjectStatusDropdownValues ( status )
164174 const StatusDropdown = canEdit
165- ? enhanceDropdown ( hocStatusDropdown ( CompositeComponent , PROJECT_STATUS , projectCanBeActive ) )
166- : hocStatusDropdown ( CompositeComponent , PROJECT_STATUS , projectCanBeActive )
175+ ? enhanceDropdown ( hocStatusDropdown ( CompositeComponent , PROJECT_STATUS_VALUES , projectCanBeActive ) )
176+ : hocStatusDropdown ( CompositeComponent , PROJECT_STATUS_VALUES , projectCanBeActive )
167177 return (
168178 < div className = { cn ( 'EditableProjectStatus' , { 'modal-active' : showStatusChangeDialog } ) } >
169179 < div className = "modal-overlay" onClick = { this . hideStatusChangeDialog } />
@@ -190,7 +200,11 @@ editableProjectStatus.propTypes = {
190200 /**
191201 * Boolean flag to control if project status can be switched to active.
192202 */
193- projectCanBeActive : PropTypes . bool
203+ projectCanBeActive : PropTypes . bool ,
204+ /**
205+ * String representing project status
206+ */
207+ status : PropTypes . string
194208}
195209
196210export default editableProjectStatus
0 commit comments