-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat: task view with offline with feedback #23705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
034680f
feat: task view with offline with feedback
allroundexperts 0965cb3
Merge branch 'main' into fix-23200
allroundexperts 9a88b34
feat: reset pending fields for failure data
allroundexperts 294a46c
feat: add pending fields wrapper
allroundexperts 7f84799
feat: add error state to tasks
allroundexperts 19077e1
feat: trigger re-render if errorFields are not equal
allroundexperts 31b79e6
feat: lint errors
allroundexperts 14198e8
feat: move the error dot above the horizontal line in task view
allroundexperts 0cdcff4
feat: resolve conflicts and comments
allroundexperts cdd9fba
feat: remove isAssignee function
allroundexperts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import React, {useEffect} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import PropTypes from 'prop-types'; | ||
| import lodashGet from 'lodash/get'; | ||
| import reportPropTypes from '../../pages/reportPropTypes'; | ||
| import withLocalize, {withLocalizePropTypes} from '../withLocalize'; | ||
| import withWindowDimensions from '../withWindowDimensions'; | ||
|
|
@@ -11,6 +12,7 @@ import ROUTES from '../../ROUTES'; | |
| import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; | ||
| import Hoverable from '../Hoverable'; | ||
| import MenuItem from '../MenuItem'; | ||
| import OfflineWithFeedback from '../OfflineWithFeedback'; | ||
| import styles from '../../styles/styles'; | ||
| import * as ReportUtils from '../../libs/ReportUtils'; | ||
| import * as OptionsListUtils from '../../libs/OptionsListUtils'; | ||
|
|
@@ -51,94 +53,104 @@ function TaskView(props) { | |
| const disableState = !canModifyTask || !isOpen; | ||
| return ( | ||
| <View> | ||
| <Hoverable> | ||
| {(hovered) => ( | ||
| <PressableWithSecondaryInteraction | ||
| onPress={Session.checkIfActionIsAllowed((e) => { | ||
| if (e && e.type === 'click') { | ||
| e.currentTarget.blur(); | ||
| } | ||
| <OfflineWithFeedback | ||
| shouldShowErrorMessages | ||
| errors={lodashGet(props, 'report.errorFields.editTask')} | ||
| onClose={() => Task.clearEditTaskErrors(props.report.reportID)} | ||
| errorRowStyles={styles.ph5} | ||
| > | ||
| <Hoverable> | ||
| {(hovered) => ( | ||
| <PressableWithSecondaryInteraction | ||
| onPress={Session.checkIfActionIsAllowed((e) => { | ||
| if (e && e.type === 'click') { | ||
| e.currentTarget.blur(); | ||
| } | ||
|
|
||
| Navigation.navigate(ROUTES.getTaskReportTitleRoute(props.report.reportID)); | ||
| })} | ||
| style={({pressed}) => [styles.ph5, styles.pv2, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed, false, disableState), true)]} | ||
| ref={props.forwardedRef} | ||
| disabled={disableState} | ||
| accessibilityLabel={taskTitle || props.translate('task.task')} | ||
| > | ||
| {({pressed}) => ( | ||
| <> | ||
| <Text style={styles.taskTitleDescription}>{props.translate('task.title')}</Text> | ||
| <View style={[styles.flexRow, styles.alignItemsTop, styles.flex1]}> | ||
| <Checkbox | ||
| onPress={() => (isCompleted ? Task.reopenTask(props.report.reportID, taskTitle) : Task.completeTask(props.report.reportID, taskTitle))} | ||
| isChecked={isCompleted} | ||
| style={styles.taskMenuItemCheckbox} | ||
| containerSize={24} | ||
| containerBorderRadius={8} | ||
| caretSize={16} | ||
| accessibilityLabel={taskTitle || props.translate('task.task')} | ||
| disabled={isCanceled || !canModifyTask} | ||
| /> | ||
| <View style={[styles.flexRow, styles.flex1]}> | ||
| <Text | ||
| numberOfLines={3} | ||
| style={styles.taskTitleMenuItem} | ||
| > | ||
| {taskTitle} | ||
| </Text> | ||
| </View> | ||
| {isOpen && ( | ||
| <View style={styles.taskRightIconContainer}> | ||
| <Icon | ||
| additionalStyles={[styles.alignItemsCenter]} | ||
| src={Expensicons.ArrowRight} | ||
| fill={StyleUtils.getIconFillColor(getButtonState(hovered, pressed, false, disableState))} | ||
| /> | ||
| Navigation.navigate(ROUTES.getTaskReportTitleRoute(props.report.reportID)); | ||
| })} | ||
| style={({pressed}) => [styles.ph5, styles.pv2, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed, false, disableState), true)]} | ||
| ref={props.forwardedRef} | ||
| disabled={disableState} | ||
| accessibilityLabel={taskTitle || props.translate('task.task')} | ||
| > | ||
| {({pressed}) => ( | ||
| <OfflineWithFeedback pendingAction={lodashGet(props, 'report.pendingFields.reportName')}> | ||
| <Text style={styles.taskTitleDescription}>{props.translate('task.title')}</Text> | ||
| <View style={[styles.flexRow, styles.alignItemsTop, styles.flex1]}> | ||
| <Checkbox | ||
| onPress={() => (isCompleted ? Task.reopenTask(props.report.reportID, taskTitle) : Task.completeTask(props.report.reportID, taskTitle))} | ||
| isChecked={isCompleted} | ||
| style={styles.taskMenuItemCheckbox} | ||
| containerSize={24} | ||
| containerBorderRadius={8} | ||
| caretSize={16} | ||
| accessibilityLabel={taskTitle || props.translate('task.task')} | ||
| disabled={isCanceled || !canModifyTask} | ||
| /> | ||
| <View style={[styles.flexRow, styles.flex1]}> | ||
| <Text | ||
| numberOfLines={3} | ||
| style={styles.taskTitleMenuItem} | ||
| > | ||
| {taskTitle} | ||
| </Text> | ||
| </View> | ||
| )} | ||
| </View> | ||
| </> | ||
| )} | ||
| </PressableWithSecondaryInteraction> | ||
| {isOpen && ( | ||
| <View style={styles.taskRightIconContainer}> | ||
| <Icon | ||
| additionalStyles={[styles.alignItemsCenter]} | ||
| src={Expensicons.ArrowRight} | ||
| fill={StyleUtils.getIconFillColor(getButtonState(hovered, pressed, false, disableState))} | ||
| /> | ||
| </View> | ||
| )} | ||
| </View> | ||
| </OfflineWithFeedback> | ||
| )} | ||
| </PressableWithSecondaryInteraction> | ||
| )} | ||
| </Hoverable> | ||
| <OfflineWithFeedback pendingAction={lodashGet(props, 'report.pendingFields.description')}> | ||
| <MenuItemWithTopDescription | ||
| description={props.translate('task.description')} | ||
| title={props.report.description || ''} | ||
| onPress={() => Navigation.navigate(ROUTES.getTaskReportDescriptionRoute(props.report.reportID))} | ||
| shouldShowRightIcon={isOpen} | ||
| disabled={disableState} | ||
| wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} | ||
| shouldGreyOutWhenDisabled={false} | ||
| numberOfLinesTitle={0} | ||
| /> | ||
| </OfflineWithFeedback> | ||
| {props.report.managerID ? ( | ||
| <OfflineWithFeedback pendingAction={lodashGet(props, 'report.pendingFields.managerID')}> | ||
| <MenuItem | ||
| label={props.translate('task.assignee')} | ||
| title={ReportUtils.getDisplayNameForParticipant(props.report.managerID)} | ||
| icon={OptionsListUtils.getAvatarsForAccountIDs([props.report.managerID], props.personalDetails)} | ||
| iconType={CONST.ICON_TYPE_AVATAR} | ||
| avatarSize={CONST.AVATAR_SIZE.SMALLER} | ||
| titleStyle={styles.assigneeTextStyle} | ||
| onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} | ||
| shouldShowRightIcon={isOpen} | ||
| disabled={disableState} | ||
| wrapperStyle={[styles.pv2]} | ||
| isSmallAvatarSubscriptMenu | ||
| shouldGreyOutWhenDisabled={false} | ||
| /> | ||
| </OfflineWithFeedback> | ||
| ) : ( | ||
| <MenuItemWithTopDescription | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coming from #35196, we should have wrapped |
||
| description={props.translate('task.assignee')} | ||
| onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} | ||
| shouldShowRightIcon={isOpen} | ||
| disabled={disableState} | ||
| wrapperStyle={[styles.pv2]} | ||
| shouldGreyOutWhenDisabled={false} | ||
| /> | ||
| )} | ||
| </Hoverable> | ||
| <MenuItemWithTopDescription | ||
| description={props.translate('task.description')} | ||
| title={props.report.description || ''} | ||
| onPress={() => Navigation.navigate(ROUTES.getTaskReportDescriptionRoute(props.report.reportID))} | ||
| shouldShowRightIcon={isOpen} | ||
| disabled={disableState} | ||
| wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} | ||
| shouldGreyOutWhenDisabled={false} | ||
| numberOfLinesTitle={0} | ||
| /> | ||
| {props.report.managerID ? ( | ||
| <MenuItem | ||
| label={props.translate('task.assignee')} | ||
| title={ReportUtils.getDisplayNameForParticipant(props.report.managerID)} | ||
| icon={OptionsListUtils.getAvatarsForAccountIDs([props.report.managerID], props.personalDetails)} | ||
| iconType={CONST.ICON_TYPE_AVATAR} | ||
| avatarSize={CONST.AVATAR_SIZE.SMALLER} | ||
| titleStyle={styles.assigneeTextStyle} | ||
| onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} | ||
| shouldShowRightIcon={isOpen} | ||
| disabled={disableState} | ||
| wrapperStyle={[styles.pv2]} | ||
| isSmallAvatarSubscriptMenu | ||
| shouldGreyOutWhenDisabled={false} | ||
| /> | ||
| ) : ( | ||
| <MenuItemWithTopDescription | ||
| description={props.translate('task.assignee')} | ||
| onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} | ||
| shouldShowRightIcon={isOpen} | ||
| disabled={disableState} | ||
| wrapperStyle={[styles.pv2]} | ||
| shouldGreyOutWhenDisabled={false} | ||
| /> | ||
| )} | ||
|
|
||
| </OfflineWithFeedback> | ||
| {props.shouldShowHorizontalRule && <View style={styles.reportHorizontalRule} />} | ||
| </View> | ||
| ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.