Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ export const CREATE_PROJECT_PENDING = 'CREATE_PROJECT_PENDING'
export const CREATE_PROJECT_SUCCESS = 'CREATE_PROJECT_SUCCESS'
export const CREATE_PROJECT_FAILURE = 'CREATE_PROJECT_FAILURE'

export const CREATE_PROJECT_STAGE = 'CREATE_PROJECT_STAGE'
export const CREATE_PROJECT_STAGE_PENDING = 'CREATE_PROJECT_STAGE_PENDING'
export const CREATE_PROJECT_STAGE_SUCCESS = 'CREATE_PROJECT_STAGE_SUCCESS'
export const CREATE_PROJECT_STAGE_FAILURE = 'CREATE_PROJECT_STAGE_FAILURE'

export const UPDATE_PROJECT = 'UPDATE_PROJECT'
export const UPDATE_PROJECT_PENDING = 'UPDATE_PROJECT_PENDING'
export const UPDATE_PROJECT_SUCCESS = 'UPDATE_PROJECT_SUCCESS'
Expand Down Expand Up @@ -1141,5 +1136,22 @@ export const MILESTONE_TYPE = {
REPORTING: 'reporting',
DELIVERABLE_REVIEW: 'deliverable-review',
FINAL_DELIVERABLE_REVIEW: 'final-deliverable-review',
DELIVERABLE_FINAL_FIXES: 'deliverable-final-fixes'
DELIVERABLE_FINAL_FIXES: 'deliverable-final-fixes',
PHASE_SPECIFICATION:'phase-specification',
COMMUNITY_WORK: 'ommunity-work',
COMMUNITY_REVIEW: 'community-review',
GENERIC_WORK: 'generic-work',
CHECKPOINT_REVIEW: 'checkpoint-review',
ADD_LINKS: 'add-links',
FINAL_DESIGNS: 'final-designs',
FINAL_FIX: 'final-fix',
DELIVERY_DEV: 'delivery-dev',
DELIVERY_DESIGN: 'delivery-design',
DELIVERY: 'delivery'
}


/**
* project template id
*/
export const PROJECT_TEMPLATE_ID = 166
29 changes: 0 additions & 29 deletions src/projects/actions/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
LOAD_PROJECT,
LOAD_PROJECT_MEMBER_INVITE,
CREATE_PROJECT,
CREATE_PROJECT_STAGE,
CLEAR_LOADED_PROJECT,
UPDATE_PROJECT,
DELETE_PROJECT,
Expand Down Expand Up @@ -74,9 +73,6 @@ import {
updateProductMilestone,
updateProductTimeline
} from './productsTimelines'
import {
getPhaseActualData,
} from '../../helpers/projectHelper'
import { delay } from '../../helpers/utils'

