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

Conversation

cdanwards
Copy link
Contributor

@cdanwards cdanwards commented Apr 25, 2023

Details

This sets up the UI and the necessary actions in order to Create a Task.

Fixed Issues

$ #16855
PROPOSAL: GH_LINK_ISSUE(COMMENT)

Tests

NOTE: The CreateTask AuthCommand is not currently deployed, so the online flow will not work as expected. However, the offline flow should work.

Assignee and Share Destination are Different

  • Ensure that you have beta access to Tasks
  • Click the global create menu and select 'Assign Task'
  • Try to click Next before entering a title. An error should appear.
  • Enter a title and description and navigate to next page
  • Try to "Confirm Task" without entering a Share Destination. An error should appear that it is required.
  • Click on the "Assignee" and select and Assignee (It will navigate automatically)
  • Check that the "Share Destination" is updated to the same as the "Assignee" (This is automatic)
  • Click on the "Share Destination" and select a different destination.
  • Check that the Share Destination has updated on the Confirm Task Screen.
  • Click "Confirm Task"
  • Confirm the Title and Description are present
  • Navigate to the Share Destination Chat Report and check for a new comment
  • Navigate to the Assignee Chat Report and Check that a new comment has been created.
  • Verify that no errors appear in the JS console

Assignee and Share Destination are the Same

  • Ensure that you have beta access to Tasks
  • Click the global create menu and select 'Assign Task'
  • Try to click Next before entering a title. An error should appear.
  • Enter a title and description and navigate to next page
  • Try to "Confirm Task" without entering a Share Destination. An error should appear that it is required.
  • Click on the "Assignee" and select and Assignee (It will navigate automatically)
  • Check that the "Share Destination" is updated to the same as the "Assignee" (This is automatic)
  • Click "Confirm Task"
  • Confirm the Title and Description are present
  • Navigate to the Assignee Chat Report and Check that a new comment has been created.
  • Verify that no errors appear in the JS console

Offline tests

Same as Online Tests

QA Steps

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message: Slack Message
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Lower.Res.Web.Test.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
Low.Res.Desktop.Version.mov
iOS
Low.Res.IOS.Test.mov
Android
Low.Res.Android.Video.mov

@github-actions
Copy link
Contributor

github-actions bot commented Apr 25, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

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

It's really coming together 🎉

src/ROUTES.js Outdated Show resolved Hide resolved
title: 'Título',
description: 'Descripción',
shareIn: 'Compartir en',
pleaseEnterTaskName: 'Por favor introduce un título',
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.

src/libs/Permissions.js Outdated Show resolved Hide resolved
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/pages/tasks/AssigneeSelectorModal.js Outdated Show resolved Hide resolved
src/pages/tasks/NewTaskPage.js Outdated Show resolved Hide resolved
Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

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

Left this initial comment first, but taking a look at the onyx data next

src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
@thienlnam
Copy link
Contributor

Optimistically:
Create a new task report along with a CreatedReportAction on the task report
Add an AddCommentReportAction on the parent chat report
(If there is an assignee and not shared in the DM between them) Add an AddCommentReportAction on the assignee chat report
Success: None
Failure: Undo all the optimistic actions

@cdanwards
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@cdanwards cdanwards force-pushed the dan-createTaskFrontend branch 4 times, most recently from 3285c82 to f166357 Compare May 5, 2023 00:32
@thienlnam
Copy link
Contributor

Screenshot 2023-05-04 at 5 48 16 PM

If you select an assignee and the 'share somewhere' hasn't been set yet - it should automatically select the DM between them. So would look like this

image

@thienlnam
Copy link
Contributor

thienlnam commented May 5, 2023

Selecting a new assignee that you don't already have stored will crash the app

  1. Create a task
  2. Choose the email of a random assignee test123@gmail.com
  3. App crashes

Screenshot 2023-05-04 at 5 52 20 PM

Here are the console errors for that
Screenshot 2023-05-04 at 5 57 19 PM

src/languages/en.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Show resolved Hide resolved
src/libs/actions/Task.js Show resolved Hide resolved
src/pages/tasks/NewTaskPage.js Outdated Show resolved Hide resolved
src/pages/tasks/NewTaskPage.js Outdated Show resolved Hide resolved
@thienlnam
Copy link
Contributor

thienlnam commented May 5, 2023

We will need to truncate if it gets too long, or allow it to expand multiple lines. Most likely the second option?
Screenshot 2023-05-05 at 8 10 23 AM

