From b26f4f8d3f279059891b7c7a9b64280e59c4f2f4 Mon Sep 17 00:00:00 2001 From: Sumit Daga Date: Mon, 24 Feb 2020 13:49:10 +0530 Subject: [PATCH] removed unsed code, direct project, issue 3404 --- src/api/projects.js | 9 +-- src/components/ProjectInfo/ProjectInfo.jsx | 4 +- src/config/constants.js | 6 -- src/helpers/projectHelper.js | 71 ------------------- src/projects/actions/project.js | 11 --- src/projects/actions/projectDashboard.js | 6 +- .../components/projectsCard/ProjectCard.jsx | 4 +- .../projectsCard/ProjectCardBody.jsx | 9 +-- .../projectsCard/ProjectsCardView.jsx | 3 - .../detail/containers/ProjectInfoContainer.js | 17 +---- src/projects/reducers/project.js | 35 +-------- 11 files changed, 9 insertions(+), 166 deletions(-) diff --git a/src/api/projects.js b/src/api/projects.js index 5bc5dedec..559b5d55d 100644 --- a/src/api/projects.js +++ b/src/api/projects.js @@ -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 @@ -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 })) diff --git a/src/components/ProjectInfo/ProjectInfo.jsx b/src/components/ProjectInfo/ProjectInfo.jsx index 5de8c8916..1e84d942a 100644 --- a/src/components/ProjectInfo/ProjectInfo.jsx +++ b/src/components/ProjectInfo/ProjectInfo.jsx @@ -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 @@ -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 @@ -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, diff --git a/src/config/constants.js b/src/config/constants.js index 70ee6c5c5..8668b1537 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -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' diff --git a/src/helpers/projectHelper.js b/src/helpers/projectHelper.js index 656218281..a199155ca 100644 --- a/src/helpers/projectHelper.js +++ b/src/helpers/projectHelper.js @@ -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 * @@ -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 * diff --git a/src/projects/actions/project.js b/src/projects/actions/project.js index 2e451cf1b..c4955a613 100644 --- a/src/projects/actions/project.js +++ b/src/projects/actions/project.js @@ -7,7 +7,6 @@ import { getProjectById, updateProject as updateProjectAPI, deleteProject as deleteProjectAPI, deleteProjectPhase as deleteProjectPhaseAPI, - getDirectProjectData, getProjectPhases, updateProduct as updateProductAPI, updatePhase as updatePhaseAPI, @@ -33,7 +32,6 @@ import { CREATE_PROJECT_STAGE, CLEAR_LOADED_PROJECT, UPDATE_PROJECT, - LOAD_DIRECT_PROJECT, DELETE_PROJECT, PROJECT_DIRTY, PROJECT_DIRTY_UNDO, @@ -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({ diff --git a/src/projects/actions/projectDashboard.js b/src/projects/actions/projectDashboard.js index 6d2172330..b7d9db0de 100644 --- a/src/projects/actions/projectDashboard.js +++ b/src/projects/actions/projectDashboard.js @@ -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' @@ -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( diff --git a/src/projects/components/projectsCard/ProjectCard.jsx b/src/projects/components/projectsCard/ProjectCard.jsx index 289b748fd..47037d73c 100644 --- a/src/projects/components/projectsCard/ProjectCard.jsx +++ b/src/projects/components/projectsCard/ProjectCard.jsx @@ -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}) @@ -31,7 +31,6 @@ function ProjectCard({ project, duration, disabled, currentUser, history, onChan } - {(project.status === PROJECT_STATUS_ACTIVE && progress !== 0) && - - {progress}% completed - - } } ) @@ -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, diff --git a/src/projects/components/projectsCard/ProjectsCardView.jsx b/src/projects/components/projectsCard/ProjectsCardView.jsx index 23399f70e..5ddc14ba9 100644 --- a/src/projects/components/projectsCard/ProjectsCardView.jsx +++ b/src/projects/components/projectsCard/ProjectsCardView.jsx @@ -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, @@ -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) @@ -47,7 +45,6 @@ const ProjectsCardView = props => {