From affa78c916a11f0f1dd449519f37aaca046aa754 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Thu, 15 Jun 2023 10:31:55 -0700 Subject: [PATCH 01/87] component skeleton, render component in ReportActionList, show GBR on open task report LHN options --- src/components/LHNOptionsList/OptionRowLHN.js | 2 +- src/components/ReportActionItem/TaskAction.js | 2 +- .../ReportActionItem/TaskPreview.js | 9 +- src/components/ReportActionItem/TaskView.js | 50 ++++++++++ src/components/TaskHeader.js | 98 ++++--------------- src/languages/en.js | 10 +- src/languages/es.js | 9 +- src/libs/ReportUtils.js | 49 +++++++++- src/libs/SidebarUtils.js | 1 + src/libs/actions/Task.js | 5 - src/pages/home/HeaderView.js | 13 +-- src/pages/home/report/ReportActionItem.js | 4 + src/pages/tasks/NewTaskDetailsPage.js | 2 +- src/pages/tasks/NewTaskPage.js | 8 +- src/pages/tasks/NewTaskTitlePage.js | 4 +- src/pages/tasks/TaskAssigneeSelectorModal.js | 2 +- src/pages/tasks/TaskDescriptionPage.js | 2 +- src/pages/tasks/TaskTitlePage.js | 4 +- 18 files changed, 156 insertions(+), 118 deletions(-) create mode 100644 src/components/ReportActionItem/TaskView.js diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index 4d5e19299e5c..db4d8f931d89 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -83,7 +83,7 @@ function OptionRowLHN(props) { const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor; const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; - const shouldShowGreenDotIndicator = !hasBrickError && (optionItem.isUnreadWithMention || (optionItem.hasOutstandingIOU && !optionItem.isIOUReportOwner)); + const shouldShowGreenDotIndicator = !hasBrickError && (optionItem.isOpenTask || optionItem.isUnreadWithMention || (optionItem.hasOutstandingIOU && !optionItem.isIOUReportOwner)); /** * Show the ReportActionContextMenu modal popover. diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js index bdf8f374dde3..cf1cee86abf4 100644 --- a/src/components/ReportActionItem/TaskAction.js +++ b/src/components/ReportActionItem/TaskAction.js @@ -50,7 +50,7 @@ function TaskAction(props) { messageLinkText = props.translate('task.messages.reopened'); break; default: - messageLinkText = props.translate('newTaskPage.task'); + messageLinkText = props.translate('task.task'); } return ( diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 2ddf2def5e89..1e330cacfabe 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -15,7 +15,8 @@ import getButtonState from '../../libs/getButtonState'; import Navigation from '../../libs/Navigation/Navigation'; import ROUTES from '../../ROUTES'; import reportActionPropTypes from '../../pages/home/report/reportActionPropTypes'; -import * as TaskUtils from '../../libs/actions/Task'; +import * as Task from '../../libs/actions/Task'; +import * as ReportUtils from '../../libs/ReportUtils'; import RenderHTML from '../RenderHTML'; const propTypes = { @@ -70,12 +71,12 @@ function TaskPreview(props) { style={[styles.mr2]} containerStyle={[styles.taskCheckbox]} isChecked={isTaskCompleted} - disabled={TaskUtils.isTaskCanceled(props.taskReport)} + disabled={ReportUtils.isCanceledTaskReport(props.taskReport)} onPress={() => { if (isTaskCompleted) { - TaskUtils.reopenTask(props.taskReportID, taskTitle); + Task.reopenTask(props.taskReportID, taskTitle); } else { - TaskUtils.completeTask(props.taskReportID, taskTitle); + Task.completeTask(props.taskReportID, taskTitle); } }} /> diff --git a/src/components/ReportActionItem/TaskView.js b/src/components/ReportActionItem/TaskView.js new file mode 100644 index 000000000000..b8524bc10afe --- /dev/null +++ b/src/components/ReportActionItem/TaskView.js @@ -0,0 +1,50 @@ +import React from 'react'; +import {View} from 'react-native'; +import PropTypes from 'prop-types'; +import _ from 'underscore'; +import reportPropTypes from '../../pages/reportPropTypes'; +import withLocalize, {withLocalizePropTypes} from '../withLocalize'; +import participantPropTypes from '../participantPropTypes'; +import withWindowDimensions from '../withWindowDimensions'; +import compose from '../../libs/compose'; +import Navigation from '../../libs/Navigation/Navigation'; +import ROUTES from '../../ROUTES'; +import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; + +const propTypes = { + /** The report currently being looked at */ + report: reportPropTypes.isRequired, + + /** Personal details so we can get the ones for the report participants */ + personalDetails: PropTypes.objectOf(participantPropTypes).isRequired, + + ...withLocalizePropTypes, +}; + +function TaskView(props) { + return ( + + Navigation.navigate(ROUTES.getTaskReportTitleRoute(props.report.reportID))} + shouldShowRightIcon + /> + Navigation.navigate(ROUTES.getTaskReportDescriptionRoute(props.report.reportID))} + shouldShowRightIcon + /> + + ); +} + +TaskView.propTypes = propTypes; +TaskView.displayName = 'TaskView'; + +export default compose(withWindowDimensions, withLocalize)(TaskView); \ No newline at end of file diff --git a/src/components/TaskHeader.js b/src/components/TaskHeader.js index a44c841b87da..eadb03c4b99d 100644 --- a/src/components/TaskHeader.js +++ b/src/components/TaskHeader.js @@ -1,124 +1,62 @@ import React, {useEffect} from 'react'; import {View} from 'react-native'; -import PropTypes from 'prop-types'; -import lodashGet from 'lodash/get'; -import _ from 'underscore'; import reportPropTypes from '../pages/reportPropTypes'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import * as ReportUtils from '../libs/ReportUtils'; -import * as Expensicons from './Icon/Expensicons'; -import Text from './Text'; -import participantPropTypes from './participantPropTypes'; -import Avatar from './Avatar'; import styles from '../styles/styles'; import themeColors from '../styles/themes/default'; -import CONST from '../CONST'; -import withWindowDimensions from './withWindowDimensions'; +import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; import compose from '../libs/compose'; import Navigation from '../libs/Navigation/Navigation'; import ROUTES from '../ROUTES'; -import Icon from './Icon'; -import MenuItemWithTopDescription from './MenuItemWithTopDescription'; import Button from './Button'; -import * as TaskUtils from '../libs/actions/Task'; -import * as UserUtils from '../libs/UserUtils'; +import * as Task from '../libs/actions/Task'; import PressableWithFeedback from './Pressable/PressableWithFeedback'; const propTypes = { /** The report currently being looked at */ report: reportPropTypes.isRequired, - /** Personal details so we can get the ones for the report participants */ - personalDetails: PropTypes.objectOf(participantPropTypes).isRequired, - ...withLocalizePropTypes, + + ...windowDimensionsPropTypes, }; function TaskHeader(props) { const title = ReportUtils.getReportName(props.report); - const assigneeName = ReportUtils.getDisplayNameForParticipant(props.report.managerID); - const assigneeAvatar = UserUtils.getAvatar(lodashGet(props.personalDetails, [props.report.managerID, 'avatar']), props.report.managerID); - const isOpen = props.report.stateNum === CONST.REPORT.STATE_NUM.OPEN && props.report.statusNum === CONST.REPORT.STATUS.OPEN; - const isCompleted = props.report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum === CONST.REPORT.STATUS.APPROVED; + const isOpen = ReportUtils.isOpenTaskReport(props.report); + const isCompleted = ReportUtils.isCompletedTaskReport(props.report); + const isCanceled = ReportUtils.isCanceledTaskReport(props.report); useEffect(() => { - TaskUtils.setTaskReport(props.report); + Task.setTaskReport(props.report); }, [props.report]); return ( - {props.translate('common.to')} Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} disabled={!isOpen} accessibilityRole="button" - accessibilityLabel={props.translate('newTaskPage.assignee')} + accessibilityLabel={props.translate('task.assignee')} hoverDimmingValue={1} pressDimmingValue={0.2} > - - - {!_.isEmpty(props.report.managerID) && ( - <> - - - - {assigneeName} - - - - )} - - - {isCompleted ? ( - <> - {props.translate('task.completed')} - - - - - ) : ( -