Skip to content

Commit 853fb37

Browse files
authored
Merge pull request #4473 from appirio-tech/feature/milestone-customer-approval
[DEV] Customer Approval
2 parents 8cab597 + 27059b9 commit 853fb37

File tree

25 files changed

+1128
-69
lines changed

25 files changed

+1128
-69
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ workflows:
188188
- build-dev
189189
filters: &filters-dev
190190
branches:
191-
only: ['dev', 'feature/new-milestone-concept']
191+
only: ['dev', 'feature/milestone-customer-approval']
192192

193193
- deployTest01:
194194
context : org-global

src/api/projects.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function getProjectPhases(projectId, query = {}) {
7878
const params = _.mapValues(query, (param) => encodeURIComponent(param))
7979

8080
return axios.get(`${PROJECTS_API_URL}/v5/projects/${projectId}/phases`, { params })
81-
.then(resp => resp.data)
81+
.then(resp => {console.log('resp.data', query, resp.data); return resp.data})
8282
}
8383

8484
/**
@@ -144,6 +144,21 @@ export function updatePhase(projectId, phaseId, updatedProps, phaseIndex) {
144144
})
145145
}
146146

147+
/**
148+
* Create phase apprvoal
149+
* @param {integer} projectId project Id
150+
* @param {integer} phaseId phase Id
151+
* @param {object} updatedProps updated phase properties
152+
* @param {integer} phaseIndex index of phase in phase list redux store
153+
* @return {promise} created phase approval
154+
*/
155+
export function createPhaseApproval(projectId, phaseId, updatedProps, phaseIndex) {
156+
return axios.post(`${PROJECTS_API_URL}/v5/projects/${projectId}/phases/${phaseId}/approvals`, updatedProps)
157+
.then(resp => {
158+
return _.extend(resp.data, {phaseIndex})
159+
})
160+
}
161+
147162
/**
148163
* Update product using patch
149164
*
Lines changed: 20 additions & 0 deletions
Loading
Lines changed: 28 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

src/config/constants.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ export const LOAD_PROJECT_PHASES = 'LOAD_PROJECT_PHASES'
318318
export const LOAD_PROJECT_PHASES_PENDING = 'LOAD_PROJECT_PHASES_PENDING'
319319
export const LOAD_PROJECT_PHASES_FAILURE = 'LOAD_PROJECT_PHASES_FAILURE'
320320
export const LOAD_PROJECT_PHASES_SUCCESS = 'LOAD_PROJECT_PHASES_SUCCESS'
321+
export const CUSTOMER_APPROVE_MILESTONE_PENDING = 'CUSTOMER_APPROVE_MILESTONE_PENDING'
322+
export const CUSTOMER_APPROVE_MILESTONE_FINISHED = 'CUSTOMER_APPROVE_MILESTONE_FINISHED'
323+
export const CUSTOMER_APPROVE_MILESTONE_SUCCESS = 'CUSTOMER_APPROVE_MILESTONE_SUCCESS'
324+
export const CUSTOMER_APPROVE_MILESTONE_FAILURE = 'CUSTOMER_APPROVE_MILESTONE_FAILURE'
325+
export const CUSTOMER_APPROVE_MILESTONE_APPROVE_SUCCESS = 'CUSTOMER_APPROVE_MILESTONE_APPROVE_SUCCESS'
326+
export const CUSTOMER_APPROVE_MILESTONE_APPROVE_FAILURE = 'CUSTOMER_APPROVE_MILESTONE_APPROVE_FAILURE'
327+
export const CUSTOMER_APPROVE_MILESTONE_REJECT_SUCCESS = 'CUSTOMER_APPROVE_MILESTONE_REJECT_SUCCESS'
328+
export const CUSTOMER_APPROVE_MILESTONE_REJECT_FAILURE = 'CUSTOMER_APPROVE_MILESTONE_REJECT_FAILURE'
321329

322330
export const LOAD_PRODUCT_TIMELINE_WITH_MILESTONES = 'LOAD_PRODUCT_TIMELINE_WITH_MILESTONES'
323331
export const LOAD_PRODUCT_TIMELINE_WITH_MILESTONES_PENDING = 'LOAD_PRODUCT_TIMELINE_WITH_MILESTONES_PENDING'
@@ -617,6 +625,9 @@ export const PHASE_STATUS_COMPLETED = 'completed'
617625
export const PHASE_STATUS_CANCELLED = 'cancelled'
618626
export const PHASE_STATUS_PAUSED = 'paused'
619627

628+
export const PHASE_APPROVAL_APPROVE = 'approve'
629+
export const PHASE_APPROVAL_REJECT = 'reject'
630+
620631
export const PROJECT_STATUS = [
621632
// {color: 'gray', name: 'Draft', fullName: 'Project is in draft', value: PROJECT_STATUS_DRAFT, order: 2, dropDownOrder: 1 },
622633
{color: 'gray', name: 'In review', fullName: 'Project is in review', value: PROJECT_STATUS_IN_REVIEW, order: 3, dropDownOrder: 2, isSpecial: true },

src/projects/actions/project.js

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getProjectById,
1010
getProjectPhases,
1111
updateProduct as updateProductAPI,
1212
updatePhase as updatePhaseAPI,
13+
createPhaseApproval as createPhaseApprovalAPI,
1314
createProjectPhase,
1415
createScopeChangeRequest as createScopeChangeRequestAPI,
1516
updateScopeChangeRequest as updateScopeChangeRequestAPI,
@@ -70,7 +71,15 @@ import {
7071
CREATE_PROJECT_PHASE_TIMELINE_MILESTONES,
7172
LOAD_PROJECT_MEMBER,
7273
ES_REINDEX_DELAY,
73-
CREATE_PROJECT_PHASE
74+
CREATE_PROJECT_PHASE,
75+
CUSTOMER_APPROVE_MILESTONE_SUCCESS,
76+
CUSTOMER_APPROVE_MILESTONE_FAILURE,
77+
CUSTOMER_APPROVE_MILESTONE_PENDING,
78+
CUSTOMER_APPROVE_MILESTONE_FINISHED,
79+
CUSTOMER_APPROVE_MILESTONE_APPROVE_SUCCESS,
80+
CUSTOMER_APPROVE_MILESTONE_REJECT_FAILURE,
81+
CUSTOMER_APPROVE_MILESTONE_APPROVE_FAILURE,
82+
CUSTOMER_APPROVE_MILESTONE_REJECT_SUCCESS
7483
} from '../../config/constants'
7584
import {
7685
updateProductMilestone,
@@ -191,6 +200,7 @@ function getProjectPhasesWithProducts(projectId) {
191200
'startDate',
192201
'status',
193202
'members',
203+
'approvals',
194204
'updatedAt',
195205
'updatedBy',
196206
].join(',')
@@ -506,6 +516,51 @@ export function activateScopeChange(projectId, scopeChangeRequestId) {
506516
}
507517

508518

519+
export function executePhaseApproval(projectId, phaseId, updatedProps, phaseIndex) {
520+
console.log('execute update phases 0')
521+
return (dispatch, getState) => {
522+
console.log('execute update phases')
523+
const state = getState()
524+
phaseIndex = phaseIndex ? phaseIndex : _.findIndex(state.projectState.phases, { id: phaseId })
525+
dispatch({type: CUSTOMER_APPROVE_MILESTONE_PENDING,
526+
payload: {phaseId}
527+
})
528+
return createPhaseApprovalAPI(projectId, phaseId, updatedProps, phaseIndex).then(() => {
529+
dispatch({type: CUSTOMER_APPROVE_MILESTONE_FINISHED,
530+
payload: {phaseId}
531+
})
532+
}).catch(() => {
533+
dispatch({type: CUSTOMER_APPROVE_MILESTONE_FINISHED,
534+
payload: {phaseId}
535+
})
536+
return Promise.reject(new Error('Fail to approve milestone'))
537+
})
538+
}
539+
}
540+
541+
/**
542+
* Dispatch alert message after individual or bulk milestone approval
543+
*
544+
* @param {Boolean} success is milestone updated successfully
545+
*
546+
* @return {Promise} phase
547+
*/
548+
export function approveMilestone(success = true, approvalType) {
549+
return (dispatch) => {
550+
let type = CUSTOMER_APPROVE_MILESTONE_FAILURE
551+
if (success) {
552+
if (approvalType === 'approve') type = CUSTOMER_APPROVE_MILESTONE_APPROVE_SUCCESS
553+
else if (approvalType === 'reject') type = CUSTOMER_APPROVE_MILESTONE_REJECT_SUCCESS
554+
else type = CUSTOMER_APPROVE_MILESTONE_SUCCESS
555+
dispatch({ type })
556+
} else {
557+
if (approvalType === 'approve') type = CUSTOMER_APPROVE_MILESTONE_APPROVE_FAILURE
558+
else if (approvalType === 'reject') type = CUSTOMER_APPROVE_MILESTONE_REJECT_FAILURE
559+
dispatch({ type })
560+
}
561+
}
562+
}
563+
509564
/**
510565
* Update phase info
511566
*

src/projects/detail/components/SimplePlan/CreateSimplePlan/CreateSimplePlan.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ManageMilestones from '../ManageMilestones'
99
import * as milestoneHelper from '../components/helpers/milestone'
1010

1111
import styles from './CreateSimplePlan.scss'
12+
import MilestonesApprovalNotification from '../components/MilestonesApprovalNotification'
1213

1314
const createTabs = ({ onClick } ) => ([
1415
{
@@ -34,10 +35,12 @@ class CreateSimplePlan extends React.Component {
3435
project,
3536
// phases,
3637
milestones,
38+
milestonesInApproval,
3739
onChangeMilestones,
3840
onSaveMilestone,
3941
onRemoveMilestone,
4042
onGetChallenges,
43+
onApproveMilestones,
4144
isProjectLive,
4245
isCustomer,
4346
} = this.props
@@ -64,17 +67,22 @@ class CreateSimplePlan extends React.Component {
6467
<div>
6568
{/* <ProjectDetailsWidget project={project} phases={phases} /> */}
6669
<div styleName="milestones-container">
70+
{!isCustomer && <MilestonesApprovalNotification milestones={milestones} />}
6771
<div styleName="tabs-header">
6872
<GenericMenu navLinks={createTabs(onClickMilestonesTab)} />
6973
</div>
7074
<ManageMilestones
7175
milestones={milestones}
76+
milestonesInApproval={milestonesInApproval}
7277
onGetChallenges={onGetChallenges}
7378
onChangeMilestones={onChangeMilestones}
7479
onSaveMilestone={onSaveMilestone}
7580
onRemoveMilestone={onRemoveMilestone}
81+
onApproveMilestones={onApproveMilestones}
7682
projectMembers={project.members}
83+
project={project}
7784
isUpdatable={isProjectLive && !isCustomer}
85+
isCustomer={isCustomer}
7886
/>
7987
</div>
8088
</div>
@@ -90,6 +98,7 @@ CreateSimplePlan.propTypes = {
9098
onSaveMilestone: PT.func,
9199
onRemoveMilestone: PT.func,
92100
onGetChallenges: PT.func,
101+
onApproveMilestones: PT.func,
93102
isCustomer: PT.bool,
94103
}
95104

0 commit comments

Comments
 (0)