Skip to content

Commit 3844266

Browse files
author
vikasrohit
authored
Merge pull request #4365 from appirio-tech/dev
Prod Release - Project plan simplification
2 parents 202ec5a + 428ea10 commit 3844266

File tree

26 files changed

+356
-142
lines changed

26 files changed

+356
-142
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ workflows:
128128
- build-dev
129129
filters:
130130
branches:
131-
only: ['dev', 'feature/add_msg_for_taas_projects']
131+
only: ['dev', 'feature/project-plan-simplification-0']
132132

133133
- deployTest01:
134134
context : org-global

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/constants.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ export const CREATE_TIMELINE_MILESTONE_SUCCESS = 'CREATE_TIMELINE_MILESTONE_SUCC
9696
export const CREATE_TIMELINE_MILESTONE_FAILURE = 'CREATE_TIMELINE_MILESTONE_FAILURE'
9797
export const CREATE_TIMELINE_MILESTONE_PENDING = 'CREATE_TIMELINE_MILESTONE_PENDING'
9898

99+
// project phases
100+
export const CREATE_PROJECT_PHASE = 'CREATE_PROJECT_PHASE'
101+
export const CREATE_PROJECT_PHASE_FAILURE = 'CREATE_PROJECT_PHASE_FAILURE'
102+
export const CREATE_PROJECT_PHASE_SUCCESS = 'CREATE_PROJECT_PHASE_SUCCESS'
103+
export const CREATE_PROJECT_PHASE_PENDING = 'CREATE_PROJECT_PHASE_PENDING'
104+
99105
// project phases and timeline and milestones
100106
export const CREATE_PROJECT_PHASE_TIMELINE_MILESTONES = 'CREATE_PROJECT_PHASE_TIMELINE_MILESTONES'
101107
export const CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_FAILURE = 'CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_FAILURE'
@@ -613,7 +619,7 @@ export const PHASE_STATUS = [
613619
{color: 'gray', name: 'Draft', fullName: 'Phase is in draft', value: PHASE_STATUS_DRAFT, order: 2, dropDownOrder: 1 },
614620
// {color: 'gray', name: 'In review', fullName: 'Phase is in review', value: PHASE_STATUS_IN_REVIEW, order: 3, dropDownOrder: 2 },
615621
{color: 'gray', name: 'Planned', fullName: 'Phase is reviewed', value: PHASE_STATUS_REVIEWED, order: 4, dropDownOrder: 3 },
616-
{color: 'green', name: 'Active', fullName: 'Phase is active', value: PHASE_STATUS_ACTIVE, order: 1, dropDownOrder: 4 },
622+
{color: 'green', name: 'Published', fullName: 'Phase is active', value: PHASE_STATUS_ACTIVE, order: 1, dropDownOrder: 4 },
617623
{color: 'black', name: 'Completed', fullName: 'Phase is completed', value: PHASE_STATUS_COMPLETED, order: 5, dropDownOrder: 5 },
618624
// {color: 'black', name: 'Cancelled', fullName: 'Phase is canceled', value: PHASE_STATUS_CANCELLED, order: 6, dropDownOrder: 6 },
619625
// {color: 'red', name: 'Paused', fullName: 'Phase is paused', value: PHASE_STATUS_PAUSED, order: 7, dropDownOrder: 7 }

src/config/permissions.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@ export const PERMISSIONS = {
199199
],
200200
},
201201

202+
SHOW_PHASE_STATUS: {
203+
meta: {
204+
group: 'Project Plan',
205+
title: 'Show project phase status',
206+
},
207+
projectRoles: [
208+
..._.difference(PROJECT_ALL, [PROJECT_ROLE_CUSTOMER])
209+
],
210+
topcoderRoles: [
211+
ROLE_CONNECT_MANAGER,
212+
...TOPCODER_ADMINS,
213+
],
214+
},
215+
202216
/*
203217
Project Members
204218
*/

