From 6dce7b4ecfb9148d4d67003afb949321fa34aa32 Mon Sep 17 00:00:00 2001 From: Nursoltan Saipolda Date: Fri, 24 Sep 2021 17:36:00 +0800 Subject: [PATCH 1/5] Fix table layout --- .../SimplePlan/ManageMilestones/ManageMilestones.jsx | 9 +++++++-- .../SimplePlan/components/MilestoneRow/MilestoneRow.jsx | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx b/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx index 31d19298f..9a8174352 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' @@ -256,8 +256,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 +328,7 @@ class ManageMilestones extends React.Component { - {/* CHECKBOX */} + {hideCheckbox ? null : }{/* CHECKBOX */} {/* MILESTONE */} {/* DESCRIPTION */} {/* START DATE */} @@ -339,6 +342,7 @@ class ManageMilestones extends React.Component { milestones={milestones} onChangeMilestones={onChangeMilestones} isUpdatable={isUpdatable || isCustomer} + hideCheckbox={hideCheckbox} /> @@ -365,6 +369,7 @@ class ManageMilestones extends React.Component { onApprove={this.onApprove} phaseMembers={milestone.members} isApproving={milestonesInApproval.indexOf(milestone.id) !== -1} + hideCheckbox={hideCheckbox} />, ...this.renderChallengeTable(milestone) ] 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 : {isUpdatable ? : - {isUpdatable ? + + } @@ -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/containers/DashboardContainer.jsx b/src/projects/detail/containers/DashboardContainer.jsx index e8b42b1f6..4c6d2a8bd 100644 --- a/src/projects/detail/containers/DashboardContainer.jsx +++ b/src/projects/detail/containers/DashboardContainer.jsx @@ -275,6 +275,8 @@ class DashboardContainer extends React.Component { ...action.payload, edit: this.state.createGameplanPhases[idx].edit, selected: this.state.createGameplanPhases[idx].selected, + products: this.state.createGameplanPhases[idx].products, + challenges: this.state.createGameplanPhases[idx].challenges, members }) this.setState({ createGameplanPhases: updatedCreateGameplanPhases }) From 0682daf971246b7337f2e1af4d427fa1d7f57e92 Mon Sep 17 00:00:00 2001 From: Nursoltan Saipolda Date: Fri, 24 Sep 2021 17:43:16 +0800 Subject: [PATCH 3/5] add permission copilot user to remove copilot --- src/config/permissions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config/permissions.js b/src/config/permissions.js index 82e33250d..774cc60c3 100644 --- a/src/config/permissions.js +++ b/src/config/permissions.js @@ -253,7 +253,8 @@ export const PERMISSIONS = { ], topcoderRoles: [ ...TOPCODER_ADMINS, - ROLE_CONNECT_COPILOT_MANAGER + ROLE_CONNECT_COPILOT_MANAGER, + ROLE_CONNECT_COPILOT ] }, From a3a067b81d9c146bfb6c425d96a93451e9da7c33 Mon Sep 17 00:00:00 2001 From: Nursoltan Saipolda Date: Fri, 24 Sep 2021 20:05:52 +0800 Subject: [PATCH 4/5] add bulk delete phases functionality --- src/api/projects.js | 5 +++++ src/config/constants.js | 5 +++++ src/projects/actions/project.js | 13 ++++++++++++- .../CreateSimplePlan/CreateSimplePlan.jsx | 3 +++ .../ManageMilestones/ManageMilestones.jsx | 14 +++++++++----- .../detail/containers/DashboardContainer.jsx | 19 +++++++++++++++++++ src/projects/reducers/project.js | 15 ++++++++++++++- src/reducers/alerts.js | 13 ++++++++++++- 8 files changed, 79 insertions(+), 8 deletions(-) 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/projects/actions/project.js b/src/projects/actions/project.js index 6bcb8aff7..3030de8b8 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, @@ -441,6 +443,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 9a8174352..0fd2b913b 100644 --- a/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx +++ b/src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx @@ -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() { @@ -388,6 +391,7 @@ ManageMilestones.propTypes = { onChangeMilestones: PT.func, onSaveMilestone: PT.func, onRemoveMilestone: PT.func, + onRemoveAllMilestones: PT.func, onGetChallenges: PT.func, onApproveMilestones: PT.func, projectMembers: PT.arrayOf(PT.shape()), diff --git a/src/projects/detail/containers/DashboardContainer.jsx b/src/projects/detail/containers/DashboardContainer.jsx index 4c6d2a8bd..2789fecf3 100644 --- a/src/projects/detail/containers/DashboardContainer.jsx +++ b/src/projects/detail/containers/DashboardContainer.jsx @@ -26,6 +26,7 @@ import { fireProductDirty, fireProductDirtyUndo, deleteProjectPhase, + deleteBulkProjectPhase, expandProjectPhase, collapseProjectPhase, collapseAllProjectPhases, @@ -94,6 +95,7 @@ class DashboardContainer extends React.Component { this.onChangeMilestones = this.onChangeMilestones.bind(this) this.onSaveMilestone = this.onSaveMilestone.bind(this) this.onRemoveMilestone = this.onRemoveMilestone.bind(this) + this.onRemoveAllMilestones = this.onRemoveAllMilestones.bind(this) this.onGetChallenges = this.onGetChallenges.bind(this) this.onApproveMilestones = this.onApproveMilestones.bind(this) } @@ -323,6 +325,21 @@ class DashboardContainer extends React.Component { }) } + onRemoveAllMilestones(projectId, phaseIds) { + this.props.deleteBulkProjectPhase( + projectId, + phaseIds + ).then(() => { + if (!this.state.createGameplanPhases) { + return + } + + // remove phases + const newGameplanPhases = this.state.createGameplanPhases.filter(phase => !phaseIds.includes(phase.id)) + this.setState({createGameplanPhases: newGameplanPhases}) + }) + } + render() { const { @@ -525,6 +542,7 @@ class DashboardContainer extends React.Component { onSaveMilestone={this.onSaveMilestone} onGetChallenges={this.onGetChallenges} onRemoveMilestone={this.onRemoveMilestone} + onRemoveAllMilestones={this.onRemoveAllMilestones} onApproveMilestones={this.onApproveMilestones} /> ) @@ -577,6 +595,7 @@ const mapDispatchToProps = { updateProductAttachment, removeProductAttachment, deleteProjectPhase, + deleteBulkProjectPhase, expandProjectPhase, collapseProjectPhase, collapseAllProjectPhases, diff --git a/src/projects/reducers/project.js b/src/projects/reducers/project.js index d6b11b9f0..b04a79c62 100644 --- a/src/projects/reducers/project.js +++ b/src/projects/reducers/project.js @@ -26,7 +26,7 @@ import { ACCEPT_OR_REFUSE_INVITE_SUCCESS, ACCEPT_OR_REFUSE_INVITE_FAILURE, ACCEPT_OR_REFUSE_INVITE_PENDING, UPLOAD_PROJECT_ATTACHMENT_FILES, DISCARD_PROJECT_ATTACHMENT, CHANGE_ATTACHMENT_PERMISSION, CREATE_SCOPE_CHANGE_REQUEST_SUCCESS, APPROVE_SCOPE_CHANGE_SUCCESS, REJECT_SCOPE_CHANGE_SUCCESS, CANCEL_SCOPE_CHANGE_SUCCESS, ACTIVATE_SCOPE_CHANGE_SUCCESS, - LOAD_PROJECT_MEMBERS_SUCCESS, LOAD_PROJECT_MEMBER_INVITES_SUCCESS, LOAD_PROJECT_MEMBER_SUCCESS, CREATE_PROJECT_PHASE_PENDING, CREATE_PROJECT_PHASE_SUCCESS, CUSTOMER_APPROVE_MILESTONE_PENDING, CUSTOMER_APPROVE_MILESTONE_FINISHED, + LOAD_PROJECT_MEMBERS_SUCCESS, LOAD_PROJECT_MEMBER_INVITES_SUCCESS, LOAD_PROJECT_MEMBER_SUCCESS, CREATE_PROJECT_PHASE_PENDING, CREATE_PROJECT_PHASE_SUCCESS, CUSTOMER_APPROVE_MILESTONE_PENDING, CUSTOMER_APPROVE_MILESTONE_FINISHED, DELETE_BULK_PROJECT_PHASE_PENDING, DELETE_BULK_PROJECT_PHASE_SUCCESS, } from '../../config/constants' import _ from 'lodash' import update from 'react-addons-update' @@ -519,6 +519,7 @@ export const projectState = function (state=initialState, action) { case UPDATE_PROJECT_PENDING: case UPDATE_PHASE_PENDING: case DELETE_PROJECT_PHASE_PENDING: + case DELETE_BULK_PROJECT_PHASE_PENDING: return Object.assign({}, state, { isLoading: false, processing: true, @@ -562,6 +563,18 @@ export const projectState = function (state=initialState, action) { }) } + case DELETE_BULK_PROJECT_PHASE_SUCCESS: { + const { phaseIds } = action.payload + + const newPhases = state.phases.filter(phase => !phaseIds.includes(phase.id)) + + return Object.assign({}, state, { + phases: newPhases, + phasesNonDirty: newPhases, + processing: false, + }) + } + case UPDATE_PRODUCT_SUCCESS: return { ...state, diff --git a/src/reducers/alerts.js b/src/reducers/alerts.js index da1b345e3..6de87290c 100644 --- a/src/reducers/alerts.js +++ b/src/reducers/alerts.js @@ -77,7 +77,8 @@ import { CUSTOMER_APPROVE_MILESTONE_APPROVE_SUCCESS, CUSTOMER_APPROVE_MILESTONE_REJECT_SUCCESS, CUSTOMER_APPROVE_MILESTONE_APPROVE_FAILURE, - CUSTOMER_APPROVE_MILESTONE_REJECT_FAILURE + CUSTOMER_APPROVE_MILESTONE_REJECT_FAILURE, + DELETE_BULK_PROJECT_PHASE_SUCCESS } from '../config/constants' /* eslint-enable no-unused-vars */ @@ -112,6 +113,16 @@ export default function(state = {}, action) { return state } + case DELETE_BULK_PROJECT_PHASE_SUCCESS: { + if (state.project.version === 'v4') { + Alert.success('Project milestones deleted.') + } else { + Alert.success('Project phases deleted.') + } + + return state + } + case DELETE_PROJECT_SUCCESS: Alert.success('Project deleted.') return state From 8805263c6f60f64061e5977ffb0cc20f82f232a6 Mon Sep 17 00:00:00 2001 From: Nursoltan Saipolda Date: Fri, 24 Sep 2021 22:47:14 +0800 Subject: [PATCH 5/5] fix layout issue --- .../components/MilestoneHeaderRow/MilestoneHeaderRow.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx b/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx index d3527285d..b59849839 100644 --- a/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx +++ b/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx @@ -33,7 +33,7 @@ function MilestoneHeaderRow ({ milestones, onChangeMilestones, isUpdatable, hide
return edit ? (
: null} - {isEditingMilestone ? : + {(isEditingMilestone || hideCheckbox) ? : {isUpdatable ? onExpand(!isExpand, milestone)}>{isExpand ? : }} - {isEditingMilestone ? : + {(isEditingMilestone || hideCheckbox) ? tdEl : Date: Fri, 24 Sep 2021 17:36:13 +0800 Subject: [PATCH 2/5] fix save copilot issue --- .../MilestoneHeaderRow/MilestoneHeaderRow.jsx | 25 +++++++++++-------- .../detail/containers/DashboardContainer.jsx | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx b/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx index 7e940a433..d3527285d 100644 --- a/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx +++ b/src/projects/detail/components/SimplePlan/components/MilestoneHeaderRow/MilestoneHeaderRow.jsx @@ -9,7 +9,7 @@ import './MilestoneHeaderRow.scss' const TCFormFields = FormsyForm.Fields -function MilestoneHeaderRow ({ milestones, onChangeMilestones, isUpdatable }) { +function MilestoneHeaderRow ({ milestones, onChangeMilestones, isUpdatable, hideCheckbox }) { const checked = milestones.reduce( (selected, milestone) => selected = selected && milestone.selected, milestones.length > 0 @@ -31,16 +31,18 @@ function MilestoneHeaderRow ({ milestones, onChangeMilestones, isUpdatable }) { return (
: null} - - { - value ? selectAll() : unselectAll() - }} - /> - + { + hideCheckbox ? : + { + value ? selectAll() : unselectAll() + }} + /> + MILESTONE DESCRIPTION START DATE
{ - hideCheckbox ? : + hideCheckbox ? null :