/**
Expand Down Expand Up @@ -274,31 +270,6 @@ function createProductsTimelineAndMilestone(project) {
}
}

export function createProduct(project, productTemplate, phases, timelines) {
// get endDates + 1 day for all the phases if there are any phases
const phaseEndDatesPlusOne = (phases || []).map((phase) => {
const productId = _.get(phase, 'products[0].id', -1)
const timeline = _.get(timelines, `${productId}.timeline`, null)

const phaseActualData = getPhaseActualData(phase, timeline)

return phaseActualData.endDate.add(1, 'day')
})

const today = moment().hours(0).minutes(0).seconds(0).milliseconds(0)
const startDate = _.max([...phaseEndDatesPlusOne, today])

// assumes 10 days as default duration, ideally we could store it at template level
const endDate = moment(startDate).add((10 - 1), 'days')

return (dispatch) => {
return dispatch({
type: CREATE_PROJECT_STAGE,
payload: createProjectPhaseAndProduct(project, productTemplate, PHASE_STATUS_DRAFT, startDate, endDate)
})
}
}

/**
* Create phase and product for the project
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class CreatePhaseForm extends React.Component {
_.forEach(apiMilestones, (m, index) => {
m.status = 'reviewed'
m.order = index + 1
m.duration = moment(m.endDate).diff(moment(m.startDate), 'days') + 1
// TODO add mock data
m.duration = 1
m.hidden =false
m.completedText = 'completed text'
m.activeText = 'active text'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class CreateMilestoneForm extends React.Component {
// TODO
// mock data
values.status = 'reviewed'
values.duration = moment(values.endDate).diff(moment(values.startDate), 'days') + 1
// TODO add mock data
values.duration = 1
values.hidden =false
values.completedText = 'completed text'
values.activeText = 'active text'
Expand All @@ -64,6 +64,11 @@ class CreateMilestoneForm extends React.Component {
values.blockedText = 'blocked text'
onSubmit(values)
}

getOptionType(val) {
return _.find(MILESTONE_TYPE_OPTIONS, (v) => v.value === val).title
}

changeForm(values) {
const { type, title, startDate, endDate } = this.state
if (values['name'] !== title) {
Expand All @@ -88,7 +93,7 @@ class CreateMilestoneForm extends React.Component {
})
if (!title) {
this.setState({
title: values['type']
title: this.getOptionType(values['type'])
})
}
}
Expand Down
25 changes: 13 additions & 12 deletions src/projects/detail/components/timeline/Milestone/Milestone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,13 @@ class Milestone extends React.Component {
const isActualDateEditable = this.isActualStartDateEditable()
const isCompletionDateEditable = this.isCompletionDateEditable()

const isFirstReportingType = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING
const disableDelete = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING
const disableType = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING || milestone.status !== MILESTONE_STATUS.PLANNED

const editForm = (
<Form
fields={[
isFirstReportingType ?
disableType ?
{
label: 'Type',
disabled: true,
Expand Down Expand Up @@ -491,7 +492,7 @@ class Milestone extends React.Component {

{isEditing && !isUpdating && (
<div styleName="edit-form">
{isFirstReportingType ? null: <i onClick={this.onDeleteClick} title="trash"><TrashIcon /></i> }
{disableDelete ? null: <i onClick={this.onDeleteClick} title="trash"><TrashIcon /></i> }
{editForm}
</div>
)}
Expand Down Expand Up @@ -519,7 +520,7 @@ class Milestone extends React.Component {

{isUpdating && <DotIndicator><LoadingIndicator /></DotIndicator>}

{!isEditing && !isUpdating && milestone.type === 'phase-specification' && (
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.PHASE_SPECIFICATION && (
<MilestoneTypePhaseSpecification
milestone={milestone}
updateMilestoneContent={this.updateMilestoneContent}
Expand All @@ -529,7 +530,7 @@ class Milestone extends React.Component {
/>
)}

{!isEditing && !isUpdating && (milestone.type === 'community-work' || milestone.type === 'community-review' || milestone.type === 'generic-work') && (
{!isEditing && !isUpdating && (milestone.type === MILESTONE_TYPE.COMMUNITY_WORK || milestone.type === MILESTONE_TYPE.COMMUNITY_REVIEW || milestone.type === MILESTONE_TYPE.GENERIC_WORK) && (
<MilestoneTypeProgress
milestone={milestone}
updateMilestoneContent={this.updateMilestoneContent}
Expand All @@ -539,7 +540,7 @@ class Milestone extends React.Component {
/>
)}

{!isEditing && !isUpdating && milestone.type === 'checkpoint-review' && (
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.CHECKPOINT_REVIEW && (
<MilestoneTypeCheckpointReview
milestone={milestone}
updateMilestoneContent={this.updateMilestoneContent}
Expand All @@ -549,7 +550,7 @@ class Milestone extends React.Component {
/>
)}

{!isEditing && !isUpdating && milestone.type === 'add-links' && (
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.ADD_LINKS && (
<MilestoneTypeAddLinks
milestone={milestone}
updateMilestoneContent={this.updateMilestoneContent}
Expand All @@ -559,7 +560,7 @@ class Milestone extends React.Component {
/>
)}

{!isEditing && !isUpdating && milestone.type === 'final-designs' && (
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.FINAL_DESIGNS && (
<MilestoneTypeFinalDesigns
milestone={milestone}
updateMilestoneContent={this.updateMilestoneContent}
Expand All @@ -569,7 +570,7 @@ class Milestone extends React.Component {
/>
)}

{!isEditing && !isUpdating && milestone.type === 'final-fix' && (
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.FINAL_FIX && (
<MilestoneTypeFinalFixes
milestone={milestone}
updateMilestoneContent={this.updateMilestoneContent}
Expand All @@ -584,11 +585,11 @@ class Milestone extends React.Component {
!isEditing &&
!isUpdating &&
(
milestone.type === 'delivery-dev' ||
milestone.type === 'delivery-design' ||
milestone.type === MILESTONE_TYPE.DELIVERY_DEV ||
milestone.type === MILESTONE_TYPE.DELIVERY_DESIGN ||
// TODO this is a temporary fallback for already created milestones in DEV backend
// this is just to keep already created milestones working and can be removed when we don't touch such projects anymore
milestone.type === 'delivery'
milestone.type === MILESTONE_TYPE.DELIVERY
) &&
(
<MilestoneTypeDelivery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class CreateMilestoneForm extends React.Component {
// TODO
// mock data
values.status = 'reviewed'
values.duration = moment(values.endDate).diff(moment(values.startDate), 'days') + 1
// TODO add mock data
values.duration = 1
values.hidden =false
values.completedText = 'completed text'
values.activeText = 'active text'
Expand All @@ -64,6 +64,11 @@ class CreateMilestoneForm extends React.Component {
values.blockedText = 'blocked text'
onSubmit(values)
}

getOptionType(val) {
return _.find(MILESTONE_TYPE_OPTIONS, (v) => v.value === val).title
}

changeForm(values) {
const { type, title, startDate, endDate } = this.state
if (values['name'] !== title) {
Expand All @@ -88,7 +93,7 @@ class CreateMilestoneForm extends React.Component {
})
if (!title) {
this.setState({
title: values['type']
title: this.getOptionType(values['type'])
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/projects/detail/containers/DashboardContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
PHASE_STATUS_DRAFT,
SCREEN_BREAKPOINT_MD,
CODER_BOT_USERID,
PROJECT_TEMPLATE_ID,
} from '../../../config/constants'

const SYSTEM_USER = {
Expand Down Expand Up @@ -119,7 +120,7 @@ class DashboardContainer extends React.Component {

const projectTemplate = {
name: phase.title,
id:166,
id: PROJECT_TEMPLATE_ID,
}

createPhaseAndMilestones(project, projectTemplate, type, phase.startDate, phase.endDate, milestones)
Expand Down
26 changes: 0 additions & 26 deletions src/projects/reducers/productsTimelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
SUBMIT_FINAL_FIXES_REQUEST_PENDING,
SUBMIT_FINAL_FIXES_REQUEST_SUCCESS,
SUBMIT_FINAL_FIXES_REQUEST_FAILURE,
CREATE_PROJECT_STAGE_SUCCESS,
} from '../../config/constants'
import update from 'react-addons-update'

Expand Down Expand Up @@ -201,31 +200,6 @@ export const productsTimelines = (state=initialState, action) => {
})
)


case CREATE_PROJECT_STAGE_SUCCESS: {
const timeline = payload.timeline
const product = payload.product

// if there is timeline for the product
if (timeline) {
// sort milestones by order as server doesn't do it
timeline.milestones = _.sortBy(timeline.milestones, 'order')
}

if (timeline && product) {
return update(state, {
[product.id]: {
$set: {
isLoading: false,
timeline,
error: false
}
}
})
}
return state
}

case LOAD_PRODUCT_TIMELINE_WITH_MILESTONES_SUCCESS: {
const timeline = payload

Expand Down
23 changes: 1 addition & 22 deletions src/projects/reducers/project.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_PENDING, CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_SUCCESS, CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_FAILURE,
LOAD_PROJECT_PENDING, LOAD_PROJECT_SUCCESS, LOAD_PROJECT_MEMBER_INVITE_PENDING, LOAD_PROJECT_MEMBER_INVITE_SUCCESS, LOAD_PROJECT_FAILURE,
CREATE_PROJECT_PENDING, CREATE_PROJECT_SUCCESS, CREATE_PROJECT_FAILURE, CREATE_PROJECT_STAGE_PENDING, CREATE_PROJECT_STAGE_SUCCESS, CREATE_PROJECT_STAGE_FAILURE, CLEAR_LOADED_PROJECT,
CREATE_PROJECT_PENDING, CREATE_PROJECT_SUCCESS, CREATE_PROJECT_FAILURE, CLEAR_LOADED_PROJECT,
UPDATE_PROJECT_PENDING, UPDATE_PROJECT_SUCCESS, UPDATE_PROJECT_FAILURE,
DELETE_PROJECT_PENDING, DELETE_PROJECT_SUCCESS, DELETE_PROJECT_FAILURE,
ADD_PROJECT_ATTACHMENT_PENDING, ADD_PROJECT_ATTACHMENT_SUCCESS, ADD_PROJECT_ATTACHMENT_FAILURE,
Expand Down Expand Up @@ -327,25 +327,6 @@ export const projectState = function (state=initialState, action) {
})
}

case CREATE_PROJECT_STAGE_SUCCESS: {
// as we additionally loaded products to the phase object we have to keep them
// note that we keep them as they are without creation a new copy
const phase = {
...action.payload.phase,
products: [action.payload.product]
}
const phaseNonDirty = {
// for non-dirty version we make sure that dont' have the same objects with phase
..._.cloneDeep(action.payload.phase),
products: [_.cloneDeep(action.payload.product)]
}
return update(state, {
processing: { $set: false },
phases: { $push: [phase] },
phasesNonDirty: { $push: [phaseNonDirty] }
})
}

case UPDATE_PHASE_SUCCESS: {
// as we additionally loaded products to the phase object we have to keep them
// note that we keep them as they are without creation a new copy
Expand Down Expand Up @@ -477,7 +458,6 @@ export const projectState = function (state=initialState, action) {
}

// Create & Edit project
case CREATE_PROJECT_STAGE_PENDING:
case CREATE_PROJECT_PENDING:
case DELETE_PROJECT_PENDING:
case UPDATE_PROJECT_PENDING:
Expand Down Expand Up @@ -885,7 +865,6 @@ export const projectState = function (state=initialState, action) {
}

case LOAD_PROJECT_FAILURE:
case CREATE_PROJECT_STAGE_FAILURE:
case CREATE_PROJECT_FAILURE:
case DELETE_PROJECT_FAILURE:
case UPDATE_PROJECT_FAILURE:
Expand Down
8 changes: 0 additions & 8 deletions src/reducers/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
// bulk phase and milestones
CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_SUCCESS,
// Project
CREATE_PROJECT_STAGE_SUCCESS,
CREATE_PROJECT_SUCCESS, CREATE_PROJECT_FAILURE,
UPDATE_PROJECT_SUCCESS, UPDATE_PROJECT_FAILURE,
DELETE_PROJECT_SUCCESS, DELETE_PROJECT_FAILURE,
Expand Down Expand Up @@ -88,13 +87,6 @@ export default function(state = {}, action) {
Alert.success('Project phase created.')
return state
}
case CREATE_PROJECT_STAGE_SUCCESS: {

//delay time for reload stage list of project after creating state
setTimeout(() => { Alert.success('Added New Stage To Project') }, 2000)

return state
}

case DELETE_PROJECT_PHASE_SUCCESS: {
Alert.success('Project phase deleted.')
Expand Down