Skip to content
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

Create Task FrontEnd Changes #17992

Merged
merged 87 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
053231c
updated beta flag
cdanwards Apr 17, 2023
db1e986
Added optimistic Task and creating assign Task
cdanwards Apr 18, 2023
cff5490
created assignTask
cdanwards Apr 20, 2023
ba8a856
Updated the optimistic data
cdanwards Apr 20, 2023
6947298
converted necessary props for selector to hooks
cdanwards Apr 21, 2023
8d49bf9
Moved selector to its own page for assignee
cdanwards Apr 25, 2023
409a593
Added routes and wired up Assignee screen
cdanwards Apr 25, 2023
dae9bb9
Got the selector to return options
cdanwards Apr 25, 2023
80c39e8
Renamed selector pages to modals
cdanwards Apr 25, 2023
d39115c
Some clean up and added todos for the selector modals
cdanwards Apr 25, 2023
f211c02
reset the es js file
cdanwards Apr 25, 2023
e660cad
reset the en js file
cdanwards Apr 25, 2023
e83984a
Fixed indentation on modalStackNavigators
cdanwards Apr 25, 2023
f494977
fixed up logic for action from review comments
cdanwards Apr 27, 2023
5d1934d
Added Task onyx key and passing assignee back to newtaskPage
cdanwards Apr 27, 2023
0da82cc
updated optionslistutils with new util to get all rooms and group chats
cdanwards Apr 27, 2023
17faa1e
Added SelectorLink and updating the Modals and NewtaskPage
cdanwards Apr 28, 2023
91f16d2
Added New Task Details page and routes
cdanwards May 1, 2023
a303279
created new task title and description routes and modals
cdanwards May 2, 2023
53f3fd3
Wired up navigation between screens
cdanwards May 2, 2023
9b5397e
updated the state functions and got the correct shape for links
cdanwards May 2, 2023
42be3fd
Updated labels
cdanwards May 2, 2023
7fe9d82
validation and link disabled logic fixed
cdanwards May 3, 2023
00e7dac
Added Tests
cdanwards May 3, 2023
9937807
Updated CreateTask command
cdanwards May 3, 2023
387d8eb
Updated to correct list for shareDestinationModal
cdanwards May 3, 2023
eb5f0bc
Renamed Selector Modals for clarity
cdanwards May 3, 2023
00b7965
Updated the createTask call
cdanwards May 3, 2023
29ca351
Fixed AddCommentReportAction
cdanwards May 3, 2023
4a90b90
refreshed changes to ReportUtils
cdanwards May 3, 2023
71981fa
More rebase cleanup
cdanwards May 3, 2023
17eec06
Fixed mobile display issue, renamed the prop name to title and begun …
cdanwards May 4, 2023
aa1aa3f
Updated some of the Taskjs logic
cdanwards May 4, 2023
ca73466
fixed esjs word
cdanwards May 4, 2023
4561089
Fixed linkingconfig lint
cdanwards May 4, 2023
cf51fbc
fixed linting on modalstack
cdanwards May 4, 2023
455081a
fix linting in reportutils
cdanwards May 4, 2023
8767bef
fixed up some logic
cdanwards May 4, 2023
ddfb87a
removed unneeded field from call
cdanwards May 5, 2023
b05c1fb
changed how we got the current user email
cdanwards May 5, 2023
5f201ea
updated to new onyx merge standard
cdanwards May 5, 2023
df2f420
Some updates from review
cdanwards May 5, 2023
5f87adf
Fixed error when selecting assignee without details
cdanwards May 5, 2023
ea3f61d
updated task title header
cdanwards May 5, 2023
b86e845
removed import
cdanwards May 5, 2023
2765122
fixed issue where contacts weren't showing
cdanwards May 5, 2023
6bcee36
Updated headers for selectors and now filtering out expensify bot emails
cdanwards May 5, 2023
6686ff8
Updated a few things
cdanwards May 5, 2023
d11f4e4
Commented out where text was being replaced
cdanwards May 5, 2023
970f786
updated with latest, also added some more JSdoc
cdanwards May 5, 2023
ebfbe39
updated ids
cdanwards May 5, 2023
856971f
removed issue where parentReportID was being provided
cdanwards May 5, 2023
956719c
fixed some bugs
cdanwards May 5, 2023
8e28148
fixed issue on assignee selector and fixed route navigation
cdanwards May 5, 2023
ef30195
Updated ids and locations
cdanwards May 6, 2023
4fe2f97
updated report Id to ID
cdanwards May 6, 2023
df59854
one last id update
cdanwards May 6, 2023
7da7834
Update src/components/TaskSelectorLink.js
cdanwards May 7, 2023
5f18bb7
Update src/components/TaskSelectorLink.js
cdanwards May 7, 2023
def7008
Update src/components/TaskSelectorLink.js
cdanwards May 7, 2023
5c4f7b0
Update src/components/TaskSelectorLink.js
cdanwards May 7, 2023
f797baf
Update src/components/TaskSelectorLink.js
cdanwards May 7, 2023
74f406e
Update src/components/TaskSelectorLink.js
cdanwards May 7, 2023
a750451
Update src/libs/ReportUtils.js
cdanwards May 7, 2023
becece5
Update src/libs/actions/Task.js
cdanwards May 7, 2023
7577d67
Update src/libs/actions/Task.js
cdanwards May 7, 2023
24af85f
Update src/libs/actions/Task.js
cdanwards May 7, 2023
1e857ea
Update src/libs/actions/Task.js
cdanwards May 7, 2023
832b36c
Update src/libs/actions/Task.js
cdanwards May 7, 2023
47265f0
Update src/libs/actions/Task.js
cdanwards May 7, 2023
a35340c
Update src/pages/tasks/NewTaskDescriptionPage.js
cdanwards May 7, 2023
3ca5b24
Update src/pages/tasks/NewTaskDescriptionPage.js
cdanwards May 7, 2023
64ae0a7
Update src/pages/tasks/NewTaskDescriptionPage.js
cdanwards May 7, 2023
4b9311e
Update src/pages/tasks/NewTaskDescriptionPage.js
cdanwards May 7, 2023
0058927
Update src/pages/tasks/NewTaskDescriptionPage.js
cdanwards May 7, 2023
c4a097d
Apply suggestions from code review
cdanwards May 7, 2023
e6adb1a
Update src/libs/OptionsListUtils.js
cdanwards May 7, 2023
b0a605a
Added import and removed comment
cdanwards May 7, 2023
8649070
Apply suggestions from code review
cdanwards May 7, 2023
7f5eb36
Updated canUseTasks
cdanwards May 7, 2023
ee1dd40
Update src/libs/actions/Task.js
cdanwards May 7, 2023
4d30cc2
removed redundant import
cdanwards May 7, 2023
b00b75c
Removed Debounch functions and added enabledWhenOfflien for form
cdanwards May 7, 2023
559e576
updated some UX bugs
cdanwards May 7, 2023
8c98b5e
Apply suggestions from code review
cdanwards May 8, 2023
02be699
Added ref to input on TaskDetails screen
cdanwards May 8, 2023
8f9abca
fixed linter issues
cdanwards May 8, 2023
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
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export default {
// Contains all the private personal details of the user
PRIVATE_PERSONAL_DETAILS: 'private_personalDetails',

// Contains all the info for Tasks
TASK: 'task',

// Contains a list of all currencies available to the user - user can
// select a currency based on the list
CURRENCY_LIST: 'currencyList',
Expand Down
10 changes: 6 additions & 4 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ export default {
TASK_DESCRIPTION: 'r/:reportID/description',
getTaskReportTitleRoute: reportID => `r/${reportID}/title`,
getTaskReportDescriptionRoute: reportID => `r/${reportID}/description`,
NEW_TASK_ASSIGNEE: `${NEW_TASK}/assignee`,
NEW_TASK_SHARE_DESTINATION: `${NEW_TASK}/share-destination`,
NEW_TASK_DETAILS: `${NEW_TASK}/details`,
NEW_TASK_TITLE: `${NEW_TASK}/title`,
NEW_TASK_DESCRIPTION: `${NEW_TASK}/description`,
getTaskDetailsRoute: taskID => `task/details/${taskID}`,
SEARCH: 'search',
SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:accountID/:validateCode',
Expand All @@ -105,10 +110,7 @@ export default {
REPORT_PARTICIPANTS: 'r/:reportID/participants',
getReportParticipantsRoute: reportID => `r/${reportID}/participants`,
REPORT_PARTICIPANT: 'r/:reportID/participants/details',
getReportParticipantRoute: (
reportID,
login,
) => `r/${reportID}/participants/details?login=${encodeURIComponent(login)}`,
getReportParticipantRoute: (reportID, login) => `r/${reportID}/participants/details?login=${encodeURIComponent(login)}`,
REPORT_WITH_ID_DETAILS: 'r/:reportID/details',
getReportDetailsRoute: reportID => `r/${reportID}/details`,
REPORT_SETTINGS: 'r/:reportID/settings',
Expand Down
120 changes: 120 additions & 0 deletions src/components/TaskSelectorLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React from 'react';
import {View, TouchableOpacity} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import themeColors from '../styles/themes/default';
import variables from '../styles/variables';
import Text from './Text';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import * as StyleUtils from '../styles/StyleUtils';
import DisplayNames from './DisplayNames';
import MultipleAvatars from './MultipleAvatars';
import CONST from '../CONST';
import avatarPropTypes from './avatarPropTypes';

const propTypes = {
/** Array of avatar URLs or icons */
icons: PropTypes.arrayOf(avatarPropTypes),

/** The title to display */
text: PropTypes.string,

/** The description to display */
alternateText: PropTypes.string,

/** The function to call when the link is pressed */
onPress: PropTypes.func.isRequired,

/** Label for the Link */
label: PropTypes.string.isRequired,

/** Whether it is a share location */
isShareDestination: PropTypes.bool,

/** Whether the Touchable should be disabled */
disabled: PropTypes.bool,

...withLocalizePropTypes,
};

const defaultProps = {
icons: [],
text: '',
alternateText: '',
isShareDestination: false,
disabled: false,
};

const TaskSelectorLink = (props) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component was not clipping text appropriately for longer text which caused #18659

const shortenedText = props.text.length > 35 ? `${props.text.substring(0, 35)}...` : props.text;
const displayNameStyle = StyleUtils.combineStyles(styles.optionDisplayName, styles.pre);
const alternateTextStyle = StyleUtils.combineStyles(
styles.sidebarLinkText,
styles.optionAlternateText,
styles.textLabelSupporting,
styles.pre,
);
const linkBottomMargin = props.icons.length !== 0 ? styles.mb6 : styles.mb2;
return (
<TouchableOpacity
style={[styles.flexRow, styles.taskSelectorLink, linkBottomMargin]}
onPress={props.onPress}
disabled={props.disabled}
>
<View style={[styles.flexRow, styles.containerWithSpaceBetween, styles.alignItemsCenter]}>
{props.icons.length !== 0 || props.text !== '' ? (
<View style={[styles.flexColumn, styles.justify, styles.alignItemsStart]}>
<Text style={[styles.label, styles.textWhite, styles.mb2]}>
{props.translate(props.label)}
</Text>
<View style={[styles.flexRow, styles.justifyContentCenter]}>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<MultipleAvatars
icons={props.icons}
size={CONST.AVATAR_SIZE.DEFAULT}
secondAvatarStyle={[StyleUtils.getBackgroundAndBorderStyle(themeColors.appBG)]}
/>
<View style={[styles.flexColumn]}>
<DisplayNames
accessibilityLabel={props.translate('accessibilityHints.chatUserDisplayNames')}
fullTitle={shortenedText}
tooltipEnabled={false}
numberOfLines={1}
textStyles={displayNameStyle}
shouldUseFullTitle={props.isShareDestination}
/>
{props.alternateText ? (
<Text style={alternateTextStyle} numberOfLines={1}>
{props.alternateText}
</Text>
) : null}
</View>
</View>
</View>
</View>
) : (
<Text style={[styles.textWhite, styles.textNormal]}>
{props.translate(props.label)}
</Text>
)}
{props.disabled ? null : (
<Icon
src={Expensicons.ArrowRight}
fill={themeColors.textLight}
width={variables.iconSizeSmall}
height={variables.iconSizeSmall}
inline
/>
)}
</View>
</TouchableOpacity>
);
};

TaskSelectorLink.defaultProps = defaultProps;
TaskSelectorLink.propTypes = propTypes;
TaskSelectorLink.displayName = 'TaskSelectorLink';

export default withLocalize(TaskSelectorLink);
9 changes: 8 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,12 +1153,19 @@ export default {
newTaskPage: {
task: 'Task',
assignTask: 'Assign task',
assignee: 'Assignee',
assigneeError: 'There was an error assigning this task, please try another assignee',
confirmTask: 'Confirm task',
confirmError: 'Please enter a title and select a share destination',
title: 'Title',
description: 'Description',
shareIn: 'Share in',
descriptionOptional: 'Description (optional)',
shareSomewhere: 'Share somewhere',
pleaseEnterTaskName: 'Please enter a title',
markAsComplete: 'Mark as complete',
markAsIncomplete: 'Mark as incomplete',
pleaseEnterTaskAssignee: 'Please select an assignee',
pleaseEnterTaskDestination: 'Please select a share destination',
},
statementPage: {
generatingPDF: 'We\'re generating your PDF right now. Please come back later!',
Expand Down
9 changes: 8 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -1154,12 +1154,19 @@ export default {
newTaskPage: {
task: 'Tarea',
assignTask: 'Asignar tarea',
assignee: 'Cesionario',
assigneeError: 'Hubo un error al asignar esta tarea, intente con otro cesionario',
confirmTask: 'Confirmar tarea',
confirmError: 'Por favor introduce un título y selecciona un destino de tarea',
title: 'Título',
description: 'Descripción',
shareIn: 'Compartir en',
descriptionOptional: 'Descripción (opcional)',
shareSomewhere: 'Compartir en algún lugar',
pleaseEnterTaskName: 'Por favor introduce un título',
markAsComplete: 'Marcar como completa',
markAsIncomplete: 'Marcar como incompleta',
pleaseEnterTaskAssignee: 'Por favor, asigna una persona a esta tarea',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder for me to get translations for this, we have some certain terminology we are trying to keep consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thienlnam I posted in open-source to get someone to check translations. Someone asked for the En/Es versions and I provided them but I haven't heard anything else about it.

pleaseEnterTaskDestination: 'Por favor, selecciona un destino de tarea',
},
statementPage: {
generatingPDF: 'Estamos generando tu PDF ahora mismo. ¡Por favor, vuelve más tarde!',
Expand Down
49 changes: 43 additions & 6 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,50 @@ const NewChatModalStackNavigator = createModalStackNavigator([{
name: 'NewChat_Root',
}]);

const NewTaskModalStackNavigator = createModalStackNavigator([{
getComponent: () => {
const NewTaskPage = require('../../../pages/NewTaskPage').default;
return NewTaskPage;
const NewTaskModalStackNavigator = createModalStackNavigator([
{
getComponent: () => {
const NewTaskPage = require('../../../pages/tasks/NewTaskPage').default;
return NewTaskPage;
},
name: 'NewTask_Root',
},
name: 'NewTask_Root',
}]);
{
getComponent: () => {
const NewTaskAssigneeSelectorPage = require('../../../pages/tasks/TaskAssigneeSelectorModal').default;
return NewTaskAssigneeSelectorPage;
},
name: 'NewTask_TaskAssigneeSelector',
},
{
getComponent: () => {
const NewTaskTaskShareDestinationPage = require('../../../pages/tasks/TaskShareDestinationSelectorModal').default;
return NewTaskTaskShareDestinationPage;
},
name: 'NewTask_TaskShareDestinationSelector',
},
{
getComponent: () => {
const NewTaskDetailsPage = require('../../../pages/tasks/NewTaskDetailsPage').default;
return NewTaskDetailsPage;
},
name: 'NewTask_Details',
},
{
getComponent: () => {
const NewTaskTitlePage = require('../../../pages/tasks/NewTaskTitlePage').default;
return NewTaskTitlePage;
},
name: 'NewTask_Title',
},
{
getComponent: () => {
const NewTaskDescriptionPage = require('../../../pages/tasks/NewTaskDescriptionPage').default;
return NewTaskDescriptionPage;
},
name: 'NewTask_Description',
},
]);

const SettingsModalStackNavigator = createModalStackNavigator([
{
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ export default {
NewTask: {
screens: {
NewTask_Root: ROUTES.NEW_TASK_WITH_REPORT_ID,
NewTask_TaskAssigneeSelector: ROUTES.NEW_TASK_ASSIGNEE,
NewTask_TaskShareDestinationSelector: ROUTES.NEW_TASK_SHARE_DESTINATION,
NewTask_Details: ROUTES.NEW_TASK_DETAILS,
NewTask_Title: ROUTES.NEW_TASK_TITLE,
NewTask_Description: ROUTES.NEW_TASK_DESCRIPTION,
},
},
Search: {
Expand Down
29 changes: 29 additions & 0 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,34 @@ function getNewChatOptions(
});
}

/**
* Build the options for the Share Destination for a Task
* *
* @param {Object} reports
* @param {Object} personalDetails
* @param {Array<String>} [betas]
* @param {String} [searchValue]
* @param {Array} [selectedOptions]
* @param {Array} [excludeLogins]
* @param {Boolean} [includeOwnedWorkspaceChats]
* @returns {Object}
*
*/

function getShareDestinationOptions(reports, personalDetails, betas = [], searchValue = '', selectedOptions = [], excludeLogins = [], includeOwnedWorkspaceChats = true) {
return getOptions(reports, personalDetails, {
betas,
searchInputValue: searchValue.trim(),
selectedOptions,
cdanwards marked this conversation as resolved.
Show resolved Hide resolved
maxRecentReportsToShow: 5,
includeRecentReports: true,
includeMultipleParticipantReports: true,
includePersonalDetails: true,
excludeLogins,
includeOwnedWorkspaceChats,
});
}

/**
* Build the options for the Workspace Member Invite view
*
Expand Down Expand Up @@ -900,6 +928,7 @@ export {
isCurrentUser,
getSearchOptions,
getNewChatOptions,
getShareDestinationOptions,
getMemberInviteOptions,
getHeaderMessage,
getPersonalDetailsForLogins,
Expand Down
35 changes: 32 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,12 +730,14 @@ function getIcons(report, personalDetails, defaultIcon = null) {
result.source = Expensicons.ActiveRoomAvatar;
return [result];
}
if (isPolicyExpenseChat(report) || isExpenseReport(report)) {
if (isPolicyExpenseChat(report)) {
const workspaceName = lodashGet(allPolicies, [
`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'name',
]);

const policyExpenseChatAvatarSource = getWorkspaceAvatar(report);
const policyExpenseChatAvatarSource = lodashGet(allPolicies, [
`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'avatar',
]) || getDefaultWorkspaceAvatar(workspaceName);

// Return the workspace avatar if the user is the owner of the policy expense chat
if (report.isOwnPolicyExpenseChat && !isExpenseReport(report)) {
Expand Down Expand Up @@ -1382,6 +1384,32 @@ function buildOptimisticWorkspaceChats(policyID, policyName) {
};
}

/**
* Builds an optimistic Task Report with a randomly generated reportID
*
* @param {String} ownerEmail - Email of the person generating the Task.
* @param {String} assignee - Email of the other person participating in the Task.
* @param {String} parentReportID - Report ID of the chat where the Task is.
* @param {String} title - Task title.
* @param {String} description - Task description.
*
* @returns {Object}
*/

function buildOptimisticTaskReport(ownerEmail, assignee = null, parentReportID, title, description) {
return {
reportID: generateReportID(),
cdanwards marked this conversation as resolved.
Show resolved Hide resolved
reportName: title,
description,
ownerEmail,
assignee,
type: CONST.REPORT.TYPE.TASK,
parentReportID,
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS.OPEN,
};
}

/**
* @param {Object} report
* @returns {Boolean}
Expand Down Expand Up @@ -1599,7 +1627,7 @@ function getChatByParticipants(newParticipantList) {
}

/**
* Attempts to find a report in onyx with the provided list of participants in given policy
* Attempts to find a report in onyx with the provided list of participants in given policy
* @param {Array} newParticipantList
* @param {String} policyID
* @returns {object|undefined}
Expand Down Expand Up @@ -1856,6 +1884,7 @@ export {
isUnread,
isUnreadWithMention,
buildOptimisticWorkspaceChats,
buildOptimisticTaskReport,
buildOptimisticChatReport,
buildOptimisticClosedReportAction,
buildOptimisticCreatedReportAction,
Expand Down
Loading