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
9 changes: 1 addition & 8 deletions src/api/projects.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'
import { axiosInstance as axios } from './requestInterceptor'
import { TC_API_URL, PROJECTS_API_URL, PROJECTS_LIST_PER_PAGE } from '../config/constants'
import { PROJECTS_API_URL, PROJECTS_LIST_PER_PAGE } from '../config/constants'

export function getProjects(criteria, pageNum) {
// add default params
Expand Down Expand Up @@ -211,13 +211,6 @@ export function deleteProject(projectId) {
})
}

export function getDirectProjectData(directProjectId) {
return axios.get(`${TC_API_URL}/v3/direct/projects/${directProjectId}`)
.then(resp => {
return resp.data.result.content
})
}

export function deleteProjectPhase(projectId, phaseId) {
return axios.delete(`${PROJECTS_API_URL}/v5/projects/${projectId}/phases/${phaseId}`)
.then(() => ({ projectId, phaseId }))
Expand Down
4 changes: 1 addition & 3 deletions src/components/ProjectInfo/ProjectInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ProjectInfo extends Component {
}

render() {
const { project, currentMemberRole, duration,
const { project, currentMemberRole,
onChangeStatus, isSuperUser, phases, onSubmitForReview, isProjectProcessing,
showDeleteConfirm, toggleProjectDelete, onConfirmDelete } = this.props

Expand Down Expand Up @@ -90,7 +90,6 @@ class ProjectInfo extends Component {
project={project}
projectCanBeActive={projectCanBeActive}
currentMemberRole={currentMemberRole}
duration={duration}
descLinesCount={
/* has to be not too big value here,
because the plugin will make this number of iterations
Expand All @@ -116,7 +115,6 @@ class ProjectInfo extends Component {
ProjectInfo.propTypes = {
project: PT.object.isRequired,
currentMemberRole: PT.string,
duration: PT.object.isRequired,
productsTimelines: PT.object.isRequired,
updateProject: PT.func,
isProjectProcessing: PT.bool,
Expand Down
6 changes: 0 additions & 6 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ export const LOAD_PROJECT_DASHBOARD_PENDING = 'LOAD_PROJECT_DASHBOARD_PENDIN
export const LOAD_PROJECT_DASHBOARD_FAILURE = 'LOAD_PROJECT_DASHBOARD_FAILURE'
export const LOAD_PROJECT_DASHBOARD_SUCCESS = 'LOAD_PROJECT_DASHBOARD_SUCCESS'

// Direct Project Data
export const LOAD_DIRECT_PROJECT = 'LOAD_DIRECT_PROJECT'
export const LOAD_DIRECT_PROJECT_PENDING = 'LOAD_DIRECT_PROJECT_PENDING'
export const LOAD_DIRECT_PROJECT_FAILURE = 'LOAD_DIRECT_PROJECT_FAILURE'
export const LOAD_DIRECT_PROJECT_SUCCESS = 'LOAD_DIRECT_PROJECT_SUCCESS'

// Direct Project Data
export const LOAD_ADDITIONAL_PROJECT_DATA = 'LOAD_ADDITIONAL_PROJECT_DATA'
export const LOAD_ADDITIONAL_PROJECT_DATA_PENDING = 'LOAD_ADDITIONAL_PROJECT_DATA_PENDING'
Expand Down
71 changes: 0 additions & 71 deletions src/helpers/projectHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,52 +35,6 @@ export const getProjectRoleForCurrentUser = ({currentUserId, project}) => {
return role
}

export const setDuration = ({duration, status}) => {
let percent =''
let title = ''
let text = ''
let type = 'completed' // default
if (duration && duration.plannedDuration) {
const {actualDuration, plannedDuration} = duration
if (status === 'draft') {
title = 'Duration'
percent = 0
text = 'Complete specification to get estimate'
} else if (status === 'in_review') {
title = 'Duration'
percent = 0
text = 'Pending review'
} else if (status === 'reviewed') {
title = `${plannedDuration} days (projected)`
percent = 0
text = `${plannedDuration} days remaining`
} else if (status === 'completed') {
title = 'Completed'
percent = 100
text = ''
type = 'completed'
} else {
text = `Day ${actualDuration} of ${plannedDuration}`
percent = actualDuration / plannedDuration * 100
if (0 <= percent && percent < 100) {
const diff = plannedDuration - actualDuration
title = `${diff} ${diff > 1 ? 'days' : 'day'} remaining`
type = 'working'
} else {
percent = 100
type = 'error'
const diff = actualDuration - plannedDuration
title = `${diff} ${diff > 1 ? 'days' : 'day'} over`
}
}
} else {
title = 'Duration'
percent = 0
text = status === 'draft' ? 'Complete specification to get estimate' : 'Estimate not entered'
}
return { title, text, percent, type }
}

/**
* Format ProjectProgress props
*
Expand Down Expand Up @@ -194,31 +148,6 @@ export function getProjectActualDuration(phases, productsTimelines) {
return projectedDuration
}

/**
* Format ProjectProgress props for old projects
*
* @param {Object} project project object
*
* @return {Object} ProjectProgress props
*/
export function formatOldProjectProgressProps(project) {
const actualDuration = _.get(project, 'duration.actualDuration', 0)
const projectedDuration = _.get(project, 'duration.projectedDuration', 0)
const actualCost = _.get(project, 'budget.actualCost', 0)

const progressPercent = projectedDuration !== 0 ? Math.round(actualDuration/projectedDuration) : 0
const labelDayStatus = `Day ${actualDuration} of ${projectedDuration}`
const labelSpent = `Spent $${formatNumberWithCommas(actualCost)}`
const labelStatus = `${progressPercent}% done`

return {
labelDayStatus,
labelSpent,
labelStatus,
progressPercent,
}
}

/**
* Gets actual data of the phase depend if phase has timeline or no
*
Expand Down
11 changes: 0 additions & 11 deletions src/projects/actions/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { getProjectById,
updateProject as updateProjectAPI,
deleteProject as deleteProjectAPI,
deleteProjectPhase as deleteProjectPhaseAPI,
getDirectProjectData,
getProjectPhases,
updateProduct as updateProductAPI,
updatePhase as updatePhaseAPI,
Expand All @@ -33,7 +32,6 @@ import {
CREATE_PROJECT_STAGE,
CLEAR_LOADED_PROJECT,
UPDATE_PROJECT,
LOAD_DIRECT_PROJECT,
DELETE_PROJECT,
PROJECT_DIRTY,
PROJECT_DIRTY_UNDO,
Expand Down Expand Up @@ -547,15 +545,6 @@ export function deleteProject(newProject) {
}
}

export function loadDirectProjectData(directProjectId) {
return (dispatch) => {
return dispatch({
type: LOAD_DIRECT_PROJECT,
payload: getDirectProjectData(directProjectId)
})
}
}

export function fireProjectDirty(dirtyProject) {
return (dispatch) => {
return dispatch({
Expand Down
6 changes: 1 addition & 5 deletions src/projects/actions/projectDashboard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash'
import { loadProject, loadProjectInvite, loadDirectProjectData, loadProjectMembers, loadProjectMemberInvites } from './project'
import { loadProject, loadProjectInvite, loadProjectMembers, loadProjectMemberInvites } from './project'
import { loadProjectPlan } from './projectPlan'
import { loadProjectsMetadata } from '../../actions/templates'
import { LOAD_PROJECT_DASHBOARD, LOAD_ADDITIONAL_PROJECT_DATA } from '../../config/constants'
Expand Down Expand Up @@ -32,10 +32,6 @@ const getDashboardData = (dispatch, getState, projectId, isOnlyLoadProjectInfo)
promises = []
}

if (project.directProjectId && !isOnlyLoadProjectInfo) {
promises.push(dispatch(loadDirectProjectData(project.directProjectId)))
}

// for new projects load phases, products, project template and product templates
if (project.version === 'v3') {
promises.push(
Expand Down
4 changes: 1 addition & 3 deletions src/projects/components/projectsCard/ProjectCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ProjectManagerAvatars from '../../list/components/Projects/ProjectManager
import Invitation from '../../../components/Invitation/Invitation'
import './ProjectCard.scss'

function ProjectCard({ project, duration, disabled, currentUser, history, onChangeStatus, projectTemplates, unreadMentionsCount, callInviteRequest, isAcceptingInvite }) {
function ProjectCard({ project, disabled, currentUser, history, onChangeStatus, projectTemplates, unreadMentionsCount, callInviteRequest, isAcceptingInvite }) {
const className = `ProjectCard ${ disabled ? 'disabled' : 'enabled'}`
if (!project) return null
const currentMemberRole = getProjectRoleForCurrentUser({ project, currentUserId: currentUser.userId})
Expand All @@ -31,7 +31,6 @@ function ProjectCard({ project, duration, disabled, currentUser, history, onChan
<ProjectCardBody
project={project}
currentMemberRole={currentMemberRole}
duration={duration}
onChangeStatus={onChangeStatus}
showLink
showLinkURL={`/projects/${project.id}/specification`}
Expand Down Expand Up @@ -70,7 +69,6 @@ ProjectCard.propTypes = {
unreadMentionsCount: PT.number.isRequired,
callInviteRequest: PT.func,
isAcceptingInvite: PT.bool
// duration: PT.object.isRequired,
}

export default withRouter(ProjectCard)
9 changes: 1 addition & 8 deletions src/projects/components/projectsCard/ProjectCardBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import PT from 'prop-types'
import TextTruncate from 'react-text-truncate'
import { Link } from 'react-router-dom'
import ProjectProgress from '../../../components/ProjectProgress/ProjectProgress'
import ProjectStatus from '../../../components/ProjectStatus/ProjectStatus'
import editableProjectStatus from '../../../components/ProjectStatus/editableProjectStatus'
import {
Expand All @@ -17,7 +16,7 @@ import _ from 'lodash'

const EnhancedProjectStatus = editableProjectStatus(ProjectStatus)

function ProjectCardBody({ project, projectCanBeActive, duration, currentMemberRole, descLinesCount = 8,
function ProjectCardBody({ project, projectCanBeActive, currentMemberRole, descLinesCount = 8,
onChangeStatus, isSuperUser, showLink, showLinkURL, canEditStatus = true, hideStatus }) {
if (!project) return null

Expand Down Expand Up @@ -61,11 +60,6 @@ function ProjectCardBody({ project, projectCanBeActive, duration, currentMemberR
projectId={project.id}
/>
}
{(project.status === PROJECT_STATUS_ACTIVE && progress !== 0) &&
<ProjectProgress {...duration} viewType={ProjectProgress.ViewTypes.CIRCLE} percent={progress}>
<span className="progress-text">{progress}% completed</span>
</ProjectProgress>
}
</div>}
</div>
)
Expand All @@ -82,7 +76,6 @@ ProjectCardBody.propTypes = {
project: PT.object.isRequired,
projectCanBeActive: PT.bool,
currentMemberRole: PT.string,
duration: PT.object.isRequired,
showLink: PT.bool,
showLinkURL: PT.string,
canEditStatus: PT.bool,
Expand Down
3 changes: 0 additions & 3 deletions src/projects/components/projectsCard/ProjectsCardView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ProjectCard from './ProjectCard'
import NewProjectCard from './NewProjectCard'
import cn from 'classnames'
import { PROJECTS_LIST_PER_PAGE } from '../../../config/constants'
import { setDuration } from '../../../helpers/projectHelper'
import {
filterReadNotifications,
filterNotificationsByProjectId,
Expand Down Expand Up @@ -37,7 +36,6 @@ const ProjectsCardView = props => {
})

const renderProject = (project) => {
const duration = setDuration({}, project.status)
//const { notifications } = this.props;
const notReadNotifications = filterReadNotifications(notifications)
const unreadProjectUpdate = filterNotificationsByProjectId(notReadNotifications, project.id)
Expand All @@ -47,7 +45,6 @@ const ProjectsCardView = props => {
<ProjectCard
project={project}
currentUser={currentUser}
duration={duration}
onChangeStatus={onChangeStatus}
projectTemplates={projectTemplates}
unreadMentionsCount={unreadMentionsCount}
Expand Down
17 changes: 3 additions & 14 deletions src/projects/detail/containers/ProjectInfoContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { updateProject, deleteProject } from '../../actions/project'
import { loadDashboardFeeds, loadProjectMessages } from '../../actions/projectTopics'
import { loadTopic } from '../../../actions/topics'
import { loadProjectPlan } from '../../actions/projectPlan'
import { setDuration, getProjectNavLinks } from '../../../helpers/projectHelper'
import { getProjectNavLinks } from '../../../helpers/projectHelper'
import {
PROJECT_ROLE_OWNER,
PROJECT_ROLE_COPILOT,
Expand Down Expand Up @@ -56,7 +56,6 @@ class ProjectInfoContainer extends React.Component {
constructor(props) {
super(props)
this.state = {
duration: {},
showDeleteConfirm: false
}
this.onChangeStatus = this.onChangeStatus.bind(this)
Expand Down Expand Up @@ -95,16 +94,9 @@ class ProjectInfoContainer extends React.Component {
nextProps.activeChannelId !== this.props.activeChannelId
}

setDuration({duration, status}) {

this.setState({duration: setDuration(duration || {}, status)})
}

componentWillMount() {
const { project, isFeedsLoading, feeds, phases, phasesTopics, loadTopic, location } = this.props

this.setDuration(project)

// load feeds from dashboard if they are not currently loading or loaded yet
// also it will load feeds, if we already loaded them, but it was 0 feeds before
if (!isFeedsLoading && feeds.length < 1) {
Expand All @@ -126,9 +118,7 @@ class ProjectInfoContainer extends React.Component {
}

componentWillReceiveProps(props) {
const { project, location } = props

this.setDuration(project)
const { location } = props

if (!_.isEmpty(location.hash) && location.hash !== this.props.location.hash) {
this.handleUrlHash(props)
Expand Down Expand Up @@ -431,7 +421,7 @@ class ProjectInfoContainer extends React.Component {
}

render() {
const { duration, showDeleteConfirm } = this.state
const { showDeleteConfirm } = this.state
const { project, currentMemberRole, isSuperUser, phases, hideInfo, hideMembers,
productsTimelines, isProjectProcessing, notifications } = this.props
let directLinks = null
Expand Down Expand Up @@ -518,7 +508,6 @@ class ProjectInfoContainer extends React.Component {
project={project}
phases={phases}
currentMemberRole={currentMemberRole}
duration={duration}
canDeleteProject={canDeleteProject}
onDeleteProject={this.onDeleteProject}
onChangeStatus={this.onChangeStatus}
Expand Down
Loading