EDIT: I see you actually just truncated it in the search, so we can keep the same pattern there
Screenshot 2023-05-05 at 8 16 45 AM

@thienlnam
Copy link
Contributor

Screenshot 2023-05-05 at 8 20 18 AM

Right now seems to be showing all of my contacts in recent, can we have it show segmented where it shows recents and then remaining contacts like in the new chat page?
These lists seem to be different
Screenshot 2023-05-05 at 8 21 12 AM

src/languages/en.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
@thienlnam
Copy link
Contributor

Screenshot 2023-05-05 at 8 46 00 AM
I still am getting an error with assigning someone new not in contacts - I can help you investigate this later

Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

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

Couple parameters to update to match with backend

src/libs/ReportUtils.js Outdated Show resolved Hide resolved

// Grab the assigneeChatReportID if there is an assignee and if it's not the same as the parentReportID
// then we create an optimistic add comment report action on the assignee's chat to notify them of the task
const assigneeChatReportID = ReportUtils.getChatByParticipants([assignee]).reportID;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an error in this line when assignee is not selected , this is come from assignee isn’t marked as required in the newTaskPage

Screenshot 2023-05-05 at 8 30 06 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! We want to leave the option for a task to be created without an assignee, only title and share destination are required. I've changed to logic to check to make sure there is an assignee before fetching the DM chat report with that assignee.

src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

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

CreateTask command is still failing, there is some missing parameters

src/libs/actions/Task.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
if (option.alternateText) {
// Clear out the state value, set the assignee and navigate back to the NewTaskPage
setSearchValue('');
TaskUtils.setAssigneeValue(option.alternateText, props.task.shareDestination);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #18649:
We should have used option.login instead of option.alternateText for phone number accounts.
Here's the root cause: #18649 (comment)

@sobitneupane
Copy link
Contributor

This issue was not addressed in this PR. We accepted white spaces as task description.

@sobitneupane
Copy link
Contributor

This issue was not address in this PR.

Issue: Error appears for a second when user select new member as Assignee

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

{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticTaskReport.reportID}`,
value: optimisticTaskReport,
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #19134:
This should always be added in optimisticData when build new report, so that they show with opacity when created offline.

                pendingFields: {
                    createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
                },

// the response
function onSubmit() {
if (!props.task.title || !props.task.shareDestination) {
setSubmitError(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from Assign Task - An incorrect error message is displayed when clicking confirm task:
This was overlooked. As confirmError error is set as initial state value, Please enter a title and select a share destination message is always displayed even though title is already filled.

}

// Create the CreatedReportAction on the task
const optimisticTaskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(optimisticTaskReport.reportID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Fyi looks like we probably meant to pass ownerEmail in the param, not reportID :D

@thesahindia
Copy link
Member

Coming from #21361. We were getting error after adding the title and moving to the next step. Info: #21361 (comment)

<Form
formID={ONYXKEYS.FORMS.NEW_TASK_FORM}
submitButtonText={props.translate('common.next')}
style={[styles.mh5, styles.mt5, styles.flexGrow1]}
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #21754, We have extra padding (styles.mt5) in all create task forms.

@abdulrahuman5196
Copy link
Contributor

Coming from here #22060. We missed to clear the pending action onyx state after API success #22060 (comment)

onBackButtonPress={() => Navigation.goBack()}
/>
<View style={[styles.flex1, styles.w100, styles.pRelative]}>
<OptionsSelector
Copy link
Member

Choose a reason for hiding this comment

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

Hi all, this PR caused issue #20075

The asignee selection list can take a long time to filter. So we should have debounced search when implementing OptionsSelector (like done in this PR)

@sobitneupane
Copy link
Contributor

This case was missed while implementing New Task Page.

Issue: Web - UserB can still create a task in room chat when UserA changes post permission to "Admins only"

});
}

const successData = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

This caused a regression. The successData array is empty but we should be clearing the pendingActions. (Coming from #22907)

@sobitneupane
Copy link
Contributor

sobitneupane commented Oct 9, 2023

This issue was not handled in this PR. policyID was not added while creating optimistic task report.

Issue: Assign Task - Workspace avatar shows 'U'

}

// Create the CreatedReportAction on the task
const optimisticTaskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(optimisticTaskReport.reportID);
Copy link
Member

Choose a reason for hiding this comment

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

Coming from No activity yet appears in task item of search RHN.

We should have updated getLastMessageTextForReport() to show the task details in LHN description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.