src/helpers/projectHelper.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,20 @@ export function getPhaseActualData(phase, timeline) {
158158
duration = phase.duration ? phase.duration : 0
159159
progress = phase.progress ? phase.progress : 0
160160

161-
if (startDate) {
161+
// if start date and duration are set, use them to calculate endDate
162+
if (!endDate && startDate && duration > 0) {
162163
endDate = startDate.clone().add(duration, 'days')
163-
} else {
164+
}
165+
// default to today if start date not set
166+
if (!startDate) {
164167
startDate = moment().hours(0).minutes(0).seconds(0).milliseconds(0)
165168
}
169+
// default to today if end date not set
166170
if (!endDate) {
167171
endDate = moment().hours(0).minutes(0).seconds(0).milliseconds(0)
168172
}
173+
// re-caclulate the duration of the phase
174+
duration = endDate.diff(startDate, 'days') + 1
169175

170176
// if phase's product has timeline get data from timeline
171177
} else {
@@ -264,7 +270,7 @@ export function getProjectNavLinks(project, projectId, renderFAQs) {
264270
messagesTab = { label: 'Messages', to: `/projects/${projectId}/messages`, Icon: MessagesIcon, iconClassName: 'stroke', exact: false }
265271
}
266272
// choose set of menu links based on the project version
267-
const navLinks = project.version === 'v3' ? [
273+
const navLinks = ['v3', 'v4'].includes(project.version) ? [
268274
{ label: 'Dashboard', to: `/projects/${projectId}`, Icon: DashboardIcon, iconClassName: 'stroke' },
269275
messagesTab,
270276
{ label: 'Scope', to: `/projects/${projectId}/scope`, Icon: ScopeIcon, iconClassName: 'fill' },

src/projects/actions/project.js

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ import {
6565
LOAD_PROJECT_MEMBER_INVITES,
6666
CREATE_PROJECT_PHASE_TIMELINE_MILESTONES,
6767
LOAD_PROJECT_MEMBER,
68-
ES_REINDEX_DELAY
68+
ES_REINDEX_DELAY,
69+
CREATE_PROJECT_PHASE
6970
} from '../../config/constants'
7071
import {
7172
updateProductMilestone,
@@ -178,6 +179,7 @@ function getProjectPhasesWithProducts(projectId) {
178179
'endDate',
179180
'id',
180181
'name',
182+
'description',
181183
'progress',
182184
'projectId',
183185
'spentBudget',
@@ -273,16 +275,20 @@ function createProductsTimelineAndMilestone(project) {
273275
/**
274276
* Create phase and product for the project
275277
*
276-
* @param {Object} project project
277-
* @param {Object} productTemplate product template
278-
* @param {String} status (optional) project/phase status
278+
* @param {Object} project project
279+
* @param {Object} productTemplate product template
280+
* @param {String} status (optional) project/phase status
281+
* @param {Date} startDate start date of the phase
282+
* @param {Date} endDate end date of the phase
283+
* @param {Boolean} createTimeline flag to indicate if we need to create timeline for the phase
279284
*
280285
* @return {Promise} project
281286
*/
282-
export function createProjectPhaseAndProduct(project, productTemplate, status = PHASE_STATUS_DRAFT, startDate, endDate) {
287+
export function createProjectPhaseAndProduct(project, productTemplate, status = PHASE_STATUS_DRAFT, startDate, endDate, createTimeline = true) {
283288
const param = {
284289
status,
285290
name: productTemplate.name,
291+
description: productTemplate.description,
286292
productTemplateId: productTemplate.id
287293
}
288294
if (startDate) {
@@ -293,13 +299,21 @@ export function createProjectPhaseAndProduct(project, productTemplate, status =
293299
}
294300

295301
return createProjectPhase(project.id, param).then((phase) => {
296-
// we also wait until timeline is created as we will load it for the phase after creation
297-
return createTimelineAndMilestoneForProduct(phase.products[0], phase).then((timeline) => ({
298-
project,
299-
phase,
300-
product:phase.products[0],
301-
timeline,
302-
}))
302+
if (createTimeline) {
303+
// we also wait until timeline is created as we will load it for the phase after creation
304+
return createTimelineAndMilestoneForProduct(phase.products[0], phase).then((timeline) => ({
305+
project,
306+
phase,
307+
product:phase.products[0],
308+
timeline,
309+
}))
310+
} else {
311+
return Promise.resolve({
312+
project,
313+
phase,
314+
product:phase.products[0]
315+
})
316+
}
303317
})
304318
}
305319

@@ -331,6 +345,25 @@ function createPhaseAndMilestonesRequest(project, productTemplate, status = PHAS
331345
})
332346
}
333347

348+
/**
349+
* Creates phase and product only, without timeline and milestone. Introduced with project plan simplification
350+
* work where we removed timeline and milestones for projects with version v4
351+
* @param {*} project
352+
* @param {*} productTemplate
353+
* @param {*} status
354+
* @param {*} startDate
355+
* @param {*} endDate
356+
*/
357+
export function createPhaseWithoutTimeline(project, productTemplate, status, startDate, endDate) {
358+
return (dispatch) => {
359+
console.log(CREATE_PROJECT_PHASE)
360+
return dispatch({
361+
type: CREATE_PROJECT_PHASE,
362+
payload: createProjectPhaseAndProduct(project, productTemplate, status, startDate, endDate, false)
363+
})
364+
}
365+
}
366+
334367
export function createPhaseAndMilestones(project, productTemplate, status, startDate, endDate, milestones) {
335368
return (dispatch, getState) => {
336369
return dispatch({
@@ -340,9 +373,6 @@ export function createPhaseAndMilestones(project, productTemplate, status, start
340373
const state = getState()
341374
const project = state.projectState.project
342375

343-
console.log('project.status', project.status)
344-
console.log('status', status)
345-
346376
// if phase is created as ACTIVE, move project to ACTIVE too
347377
if (
348378
_.includes([PROJECT_STATUS_DRAFT, PROJECT_STATUS_IN_REVIEW, PROJECT_STATUS_REVIEWED], project.status) &&
@@ -464,6 +494,7 @@ export function updatePhase(projectId, phaseId, updatedProps, phaseIndex) {
464494
const phaseStartDate = timeline ? timeline.startDate : phase.startDate
465495
const startDateChanged = updatedProps.startDate ? updatedProps.startDate.diff(phaseStartDate) : null
466496
const phaseActivated = phaseStatusChanged && updatedProps.status === PHASE_STATUS_ACTIVE
497+
const projectVersion = state.projectState.project.version
467498

468499
if (updatedProps.startDate) {
469500
updatedProps.startDate = moment(updatedProps.startDate).format('YYYY-MM-DD')
@@ -494,7 +525,7 @@ export function updatePhase(projectId, phaseId, updatedProps, phaseIndex) {
494525
// - phase's status is changed to active
495526
// - there is not active milestone alreay (this can happen when phase is made active more than once
496527
// e.g. Active => Paused => Active)
497-
if (timeline && !activeMilestone && phaseActivated ) {
528+
if (projectVersion !== 'v4' && timeline && !activeMilestone && phaseActivated ) {
498529
dispatch(
499530
updateProductMilestone(
500531
productId,

src/projects/actions/projectDashboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const getDashboardData = (dispatch, getState, projectId, isOnlyLoadProjectInfo)
3333
}
3434

3535
// for new projects load phases, products, project template and product templates
36-
if (project.version === 'v3') {
36+
if (['v3', 'v4'].indexOf(project.version) !== -1) {
3737
promises.push(
3838
dispatch(loadProjectPlan(projectId, userIds))
3939
)

src/projects/components/projectsCard/ProjectCard.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function ProjectCard({ project, disabled, currentUser, history, onChangeStatus,
1515
const isMember = _.some(project.members, m => (m.userId === currentUser.userId && m.deletedAt === null))
1616
// check whether has pending invition
1717
const isInvited = _.some(project.invites, m => ((m.userId === currentUser.userId || m.email === currentUser.email) && !m.deletedAt && m.status === 'pending'))
18-
const projectDetailsURL = project.version === 'v3'
18+
const projectDetailsURL = ['v3', 'v4'].includes(project.version)
1919
? `/projects/${project.id}/scope`
2020
: `/projects/${project.id}/specification`
2121

src/projects/components/projectsCard/ProjectCardBody.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function ProjectCardBody({ project, descLinesCount = 8,
3232

3333
const progress = _.get(process, 'percent', 0)
3434

35-
const projectDetailsURL = project.version === 'v3'
35+
const projectDetailsURL = ['v3', 'v4'].includes(project.version)
3636
? `/projects/${project.id}/scope`
3737
: `/projects/${project.id}/specification`
3838

src/projects/create/containers/CreateContainer.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,10 @@ class CreateContainer extends React.Component {
245245
}
246246
_.set(project, 'details.utm.google', googleAnalytics)
247247
}
248+
const searchParams = new URLSearchParams(window.location.search)
249+
const isBetaMode = searchParams.get('beta') === 'true'
248250
if (projectTemplate) {
249-
project.version = 'v3'
251+
project.version = isBetaMode ? 'v4' : 'v3'
250252
project.templateId = projectTemplate.id
251253
project.type = projectTemplate.category
252254
}

0 commit comments

Comments
 (0)