44import React from 'react'
55import PT from 'prop-types'
66import _ from 'lodash'
7- import uncontrollable from 'uncontrollable'
87
98import { formatNumberWithCommas } from '../../../helpers/format'
109import { getPhaseActualData } from '../../../helpers/projectHelper'
@@ -93,6 +92,7 @@ class ProjectStage extends React.Component{
9392 this . removeProductAttachment = this . removeProductAttachment . bind ( this )
9493 this . updateProductAttachment = this . updateProductAttachment . bind ( this )
9594 this . addProductAttachment = this . addProductAttachment . bind ( this )
95+ this . onTabClick = this . onTabClick . bind ( this )
9696 }
9797
9898 removeProductAttachment ( attachmentId ) {
@@ -116,9 +116,14 @@ class ProjectStage extends React.Component{
116116 addProductAttachment ( project . id , phase . id , product . id , attachment )
117117 }
118118
119+ onTabClick ( tab ) {
120+ const { expandProjectPhase, phase } = this . props
121+
122+ expandProjectPhase ( phase . id , tab )
123+ }
124+
119125 render ( ) {
120126 const {
121- activeTab,
122127 phase,
123128 phaseIndex,
124129 project,
@@ -130,8 +135,10 @@ class ProjectStage extends React.Component{
130135 updateProduct,
131136 fireProductDirty,
132137 fireProductDirtyUndo,
133- onTabClick,
134138 deleteProjectPhase,
139+ phaseState,
140+ collapseProjectPhase,
141+ expandProjectPhase,
135142
136143 // comes from phaseFeedHOC
137144 currentUser,
@@ -156,7 +163,7 @@ class ProjectStage extends React.Component{
156163
157164 const hasTimeline = ! ! timeline
158165 const defaultActiveTab = hasTimeline ? 'timeline' : 'posts'
159- const currentActiveTab = activeTab ? activeTab : defaultActiveTab
166+ const currentActiveTab = _ . get ( phaseState , 'tab' , defaultActiveTab )
160167 const postNotifications = filterNotificationsByPosts ( notifications , _ . get ( feed , 'posts' , [ ] ) )
161168 const unreadPostNotifications = filterReadNotifications ( postNotifications )
162169 const hasReadPosts = unreadPostNotifications . length > 0
@@ -169,11 +176,15 @@ class ProjectStage extends React.Component{
169176 deleteProjectPhase = { ( ) => deleteProjectPhase ( project . id , phase . id ) }
170177 timeline = { timeline }
171178 hasReadPosts = { hasReadPosts }
179+ phaseId = { phase . id }
180+ isExpanded = { _ . get ( phaseState , 'isExpanded' ) }
181+ collapseProjectPhase = { collapseProjectPhase }
182+ expandProjectPhase = { expandProjectPhase }
172183 >
173184 < div >
174185 < ProjectStageTabs
175186 activeTab = { currentActiveTab }
176- onTabClick = { onTabClick }
187+ onTabClick = { this . onTabClick }
177188 isSuperUser = { isSuperUser }
178189 isManageUser = { isManageUser }
179190 hasTimeline = { hasTimeline }
@@ -225,13 +236,10 @@ class ProjectStage extends React.Component{
225236}
226237
227238ProjectStage . defaultProps = {
228- activeTab : '' ,
229239 currentMemberRole : null ,
230240}
231241
232242ProjectStage . propTypes = {
233- activeTab : PT . string ,
234- onTabClick : PT . func . isRequired ,
235243 project : PT . object . isRequired ,
236244 currentMemberRole : PT . string ,
237245 isProcessing : PT . bool . isRequired ,
@@ -245,8 +253,4 @@ ProjectStage.propTypes = {
245253 deleteProjectPhase : PT . func . isRequired ,
246254}
247255
248- const ProjectStageUncontrollable = uncontrollable ( ProjectStage , {
249- activeTab : 'onTabClick' ,
250- } )
251-
252- export default phaseFeedHOC ( ProjectStageUncontrollable )
256+ export default phaseFeedHOC ( ProjectStage )
0 commit comments