Skip to content

Commit

Permalink
Merge pull request #4455 from appirio-tech/dev
Browse files Browse the repository at this point in the history
[PROD] Milestone Management
  • Loading branch information
RishiRajSahu committed Aug 16, 2021
2 parents ac24c7f + 9cca4dc commit 9d53191
Show file tree
Hide file tree
Showing 43 changed files with 1,263 additions and 350 deletions.
9 changes: 9 additions & 0 deletions src/api/phaseMembers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { axiosInstance as axios } from './requestInterceptor'
import { PROJECTS_API_URL } from '../config/constants'

export function updatePhaseMembers(projectId, phaseId, userIds) {
const url = `${PROJECTS_API_URL}/v5/projects/${projectId}/phases/${phaseId}/members`
const data = { userIds }
return axios.post(url, data)
.then(res => res.data)
}
13 changes: 13 additions & 0 deletions src/api/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ export function getProjectSuggestions() {
// TODO
}

/**
* Get a challenge detail based on it's id
* @param {integer} challenId challenge id
* @return {object} challenge detail returned by api
*/
export function getChallengeById(challengeId) {
return axios.get(`${PROJECTS_API_URL}/v5/challenges/${challengeId}/`)
.then(resp => {
const res = resp.data
return res
})
}


/**
* Get a project based on it's id
Expand Down
36 changes: 36 additions & 0 deletions src/assets/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/icon-calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/icon-calendar2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/icon-copilot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/icon-delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/assets/icons/icon-disselect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/icon-save2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/icon-trash2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/icons/icon-ui-pencil.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/icons/icon-ui-trash-simple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export const LOAD_USER_CREDENTIAL_PENDING = 'LOAD_USER_CREDENTIAL_PENDING'
export const LOAD_USER_CREDENTIAL_SUCCESS = 'LOAD_USER_CREDENTIAL_SUCCESS'
export const LOAD_USER_CREDENTIAL_FAILURE = 'LOAD_USER_CREDENTIAL_FAILURE'

// Load_CHALLEGNES
export const LOAD_CHALLEGNES = 'LOAD_CHALLEGNES'
export const LOAD_CHALLEGNES_PENDING = 'LOAD_CHALLEGNES_PENDING'
export const LOAD_CHALLEGNES_SUCCESS = 'LOAD_CHALLEGNES_SUCCESS'
export const LOAD_CHALLEGNES_FAILURE = 'Load_CHALLEGNES_FAILURE'

// Load organization configs
export const LOAD_ORG_CONFIG_SUCCESS = 'LOAD_ORG_CONFIG_SUCCESS'
Expand Down Expand Up @@ -753,6 +758,8 @@ export const PROJECT_ATTACHMENTS_FOLDER = process.env.PROJECT_ATTACHMENTS_FOLDER
export const FILE_PICKER_ACCEPT = process.env.FILE_PICKER_ACCEPT || ['.bmp', '.gif', '.jpg', '.tex', '.xls', '.xlsx', '.doc', '.docx', '.zip', '.txt', '.pdf', '.png', '.ppt', '.pptx', '.rtf', '.csv']

export const SEGMENT_KEY = process.env.CONNECT_SEGMENT_KEY

export const CHALLENGE_ID_MAPPING = 'challengeGuid'
/*
* URLs
*/
Expand All @@ -766,6 +773,7 @@ export const ACCOUNTS_APP_REGISTER_URL = process.env.ACCOUNTS_APP_REGISTER_URL |
export const TC_API_URL = `https://api.${DOMAIN}`
export const DIRECT_PROJECT_URL = `https://www.${DOMAIN}/direct/projectOverview?formData.projectId=`
export const WORK_MANAGER_APP = `https://challenges.${DOMAIN}/projects`
export const CHALLENGE_DETAIL_APP = `https://www.${DOMAIN}/challenges`
export const SALESFORCE_PROJECT_LEAD_LINK = process.env.SALESFORCE_PROJECT_LEAD_LINK
export const SALESFORCE_BILLING_ACCOUNT_LINK = process.env.SALESFORCE_BILLING_ACCOUNT_LINK
export const TC_NOTIFICATION_URL = process.env.TC_NOTIFICATION_URL || `${TC_API_URL}/v5/notifications`
Expand Down
10 changes: 10 additions & 0 deletions src/projects/actions/phaseMember.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { updatePhaseMembers as updatePhaseMembersAPI } from '../../api/phaseMembers'

