Skip to content

Commit b2e2387

Browse files
committed
fix: change milestone.type to const type
1 parent 5986ae6 commit b2e2387

File tree

10 files changed

+44
-38
lines changed

10 files changed

+44
-38
lines changed

config/constants/dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = {
4343
PREDIX_PROGRAM_ID : 3448,
4444
IBM_COGNITIVE_PROGRAM_ID : 3449,
4545
HEAP_ANALYTICS_APP_ID : '4153837120',
46+
PHASE_PRODUCT_TEMPLATE_ID : 166,
4647

4748
TC_NOTIFICATION_URL: 'https://api.topcoder-dev.com/v5/notifications',
4849
CONNECT_MESSAGE_API_URL: 'https://api.topcoder-dev.com/v5',

config/constants/master.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = {
4343
PREDIX_PROGRAM_ID : 3448,
4444
IBM_COGNITIVE_PROGRAM_ID : 3449,
4545
HEAP_ANALYTICS_APP_ID : '638908330',
46+
PHASE_PRODUCT_TEMPLATE_ID : 166,
4647

4748
TC_NOTIFICATION_URL: 'https://api.topcoder.com/v5/notifications',
4849
CONNECT_MESSAGE_API_URL: 'https://api.topcoder.com/v5',

config/constants/qa.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = {
4242
PREDIX_PROGRAM_ID : 3448,
4343
IBM_COGNITIVE_PROGRAM_ID : 3449,
4444
HEAP_ANALYTICS_APP_ID : '4153837120',
45+
PHASE_PRODUCT_TEMPLATE_ID : 166,
4546

4647
TC_NOTIFICATION_URL: 'https://api.topcoder-dev.com/v5/notifications',
4748
CONNECT_MESSAGE_API_URL: 'https://api.topcoder-qa.com/v5',

src/config/constants.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,24 +1111,6 @@ export const PROJECT_TYPE_TALENT_AS_A_SERVICE = 'talent-as-a-service'
11111111
*/
11121112
export const TAAS_APP_URL = process.env.TAAS_APP_URL || 'https://mfe.topcoder-dev.com/taas'
11131113

1114-
/**
1115-
* Milestone Type Options
1116-
*/
1117-
export const MILESTONE_TYPE_OPTIONS = [
1118-
{
1119-
title: 'Reporting',
1120-
value: 'reporting',
1121-
},
1122-
{
1123-
title: 'Deliverable Review',
1124-
value: 'deliverable-review',
1125-
},
1126-
{
1127-
title: 'Final Deliverable Review',
1128-
value: 'final-deliverable-review',
1129-
},
1130-
]
1131-
11321114
/**
11331115
* Milestone Types
11341116
*/
@@ -1150,8 +1132,25 @@ export const MILESTONE_TYPE = {
11501132
DELIVERY: 'delivery'
11511133
}
11521134

1135+
/**
1136+
* Milestone Type Options
1137+
*/
1138+
export const MILESTONE_TYPE_OPTIONS = [
1139+
{
1140+
title: 'Reporting',
1141+
value: MILESTONE_TYPE.REPORTING,
1142+
},
1143+
{
1144+
title: 'Deliverable Review',
1145+
value: MILESTONE_TYPE.DELIVERABLE_REVIEW,
1146+
},
1147+
{
1148+
title: 'Final Deliverable Review',
1149+
value: MILESTONE_TYPE.FINAL_DELIVERABLE_REVIEW,
1150+
},
1151+
]
11531152

11541153
/**
11551154
* project template id
11561155
*/
1157-
export const PROJECT_TEMPLATE_ID = 166
1156+
export const PHASE_PRODUCT_TEMPLATE_ID = process.env.PHASE_PRODUCT_TEMPLATE_ID

src/projects/actions/productsTimelines.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
SUBMIT_FINAL_FIXES_REQUEST_SUCCESS,
2525
SUBMIT_FINAL_FIXES_REQUEST_FAILURE,
2626
CREATE_TIMELINE_MILESTONE,
27+
MILESTONE_TYPE,
2728
MILESTONE_STATUS,
2829
UPDATE_PRODUCT_TIMELINE,
2930
PHASE_STATUS_COMPLETED,
@@ -226,10 +227,10 @@ export function completeProductMilestone(productId, timelineId, milestoneId, upd
226227
prevMilestoneContent: completedMilestone.details.content,
227228
prevMilestoneType: completedMilestone.type,
228229
}
229-
if ( ((nextMilestone.type === 'checkpoint-review' || nextMilestone.type === 'final-designs') // case # 2
230-
&& completedMilestone.type === 'add-links' ) ||
231-
((nextMilestone.type === 'delivery-design' || nextMilestone.type === 'delivery-dev') // case # 4
232-
&& completedMilestone.type !== 'final-fix' ) ) {
230+
if ( ((nextMilestone.type === MILESTONE_TYPE.CHECKPOINT_REVIEW || nextMilestone.type === MILESTONE_TYPE.FINAL_DESIGNS) // case # 2
231+
&& completedMilestone.type === MILESTONE_TYPE.ADD_LINKS ) ||
232+
((nextMilestone.type === MILESTONE_TYPE.DELIVERY_DESIGN || nextMilestone.type === MILESTONE_TYPE.DELIVERY_DEV) // case # 4
233+
&& completedMilestone.type !== MILESTONE_TYPE.FINAL_FIX) ) {
233234
details.metadata = {
234235
..._.get(nextMilestone.details, 'metadata', {}),
235236
waitingForCustomer: true
@@ -343,7 +344,7 @@ export function submitFinalFixesRequest(productId, timelineId, milestoneId, fina
343344

344345
let finalFixesMilestone = timeline.milestones[milestoneIdx - 1]
345346

346-
if (!finalFixesMilestone || finalFixesMilestone.type !== 'final-fix') {
347+
if (!finalFixesMilestone || finalFixesMilestone.type !== MILESTONE_TYPE.FINAL_FIX) {
347348
throw new Error('Cannot find final-fix milestone.')
348349
}
349350

@@ -506,7 +507,7 @@ export function submitDeliverableFinalFixesRequest(productId, timelineId, milest
506507
).updatedTimelineMilestones
507508

508509
const finalFixesMilestone = {
509-
type: 'deliverable-final-fixes',
510+
type: MILESTONE_TYPE.DELIVERABLE_FINAL_FIXES,
510511
startDate: milestone.endDate,
511512
endDate: moment(milestone.endDate).add(3, 'day').toISOString(),
512513
status: MILESTONE_STATUS.ACTIVE,

src/projects/detail/components/timeline/milestones/MilestoneTypeCheckpointReview/MilestoneTypeCheckpointReview.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { getMilestoneStatusText, getDaysLeft, getTotalDays, getProgressPercent,
1717
import {
1818
MILESTONE_STATUS,
1919
MIN_CHECKPOINT_REVIEW_DESIGNS,
20+
MILESTONE_TYPE,
2021
} from '../../../../../../config/constants'
2122

2223
import './MilestoneTypeCheckpointReview.scss'
@@ -29,7 +30,7 @@ class MilestoneTypeCheckpointReview extends React.Component {
2930

3031
this.state = {
3132
selectedLinks: [],
32-
isLinksProvided: _.get(props.milestone, 'details.prevMilestoneType') === 'add-links',
33+
isLinksProvided: _.get(props.milestone, 'details.prevMilestoneType') === MILESTONE_TYPE.ADD_LINKS,
3334
isSelectWarningVisible: false,
3435
isShowCompleteConfirmMessage: false,
3536
}

src/projects/detail/components/timeline/milestones/MilestoneTypeDeliverableReview/MilestoneTypeDeliverableReview.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { withMilestoneExtensionRequest } from '../../MilestoneExtensionRequest'
1515
import { getMilestoneStatusText } from '../../../../../../helpers/milestoneHelper'
1616

1717
import {
18+
MILESTONE_TYPE,
1819
MILESTONE_STATUS
1920
} from '../../../../../../config/constants'
2021

@@ -215,7 +216,7 @@ class MilestoneTypeDeliverableReview extends React.Component {
215216
<div className="flex column middle" styleName="btns-container-vertical">
216217

217218
{/* For milestone type of 'deliverable-final-fixes' specifically */}
218-
{milestone.type === 'deliverable-final-fixes' && (
219+
{milestone.type === MILESTONE_TYPE.DELIVERABLE_FINAL_FIXES && (
219220
<div styleName="fullwidth">
220221
<div styleName="view-report-text">{milestoneDeliverableFinalFixesRequest}</div>
221222
</div>
@@ -250,7 +251,7 @@ class MilestoneTypeDeliverableReview extends React.Component {
250251
)}
251252

252253
{/* Feedback link */}
253-
{milestone.type !== 'deliverable-final-fixes' && (
254+
{milestone.type !== MILESTONE_TYPE.DELIVERABLE_FINAL_FIXES && (
254255
isAddingFeedbackLink ? (
255256
<div styleName="fullwidth">
256257
<LinkItemForm
@@ -319,7 +320,7 @@ class MilestoneTypeDeliverableReview extends React.Component {
319320
</div>
320321

321322
{/* For milestone types other than 'final-deliverable-review' specifically */}
322-
{milestone.type !== 'final-deliverable-review' && (
323+
{milestone.type !== MILESTONE_TYPE.FINAL_DELIVERABLE_REVIEW && (
323324
isActive && canAcceptFinalDelivery && (
324325
<div className="flex center" styleName="review-complete-btn-container">
325326
<button type="button" className="tc-btn tc-btn-primary" onClick={this.onClickReviewComplete} disabled={milestoneSubmissionLinks.length === 0}>Review Complete</button>
@@ -328,7 +329,7 @@ class MilestoneTypeDeliverableReview extends React.Component {
328329
)}
329330

330331
{/* For milestone type of 'final-deliverable-review' specifically */}
331-
{milestone.type === 'final-deliverable-review' && (
332+
{milestone.type === MILESTONE_TYPE.FINAL_DELIVERABLE_REVIEW && (
332333
isActive && canAcceptFinalDelivery && (
333334
isAdddingFinalFixesRequest ? (
334335
<div styleName="fullwidth">

src/projects/detail/components/timeline/milestones/MilestoneTypeDelivery/MilestoneTypeDelivery.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import MilestoneDescription from '../../MilestoneDescription'
1414
import MilestoneDelayNotification from '../../MilestoneDelayNotification'
1515
import { getMilestoneStatusText } from '../../../../../../helpers/milestoneHelper'
1616
import { hasPermission } from '../../../../../../helpers/permissions'
17-
import { MILESTONE_STATUS } from '../../../../../../config/constants'
17+
import { MILESTONE_STATUS, MILESTONE_TYPE } from '../../../../../../config/constants'
1818

1919
import './MilestoneTypeDelivery.scss'
2020
import { PERMISSIONS } from '../../../../../../config/permissions'
@@ -23,19 +23,19 @@ import { PERMISSIONS } from '../../../../../../config/permissions'
2323
Acceptance dialogue messages based on the milestone type
2424
*/
2525
const acceptDialogue = {
26-
'delivery-dev': {
26+
[MILESTONE_TYPE.DELIVERY_DEV]: {
2727
title: 'Code acceptance',
2828
text: 'Do you need any refinement on winner’s code before we deliver you the final source files? Some refinement or final fixes outside the project scope may cost you additional payment',
2929
button: 'Accept code',
3030
},
31-
'delivery-design': {
31+
[MILESTONE_TYPE.DELIVERY_DESIGN]: {
3232
title: 'Design acceptance',
3333
text: 'Do you need any refinement on winner’s design before we deliver you the final source files? Some refinement or final fixes outside the project scope may cost you additional payment',
3434
button: 'Accept design',
3535
},
3636
// TODO this is a temporary fallback for already created milestones in DEV backend
3737
// this is just to keep already created milestones working and can be removed when we don't touch such projects anymore
38-
delivery: {
38+
[MILESTONE_TYPE.DELIVERY]: {
3939
title: 'Work acceptance',
4040
text: 'Do you need any refinement on winner’s work before we deliver you the final source files? Some refinement or final fixes outside the project scope may cost you additional payment',
4141
button: 'Accept work',
@@ -194,7 +194,7 @@ class MilestoneTypeDelivery extends React.Component {
194194

195195
const canSubmitFinalFixes = _.some(finalFixRequests, (finalFixRequest) => !!finalFixRequest.value)
196196

197-
const isFinalFixPresent = previousMilestone === 'final-fix'
197+
const isFinalFixPresent = previousMilestone === MILESTONE_TYPE.FINAL_FIX
198198
let links = ''
199199
const deliveryButtons = [{ title: acceptDialogue[milestone.type].button, onClick: this.acceptDesign, type: 'primary' }]
200200
if(isFinalFixPresent) {

src/projects/detail/components/timeline/milestones/MilestoneTypeFinalDesigns/MilestoneTypeFinalDesigns.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
MILESTONE_STATUS,
2020
MIN_WINNER_DESIGNS,
2121
DEFAULT_ADDITIONAL_DESIGN_COST,
22+
MILESTONE_TYPE
2223
} from '../../../../../../config/constants'
2324

2425
import './MilestoneTypeFinalDesigns.scss'
@@ -36,7 +37,7 @@ class MilestoneTypeFinalDesigns extends React.Component {
3637
additionalDesignCost: _.get(props, 'milestone.details.metadata.additionalDesignCost', DEFAULT_ADDITIONAL_DESIGN_COST),
3738
selectedLinks: [],
3839
places: _.fill(Array(requiredWinnersCount), -1), // produces array like [-1, -1, -1, ... , -1]
39-
isLinksProvided: _.get(props.milestone, 'details.prevMilestoneType') === 'add-links',
40+
isLinksProvided: _.get(props.milestone, 'details.prevMilestoneType') === MILESTONE_TYPE.ADD_LINKS,
4041
isShowCompleteConfirmMessage: false,
4142
isShowCustomerCompleteConfirmMessage: false,
4243
}

src/projects/detail/containers/DashboardContainer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import {
6060
PHASE_STATUS_DRAFT,
6161
SCREEN_BREAKPOINT_MD,
6262
CODER_BOT_USERID,
63-
PROJECT_TEMPLATE_ID,
63+
PHASE_PRODUCT_TEMPLATE_ID
6464
} from '../../../config/constants'
6565

6666
const SYSTEM_USER = {
@@ -120,7 +120,7 @@ class DashboardContainer extends React.Component {
120120

121121
const projectTemplate = {
122122
name: phase.title,
123-
id: PROJECT_TEMPLATE_ID,
123+
id: PHASE_PRODUCT_TEMPLATE_ID,
124124
}
125125

126126
createPhaseAndMilestones(project, projectTemplate, type, phase.startDate, phase.endDate, milestones)

0 commit comments

Comments
 (0)