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

Show comment API errors with OfflineWithFeedback #10317

Merged
merged 9 commits into from
Aug 10, 2022

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Aug 9, 2022

Details

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/218572

Tests

  1. Test together with https://github.com/Expensify/Web-Expensify/pull/34538
  2. Trigger an error by throwing an ExpError somewhere in the try/catch here
  3. Verify that the error message appears below the chat message
  4. Verify that the sidebar has a red dot (red brick road indicator)
  5. Dismiss the error
  6. Verify the red brick road indicator is removed.
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (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 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 included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team 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
  • 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 */
    • Any functional components have the displayName property
    • 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 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 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 verified proper code patterns were followed (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 was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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
  • 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 */
    • Any functional components have the displayName property
    • 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 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

QA Steps

  • Verify that no errors appear in the JS console

Screenshots

Web

Mobile Web

Desktop

iOS

Android

@marcaaron marcaaron self-assigned this Aug 9, 2022
@marcaaron
Copy link
Contributor Author

Style on this is looking a bit rough but the opacity and errors are showing up...

Screen Shot 2022-08-08 at 3 52 45 PM

To Do:

  • Fix the styles
  • Work on getting the red brick road indicators to show up in the sidebar

@marcaaron marcaaron changed the title [WIP] Add initial code to render comment errors with OfflineWithFeedback Add initial code to render comment errors with OfflineWithFeedback Aug 9, 2022
@marcaaron marcaaron changed the title Add initial code to render comment errors with OfflineWithFeedback [HOLD Web-Expensify 34538] Add initial code to render comment errors with OfflineWithFeedback Aug 9, 2022
@marcaaron marcaaron changed the title [HOLD Web-Expensify 34538] Add initial code to render comment errors with OfflineWithFeedback [HOLD Web-Expensify 34538] Render comment errors with OfflineWithFeedback Aug 9, 2022
@marcaaron marcaaron changed the title [HOLD Web-Expensify 34538] Render comment errors with OfflineWithFeedback [HOLD Web-Expensify 34538] Show comment API errors with OfflineWithFeedback Aug 9, 2022
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {
optimisticReportActionIDs: [],
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is kind of an MVP solution that I'm removing now. If we leave it in each time the report actions are fetched we will remove any "optimistic actions". That includes any pending actions with errors which breaks the new design. It was always the plan to remove this code so if we end up with a problem related to "stuck actions" then we'll just need to approach it another way. Though, I'm not sure if "stuck comments" are really a thing anymore.

@marcaaron
Copy link
Contributor Author

I think this is almost ready. This is what the errors look like atm:

Screen Shot 2022-08-09 at 11 13 44 AM
Screen Shot 2022-08-09 at 11 13 37 AM
Screen Shot 2022-08-09 at 11 12 40 AM

cc @shawnborton to see if there are any notes!

@marcaaron marcaaron marked this pull request as ready for review August 9, 2022 21:15
@marcaaron marcaaron requested a review from a team as a code owner August 9, 2022 21:15
@melvin-bot melvin-bot bot requested review from youssef-lr and removed request for a team August 9, 2022 21:15
@shawnborton
Copy link
Contributor

Looks pretty good! Make sure the right side of the error block also has 20px padding, so that the right icon aligns well with the content above and below it. Also, is this nested within the message above it? As in, if you hover over the message row with the error, does the row highlight color show behind the error as well?

@shawnborton shawnborton self-requested a review August 9, 2022 21:31
@PauloGasparSv PauloGasparSv self-requested a review August 9, 2022 21:52
Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

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

Looks good overall and it works well. I have some questions and a couple things that I think should be changed. As Shawn said the error needs some right margin.

The error row is separate from the comment when highlighted. Personally I think it looks fine.
image

Also, the tooltip doesn't look quite right
image


/** Additional style object for the error row */
// eslint-disable-next-line react/forbid-prop-types
errorStyle: PropTypes.object,
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: How about errorRowStyle?

src/libs/OptionsListUtils.js Show resolved Hide resolved
src/libs/OptionsListUtils.js Show resolved Hide resolved
@@ -581,7 +600,7 @@ function getOptions(reports, personalDetails, activeReportID, {
const login = (Str.isValidPhone(searchValue) && !searchValue.includes('+'))
? `+${countryCodeByIP}${searchValue}`
: searchValue;
userToInvite = createOption([login], personalDetails, null, reportsWithDraft, {
userToInvite = createOption([login], personalDetails, null, reportsWithDraft, reportActions, {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like the case for creating an option when searching for a user to chat with. Are we planning to add a brickRoadIndicator here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but I don't have any specific concerns with passing the reportActions here. We could create a more specific createReportOption() alternatively, but unsure whether it's necessary.

@@ -59,10 +59,6 @@ const allReports = {};
let conciergeChatReportID;
const typingWatchTimers = {};

// Map of optimistic report action IDs. These should be cleared when replaced by a recent fetch of report history
// since we will then be up to date and any optimistic actions that are still waiting to be replaced can be removed.
const optimisticReportActionIDs = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: It looks like we weren't really using optimisticReportActionIDs so removing this is fine. How were we using these before?

Copy link
Contributor Author

@marcaaron marcaaron Aug 9, 2022

Choose a reason for hiding this comment

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

We were:

  • adding all optimistic actions clientID to an array on each report object
  • removing them later when one of these things happens (whichever one happens first):
    • The real action created in the server shows up in Pusher
    • The latest actions for the report are fetched

Clearing out the actions was done to take care of an edge case where:

  • A report comment would fail to be created in the server
  • No error message would be displayed and there would be no way to dismiss the message
  • These comments would get "stuck" in a kind of limbo of never being created and unable to be removed
  • So to counteract that we would clear these out when fetching new actions

Ultimately, I think this is not as much of a problem any more since we are handling the failure cases and giving the user a way to dismiss a message that could not be created for some reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Thanks for the explanation.

src/pages/home/report/ReportActionsList.js Outdated Show resolved Hide resolved
@marcaaron
Copy link
Contributor Author

Yeah so I'm not too sure what exactly is happening with the tooltip tbh. Tried switching from margin to padding to see if that helped.

Here's what this looks like with improved spacing on the right side and everything under the "hover"

Screen Shot 2022-08-09 at 1 57 10 PM
Screen Shot 2022-08-09 at 1 56 53 PM
Screen Shot 2022-08-09 at 1 57 20 PM

Unsure if this is a blocker or something we might improve later, but here's some feedback...

  1. It's not entirely clear that the "Close" button will remove the message. Should it say something like "Delete Comment" instead? Do we care?

  2. The x feels a bit far from the error message on desktop and having an x in the bottom right corner sort of betrays my expectations (x usually in the top right or left to close or dismiss something).

@marcaaron
Copy link
Contributor Author

This effect is not as noticeable on mobile sizes ->

Screen Shot 2022-08-09 at 2 04 59 PM

Copy link
Contributor

@neil-marcellini neil-marcellini 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 not entirely clear that the "Close" button will remove the message. Should it say something like "Delete Comment" instead? Do we care?

I think it's fine. If this command fails I suspect the error message will give some context that will make it clear that the message was not sent / saved.

The x feels a bit far from the error message on desktop and having an x in the bottom right corner sort of betrays my expectations (x usually in the top right or left to close or dismiss something).

Yeah, it doesn't look super great, but that's only the case for very large screen sizes. I think it looks pretty good on a laptop sized screen or smaller. The hover actions like "copy to clipboard" are also pushed to the far right side and we seem to be okay with that.

Also, the tooltip looks different now and I think it's satisfactory at this point. We can always make small tweaks in the future.
image

I'll approve but I'm curious to hear what @shawnborton thinks before we merge.

PauloGasparSv
PauloGasparSv previously approved these changes Aug 10, 2022
@shawnborton
Copy link
Contributor

Both the tooltip and the "x" being far off to the right are totally cool with me, so I'm good with merging this.

shawnborton
shawnborton previously approved these changes Aug 10, 2022
@marcaaron marcaaron changed the title [HOLD Web-Expensify 34538] Show comment API errors with OfflineWithFeedback Show comment API errors with OfflineWithFeedback Aug 10, 2022
@marcaaron
Copy link
Contributor Author

I'm gonna merge this one to unblock @neil-marcellini and @PauloGasparSv. I tested against the staging Web-Expensify and don't think this needs to be on HOLD.

@marcaaron marcaaron merged commit e57e113 into main Aug 10, 2022
@marcaaron marcaaron deleted the marcaaron-addCommentPatternB branch August 10, 2022 18:41
@melvin-bot melvin-bot bot added the Emergency label Aug 10, 2022
@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2022

@marcaaron looks like this was merged without passing tests. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@marcaaron
Copy link
Contributor Author

Tests passed

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.

5 participants