export function updatePhaseMembers(projectId, phaseId, userIds) {
return (dispatch) => {
return dispatch({
type: 'UPDATE_PROJECT_PHASE_MEMBERS',
payload: updatePhaseMembersAPI(projectId, phaseId, userIds)
})
}
}
39 changes: 34 additions & 5 deletions src/projects/actions/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash'
import moment from 'moment'
import { flatten, unflatten } from 'flat'
import { getProjectById,
getChallengeById,
createProject as createProjectAPI,
updateProject as updateProjectAPI,
deleteProject as deleteProjectAPI,
Expand Down Expand Up @@ -36,6 +37,7 @@ import {
DELETE_PROJECT,
PROJECT_DIRTY,
PROJECT_DIRTY_UNDO,
LOAD_CHALLEGNES,
LOAD_PROJECT_PHASES,
UPDATE_PRODUCT,
PROJECT_STATUS_DRAFT,
Expand Down Expand Up @@ -161,6 +163,7 @@ export function loadProjectInvite(projectId) {
}*/
}


/**
* Get project phases together with products
*
Expand All @@ -187,12 +190,40 @@ function getProjectPhasesWithProducts(projectId) {
'spentBudget',
'startDate',
'status',
'members',
'updatedAt',
'updatedBy',
].join(',')
})
}

/**
* Get challenges by challenge ids
*
* @param {Number} milestoneId milestone id
* @param {Array} challengeIds challenge ids
*
* @returns {Promise<[]>} resolves to the list of challenge
*/
export function getChallengesByIds(milestoneId, challengeIds) {

const requests = _.map(challengeIds, id => getChallengeById(id))
const challengesAPIs = Promise.all(requests)

return (dispatch) => {
return dispatch({
type: LOAD_CHALLEGNES,
payload: challengesAPIs,
meta: {
milestoneId
}
})
}

}



/**
* Load project phases with populated products
*
Expand Down Expand Up @@ -286,14 +317,12 @@ function createProductsTimelineAndMilestone(project) {
*
* @return {Promise} project
*/
export function createProjectPhaseAndProduct(project, productTemplate, status = PHASE_STATUS_DRAFT, startDate, endDate, createTimeline = true, budget, details) {
export function createProjectPhaseAndProduct(project, productTemplate, status = PHASE_STATUS_DRAFT, startDate, endDate, createTimeline = true) {
const param = {
status,
name: productTemplate.name,
description: productTemplate.description,
productTemplateId: productTemplate.id,
budget,
details,
}
if (startDate) {
param['startDate'] = startDate.format('YYYY-MM-DD')
Expand Down Expand Up @@ -358,12 +387,12 @@ function createPhaseAndMilestonesRequest(project, productTemplate, status = PHAS
* @param {*} startDate
* @param {*} endDate
*/
export function createPhaseWithoutTimeline(project, productTemplate, status, startDate, endDate, budget, details) {
export function createPhaseWithoutTimeline(project, productTemplate, status, startDate, endDate) {
return (dispatch) => {
console.log(CREATE_PROJECT_PHASE)
return dispatch({
type: CREATE_PROJECT_PHASE,
payload: createProjectPhaseAndProduct(project, productTemplate, status, startDate, endDate, false, budget, details)
payload: createProjectPhaseAndProduct(project, productTemplate, status, startDate, endDate, false)
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import React from 'react'
import PT from 'prop-types'
import _ from 'lodash'
import GenericMenu from '../../../../../components/GenericMenu'
// import ProjectDetailsWidget from '../ProjectDetailsWidget'
import ManageMilestones from '../ManageMilestones'
Expand All @@ -21,19 +20,6 @@ const createTabs = ({ onClick } ) => ([

class CreateSimplePlan extends React.Component {
componentDidMount() {
const { project, milestones, loadMembers } = this.props

let copilotIds = []
milestones.forEach((milestone) => {
copilotIds = copilotIds.concat(_.get(milestone, 'details.copilots', []))
})

const projectMemberIds = project.members.map(member => member.userId)
const missingMemberIds = _.difference(copilotIds, projectMemberIds)
if (missingMemberIds.length) {
loadMembers(missingMemberIds)
}

const contentInnerElement = document.querySelector('.twoColsLayout-contentInner')
contentInnerElement.classList.add(styles['twoColsLayout-contentInner'])
}
Expand All @@ -51,8 +37,8 @@ class CreateSimplePlan extends React.Component {
onChangeMilestones,
onSaveMilestone,
onRemoveMilestone,
onGetChallenges,
isProjectLive,
members,
isCustomer,
} = this.props
const onClickMilestonesTab = () => {}
Expand Down Expand Up @@ -83,12 +69,12 @@ class CreateSimplePlan extends React.Component {
</div>
<ManageMilestones
milestones={milestones}
onGetChallenges={onGetChallenges}
onChangeMilestones={onChangeMilestones}
onSaveMilestone={onSaveMilestone}
onRemoveMilestone={onRemoveMilestone}
projectMembers={project.members}
isUpdatable={isProjectLive && !isCustomer}
members={members}
/>
</div>
</div>
Expand All @@ -103,7 +89,7 @@ CreateSimplePlan.propTypes = {
onChangeMilestones: PT.func,
onSaveMilestone: PT.func,
onRemoveMilestone: PT.func,
members: PT.object,
onGetChallenges: PT.func,
isCustomer: PT.bool,
}

Expand Down
Loading

0 comments on commit 9d53191

Please sign in to comment.