@@ -4,13 +4,17 @@ import ProjectStatusChangeConfirmation from './ProjectStatusChangeConfirmation'
44import cn from 'classnames'
55import _ from 'lodash'
66import enhanceDropdown from 'appirio-tech-react-components/components/Dropdown/enhanceDropdown'
7+ import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip'
78import {
89 PROJECT_STATUS ,
910 PROJECT_STATUS_COMPLETED ,
1011 PROJECT_STATUS_CANCELLED ,
11- PROJECT_STATUS_DRAFT
12+ PROJECT_STATUS_DRAFT ,
13+ TOOLTIP_DEFAULT_DELAY
1214} from '../../config/constants'
1315import CarretDownNormal9px from '../../assets/icons/arrow-9px-carret-down-normal.svg'
16+ import { hasPermission } from '../../helpers/permissions'
17+ import { PERMISSIONS } from '../../config/permissions'
1418
1519
1620const hocStatusDropdown = ( CompositeComponent , statusList ) => {
@@ -55,24 +59,33 @@ const hocStatusDropdown = (CompositeComponent, statusList) => {
5559 < div className = "status-header" > Project Status</ div >
5660 < ul >
5761 {
58- statusList . sort ( ( a , b ) => a . order - b . order ) . map ( ( item ) =>
59- (
60- < div key = { item . value } className = "tooltip-target" >
61- < li >
62- < a
63- href = "javascript:"
64- className = { cn ( 'status-option' , 'status-' + item . value , { active : item . value === status , disabled : item . disabled } ) }
65- onClick = { ( e ) => {
66- if ( ! item . disabled )
67- onItemSelect ( item . value , e )
68- } }
69- >
70- < CompositeComponent status = { item } showText />
71- </ a >
72- </ li >
73- </ div >
62+ statusList . sort ( ( a , b ) => a . order - b . order ) . map ( ( item ) => {
63+ const selectItem = (
64+ < li key = { item . value } >
65+ < a
66+ href = "javascript:"
67+ className = { cn ( 'status-option' , 'status-' + item . value , { active : item . value === status , disabled : item . disabled } ) }
68+ onClick = { ( e ) => {
69+ if ( ! item . disabled )
70+ onItemSelect ( item . value , e )
71+ } }
72+ >
73+ < CompositeComponent status = { item } showText />
74+ </ a >
75+ </ li >
7476 )
75- )
77+
78+ return item . toolTipMessage ? (
79+ < Tooltip theme = "light" tooltipDelay = { TOOLTIP_DEFAULT_DELAY } key = { item . value } usePortal >
80+ < div className = "tooltip-target" >
81+ { selectItem }
82+ </ div >
83+ < div className = "tooltip-body" >
84+ { item . toolTipMessage }
85+ </ div >
86+ </ Tooltip >
87+ ) : selectItem
88+ } )
7689 }
7790 </ ul >
7891 </ div >
@@ -132,10 +145,29 @@ const editableProjectStatus = (CompositeComponent) => class extends Component {
132145 }
133146
134147 getProjectStatusDropdownValues ( status ) {
135- if ( status === PROJECT_STATUS_DRAFT ) {
136- return [ { color : 'gray' , name : 'Draft' , fullName : 'Project is in draft' , value : PROJECT_STATUS_DRAFT , order : 2 , dropDownOrder : 1 } ] . concat ( PROJECT_STATUS )
148+ const statusList = status === PROJECT_STATUS_DRAFT
149+ // if current status, is "Draft" which is deprecated, then show it on the list
150+ ? [ { color : 'gray' , name : 'Draft' , fullName : 'Project is in draft' , value : PROJECT_STATUS_DRAFT , order : 2 , dropDownOrder : 1 } ] . concat ( PROJECT_STATUS )
151+ // otherwise don't show deprecated status
152+ : PROJECT_STATUS
153+
154+ if ( hasPermission ( PERMISSIONS . EDIT_PROJECT_STATUS_TO_SPECIAL ) ) {
155+ return statusList
156+ } else {
157+ return statusList . map ( ( statusOption ) => {
158+ // if option is not special anyone can choose it
159+ // also, don't disable special option, if it's the current value
160+ if ( ! statusOption . isSpecial || statusOption . value === status ) {
161+ return statusOption
162+ }
163+
164+ return {
165+ ...statusOption ,
166+ disabled : true ,
167+ toolTipMessage : 'Only managers and admins can change to this status'
168+ }
169+ } )
137170 }
138- return PROJECT_STATUS
139171 }
140172
141173 render ( ) {
0 commit comments