diff --git a/src/api/projects.js b/src/api/projects.js index 17cc966da..950a39e7c 100644 --- a/src/api/projects.js +++ b/src/api/projects.js @@ -223,3 +223,8 @@ export function deleteProjectPhase(projectId, phaseId) { return axios.delete(`${PROJECTS_API_URL}/v5/projects/${projectId}/phases/${phaseId}`) .then(() => ({ projectId, phaseId })) } + +export function deleteBulkProjectPhase(projectId, phaseIds) { + return axios.delete(`${PROJECTS_API_URL}/v5/projects/${projectId}/phases`, { data: { phaseIds } }) + .then(() => ({ phaseIds })) +} diff --git a/src/config/constants.js b/src/config/constants.js index 0b27005a0..420aeda9f 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -300,6 +300,11 @@ export const DELETE_PROJECT_PHASE_PENDING = 'DELETE_PROJECT_PHASE_PENDING' export const DELETE_PROJECT_PHASE_FAILURE = 'DELETE_PROJECT_PHASE_FAILURE' export const DELETE_PROJECT_PHASE_SUCCESS = 'DELETE_PROJECT_PHASE_SUCCESS' +export const DELETE_BULK_PROJECT_PHASE = 'DELETE_BULK_PROJECT_PHASE' +export const DELETE_BULK_PROJECT_PHASE_PENDING = 'DELETE_BULK_PROJECT_PHASE_PENDING' +export const DELETE_BULK_PROJECT_PHASE_FAILURE = 'DELETE_BULK_PROJECT_PHASE_FAILURE' +export const DELETE_BULK_PROJECT_PHASE_SUCCESS = 'DELETE_BULK_PROJECT_PHASE_SUCCESS' + export const UPDATE_PRODUCT = 'UPDATE_PRODUCT' export const UPDATE_PRODUCT_PENDING = 'UPDATE_PRODUCT_PENDING' export const UPDATE_PRODUCT_SUCCESS = 'UPDATE_PRODUCT_SUCCESS' diff --git a/src/config/permissions.js b/src/config/permissions.js index 82e33250d..0b26002e5 100644 --- a/src/config/permissions.js +++ b/src/config/permissions.js @@ -249,7 +249,7 @@ export const PERMISSIONS = { description: 'Remove copilots form the project.', }, projectRoles: [ - ..._.difference(PROJECT_ALL, [PROJECT_ROLE_COPILOT, PROJECT_ROLE_CUSTOMER]) + ..._.difference(PROJECT_ALL, [PROJECT_ROLE_CUSTOMER]) ], topcoderRoles: [ ...TOPCODER_ADMINS, diff --git a/src/projects/actions/project.js b/src/projects/actions/project.js index 6bcb8aff7..aedb88427 100644 --- a/src/projects/actions/project.js +++ b/src/projects/actions/project.js @@ -7,6 +7,7 @@ import { getProjectById, updateProject as updateProjectAPI, deleteProject as deleteProjectAPI, deleteProjectPhase as deleteProjectPhaseAPI, + deleteBulkProjectPhase as deleteBulkProjectPhaseAPI, getProjectPhases, updateProduct as updateProductAPI, updatePhase as updatePhaseAPI, @@ -79,7 +80,8 @@ import { CUSTOMER_APPROVE_MILESTONE_APPROVE_SUCCESS, CUSTOMER_APPROVE_MILESTONE_REJECT_FAILURE, CUSTOMER_APPROVE_MILESTONE_APPROVE_FAILURE, - CUSTOMER_APPROVE_MILESTONE_REJECT_SUCCESS + CUSTOMER_APPROVE_MILESTONE_REJECT_SUCCESS, + DELETE_BULK_PROJECT_PHASE } from '../../config/constants' import { updateProductMilestone, @@ -334,6 +336,11 @@ export function createProjectPhaseAndProduct(project, productTemplate, status = description: productTemplate.description, productTemplateId: productTemplate.id, } + + if(productTemplate.members) { + param.members = productTemplate.members + } + if (startDate) { param['startDate'] = startDate.format('YYYY-MM-DD') } @@ -441,6 +448,15 @@ export function deleteProjectPhase(projectId, phaseId) { } } +export function deleteBulkProjectPhase(projectId, phaseIds) { + return (dispatch) => { + return dispatch({ + type: DELETE_BULK_PROJECT_PHASE, + payload: deleteBulkProjectPhaseAPI(projectId, phaseIds) + }) + } +} + export function updateProject(projectId, updatedProps, updateExisting = false) { return (dispatch) => { return dispatch({ diff --git a/src/projects/detail/components/SimplePlan/CreateSimplePlan/CreateSimplePlan.jsx b/src/projects/detail/components/SimplePlan/CreateSimplePlan/CreateSimplePlan.jsx index 10a37ccfe..c96add512 100644 --- a/src/projects/detail/components/SimplePlan/CreateSimplePlan/CreateSimplePlan.jsx +++ b/src/projects/detail/components/SimplePlan/CreateSimplePlan/CreateSimplePlan.jsx @@ -39,6 +39,7 @@ class CreateSimplePlan extends React.Component { onChangeMilestones, onSaveMilestone, onRemoveMilestone, + onRemoveAllMilestones, onGetChallenges, onApproveMilestones, isProjectLive, @@ -78,6 +79,7 @@ class CreateSimplePlan extends React.Component { onChangeMilestones={onChangeMilestones} onSaveMilestone={onSaveMilestone} onRemoveMilestone={onRemoveMilestone} + onRemoveAllMilestones={onRemoveAllMilestones} onApproveMilestones={onApproveMilestones} projectMembers={project.members} project={project} @@ -97,6 +99,7 @@ CreateSimplePlan.propTypes = { onChangeMilestones: PT.func, onSaveMilestone: PT.func, onRemoveMilestone: PT.func, + onRemoveAllMilestones: PT.func, onGetChallenges: PT.func, onApproveMilestones: PT.func, isCustomer: PT.bool, diff --git a/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx b/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx index 31d19298f..0fd2b913b 100644 --- a/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx +++ b/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx @@ -16,7 +16,7 @@ import MilestoneMoveDateButton from '../components/MilestoneMoveDateButton' import * as milestoneHelper from '../components/helpers/milestone' import IconUnselect from '../../../../../assets/icons/icon-disselect.svg' import IconCopilot from '../../../../../assets/icons/icon-copilot.svg' -import { CHALLENGE_ID_MAPPING, PHASE_STATUS_IN_REVIEW } from '../../../../../config/constants' +import { CHALLENGE_ID_MAPPING, PHASE_STATUS_IN_REVIEW, PROJECT_STATUS_CANCELLED, PROJECT_STATUS_COMPLETED } from '../../../../../config/constants' import './ManageMilestones.scss' import MilestoneApprovalButton from '../components/MilestoneApprovalButton' @@ -84,11 +84,14 @@ class ManageMilestones extends React.Component { } onDeleteAll() { - const { milestones, onRemoveMilestone } = this.props - const seletedMilestones = _.filter(milestones, m => m.selected) - _.forEach(seletedMilestones, m => { - onRemoveMilestone(m.id) - }) + const { milestones, onRemoveAllMilestones } = this.props + const selectedPhases = _.filter(milestones, m => m.selected) + + if (selectedPhases.length) { + const { projectId } = selectedPhases[0] + const phaseIds = selectedPhases.map(m => m.id) + onRemoveAllMilestones(projectId, phaseIds) + } } onUnselectAll() { @@ -256,8 +259,11 @@ class ManageMilestones extends React.Component { onChangeMilestones, isUpdatable, isCustomer, + project, } = this.props + const hideCheckbox = project.status === PROJECT_STATUS_CANCELLED || project.status === PROJECT_STATUS_COMPLETED + // const isNeedApproval = project.status === PROJECT_STATUS_IN_REVIEW const isNeedApproval = !milestones.filter(ms => ms.selected === true).find(ms => !(ms.status === PHASE_STATUS_IN_REVIEW)) const canShowApproval = isCustomer && isNeedApproval @@ -325,7 +331,7 @@ class ManageMilestones extends React.Component {
| : null} - |
- |
+ + { + hideCheckbox ? null : |
+ |
+ }
MILESTONE | DESCRIPTION | START DATE | @@ -54,6 +56,7 @@ function MilestoneHeaderRow ({ milestones, onChangeMilestones, isUpdatable }) { MilestoneHeaderRow.propTypes = { onChangeMilestones: PT.func, + hideCheckbox: PT.bool, } export default MilestoneHeaderRow diff --git a/src/projects/detail/components/SimplePlan/components/MilestoneRow/MilestoneRow.jsx b/src/projects/detail/components/SimplePlan/components/MilestoneRow/MilestoneRow.jsx index 47ebf9e32..f14a3c4c5 100644 --- a/src/projects/detail/components/SimplePlan/components/MilestoneRow/MilestoneRow.jsx +++ b/src/projects/detail/components/SimplePlan/components/MilestoneRow/MilestoneRow.jsx @@ -45,7 +45,8 @@ function MilestoneRow({ phaseMembers, disableDeleteAction, isCustomer, - isApproving + isApproving, + hideCheckbox }) { const isNeedApproval = milestone.status === PHASE_STATUS_IN_REVIEW const showApproval = isCustomer && isNeedApproval @@ -58,11 +59,12 @@ function MilestoneRow({ let milestoneRef let startDateRef let endDateRef + const tdEl = hideCheckbox ? null :return edit ? ( | ||
|---|---|---|---|---|---|---|---|---|---|
| : null} - {isEditingMilestone ? | : | + {(isEditingMilestone || hideCheckbox) ? | : |
| onExpand(!isExpand, milestone)}>{isExpand ? | : }
- {isEditingMilestone ? | : |
+ {(isEditingMilestone || hideCheckbox) ? tdEl : |
| |