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
5 changes: 5 additions & 0 deletions src/api/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
}
5 changes: 5 additions & 0 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/config/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 17 additions & 1 deletion src/projects/actions/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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')
}
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CreateSimplePlan extends React.Component {
onChangeMilestones,
onSaveMilestone,
onRemoveMilestone,
onRemoveAllMilestones,
onGetChallenges,
onApproveMilestones,
isProjectLive,
Expand Down Expand Up @@ -78,6 +79,7 @@ class CreateSimplePlan extends React.Component {
onChangeMilestones={onChangeMilestones}
onSaveMilestone={onSaveMilestone}
onRemoveMilestone={onRemoveMilestone}
onRemoveAllMilestones={onRemoveAllMilestones}
onApproveMilestones={onApproveMilestones}
projectMembers={project.members}
project={project}
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -325,7 +331,7 @@ class ManageMilestones extends React.Component {
<table styleName="milestones-table">
<colgroup>
<col style={{ width: '20px' }} />
<col style={{ width: '20px' }} />{/* CHECKBOX */}
{hideCheckbox ? null : <col style={{ width: '20px' }} />}{/* CHECKBOX */}
<col style={{ width: '8%' }} />{/* MILESTONE */}
<col />{/* DESCRIPTION */}
<col style={{ width: '12%' }} />{/* START DATE */}
Expand All @@ -339,6 +345,7 @@ class ManageMilestones extends React.Component {
milestones={milestones}
onChangeMilestones={onChangeMilestones}
isUpdatable={isUpdatable || isCustomer}
hideCheckbox={hideCheckbox}
/>
</thead>
<tbody>
Expand All @@ -365,6 +372,7 @@ class ManageMilestones extends React.Component {
onApprove={this.onApprove}
phaseMembers={milestone.members}
isApproving={milestonesInApproval.indexOf(milestone.id) !== -1}
hideCheckbox={hideCheckbox}
/>,
...this.renderChallengeTable(milestone)
]
Expand All @@ -383,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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,16 +31,18 @@ function MilestoneHeaderRow ({ milestones, onChangeMilestones, isUpdatable }) {

return (
<tr styleName="milestone-row">
{isUpdatable ? <th />: null}
<th>
<TCFormFields.Checkbox
name="select-all"
value={checked}
onChange={(_, value) => {
value ? selectAll() : unselectAll()
}}
/>
</th>
<th />
{
hideCheckbox ? null : <th>
<TCFormFields.Checkbox
name="select-all"
value={checked}
onChange={(_, value) => {
value ? selectAll() : unselectAll()
}}
/>
</th>
}
<th>MILESTONE</th>
<th>DESCRIPTION</th>
<th>START DATE</th>
Expand All @@ -54,6 +56,7 @@ function MilestoneHeaderRow ({ milestones, onChangeMilestones, isUpdatable }) {

MilestoneHeaderRow.propTypes = {
onChangeMilestones: PT.func,
hideCheckbox: PT.bool,
}

export default MilestoneHeaderRow
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function MilestoneRow({
phaseMembers,
disableDeleteAction,
isCustomer,
isApproving
isApproving,
hideCheckbox
}) {
const isNeedApproval = milestone.status === PHASE_STATUS_IN_REVIEW
const showApproval = isCustomer && isNeedApproval
Expand All @@ -58,11 +59,12 @@ function MilestoneRow({
let milestoneRef
let startDateRef
let endDateRef
const tdEl = hideCheckbox ? null : <td/>

return edit ? (
<tr styleName="milestone-row" className="edit-milestone-row">
{isUpdatable ? <td /> : null}
{isEditingMilestone ? <td/ >: <td styleName="checkbox">
{(isEditingMilestone || hideCheckbox) ? <td/ >: <td styleName="checkbox">
<TCFormFields.Checkbox
name={`select-${rowId}`}
value={milestone.selected}
Expand Down Expand Up @@ -301,7 +303,7 @@ function MilestoneRow({
) : (
<tr styleName="milestone-row">
{isUpdatable ? <td styleName="expand" onClick={() => onExpand(!isExpand, milestone)}>{isExpand ? <IconClose />: <IconExpand />}</td>: <td />}
{isEditingMilestone ? <td/> : <td styleName="checkbox">
{(isEditingMilestone || hideCheckbox) ? tdEl : <td styleName="checkbox">
<TCFormFields.Checkbox
name={`select-${rowId}`}
value={milestone.selected}
Expand Down Expand Up @@ -402,6 +404,7 @@ MilestoneRow.propTypes = {
disableDeleteAction: PT.bool,
isCustomer: PT.bool,
members: PT.object,
hideCheckbox: PT.bool,
}

export default MilestoneRow
Loading