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

Add Red Brick Road Offline Handling to Payments List #10333

Merged
merged 29 commits into from
Aug 15, 2022

Conversation

thienlnam
Copy link
Contributor

@thienlnam thienlnam commented Aug 9, 2022

Details

Fixed Issues

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

Tests

  1. Modify your Onyx data to include an error in the bank accounts
  2. First start by exposing Onyx to the window by adding window.Onyx = Onyx; to setup/index.js
  3. Then in the console, you should be able to do something like below with an existing bank account
    Onyx.merge('bankAccountList', {"827591": {pendingAction: 'delete', errors: {1: 'This is an error'}}})
  4. Verify that when you go to Settings, you see the error dot on the 'Payments' tab like below, and when you click on the payments tab you see the error
  5. Verify you can click on the x to remove the error
  • 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

Screen Shot 2022-08-09 at 6 05 53 PM

Screen Shot 2022-08-09 at 6 13 28 PM

Screen Shot 2022-08-09 at 6 47 05 PM

Mobile Web

Desktop

iOS

Android

@melvin-bot
Copy link

melvin-bot bot commented Aug 9, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

2 similar comments
@melvin-bot
Copy link

melvin-bot bot commented Aug 9, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

@melvin-bot
Copy link

melvin-bot bot commented Aug 9, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

@thienlnam thienlnam self-assigned this Aug 10, 2022
@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

1 similar comment
@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

@thienlnam thienlnam changed the title Add Pattern B Offline Handling to Payments List Add Red Brick Road Offline Handling to Payments List Aug 10, 2022
@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2022

npm has a package.json file and a package-lock.json file. It seems you updated one without the other, which is usually a sign of a mistake. If you are updating a package make sure that you update the version in package.json then run npm install

@thienlnam thienlnam marked this pull request as ready for review August 10, 2022 01:53
@thienlnam thienlnam requested a review from a team as a code owner August 10, 2022 01:53
@thienlnam thienlnam requested review from MariaHCD and iwiznia August 10, 2022 01:53
@melvin-bot melvin-bot bot requested review from aldo-expensify and removed request for a team August 10, 2022 01:53
@aldo-expensify
Copy link
Contributor

hmm whats with Melvin repeating this comment: #10333 (comment)

Copy link
Contributor

@aldo-expensify aldo-expensify left a comment

Choose a reason for hiding this comment

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

Looking good so far! the trick to insert the error in Onyx is very clever and made testing easier.. thanks!

I added the error as suggested and disabled the network. I think the item text should have been strikethrough, but it didn't work:

image

Maybe you need to do something like @iwiznia did here (add style prop to MenuItem in your case... but that may be a bit confusing since there are already other styles there 🤮 )

package-lock.json Outdated Show resolved Hide resolved
src/libs/actions/PaymentMethods.js Show resolved Hide resolved
src/pages/settings/Payments/PaymentMethodList.js Outdated Show resolved Hide resolved
@iwiznia
Copy link
Contributor

iwiznia commented Aug 10, 2022

hmm whats with Melvin repeating this comment: #10333 (comment)

Probably we are not checking if we already left the comment, but maybe we should not fix that, because Melvin commented 42 times, but the PR still contains changes in the lock, when it shouldn't 😄

src/libs/PaymentUtils.js Outdated Show resolved Hide resolved
src/libs/actions/PaymentMethods.js Outdated Show resolved Hide resolved
@@ -78,39 +87,6 @@ const defaultProps = {
...withCurrentUserPersonalDetailsDefaultProps,
};

const defaultMenuItems = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this moved?

Copy link
Contributor

Choose a reason for hiding this comment

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

The brickRoadIndicator: PaymentMethods.hasPaymentMethodError(props.bankAccountList, props.cardList) ? 'error' : null, needs access to something in props now

src/pages/settings/Payments/PaymentMethodList.js Outdated Show resolved Hide resolved
src/pages/settings/Payments/PaymentMethodList.js Outdated Show resolved Hide resolved
@iwiznia
Copy link
Contributor

iwiznia commented Aug 10, 2022

I think this is missing adding the dot to the avatar, no?

Copy link
Contributor

@aldo-expensify aldo-expensify left a comment

Choose a reason for hiding this comment

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

The X is not working for cards for me. I got the card id from the request:

image

Added the error like this:

Screen Shot 2022-08-12 at 6 14 04 PM

It looks a bit weird the card error twice. Clicking the X doesn't work:

Screen.Recording.2022-08-12.at.6.15.30.PM.mov

For banks, it works fine.

@thienlnam
Copy link
Contributor Author

thienlnam commented Aug 15, 2022

It looks a bit weird the card error twice. Clicking the X doesn't work:

This seems to be a bug from the cli tools utils where the card gets added to the bank list and the card list like Maria mentioned here #10333 (review)

I'll check it though and see if it is also happening to other cards

@aldo-expensify
Copy link
Contributor

It looks a bit weird the card error twice. Clicking the X doesn't work:

This seems to be a bug from the cli tools utils where the card gets added to the bank list and the card list like Maria mentioned here #10333 (review)

I'll check it though and see if it is also happening to other cards

Ahh, I see, I'll test it with a fresh account without adding stuff with clitools

@thienlnam
Copy link
Contributor Author

thienlnam commented Aug 15, 2022

Nevermind, found the issue - it was looking for cardID instead of fundID which is why it wouldn't delete

But I believe the bug where closing the error adds another error to the bank account of the same number is a bug from the cli tools

@aldo-expensify
Copy link
Contributor

You have some conflicts now, can you resolve before I do a final test 🙏

@thienlnam
Copy link
Contributor Author

Should be good now! @aldo-expensify

Copy link
Contributor

@aldo-expensify aldo-expensify left a comment

Choose a reason for hiding this comment

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

Seems to be working well, tested in web and Android (real device)

To have the errors in Android, I found it easier to send them from the Web API adding these lines

$bankAccountList = array_map(function (array $bankAccount) {
    return array_merge($bankAccount, ['pendingAction' => 'delete', 'errors' => ['1' => 'This is an error']]);
}, $bankAccountList);
$fundList = array_map(function (array $fund) {
    return array_merge($fund, ['pendingAction' => 'delete', 'errors' => ['1' => 'This is an error']]);
}, $fundList);

before construction $onyxData here: https://github.com/Expensify/Web-Expensify/blob/3b9e65f83ed4abe74e8a4bf36a84fe9cd3356f23/lib/BankAccountAPI.php#L962

@thienlnam
Copy link
Contributor Author

Going to self merge since I've addressed all reviewer comments and don't want to deal with any more merge conflicts - feel free to leave another review and I'll address in another PR

@eVoloshchak
Copy link
Contributor

👋
Leaving a note that this PR didn't optimistically filter out payment methods that were pending deletion, which caused #14262

@mananjadhav
Copy link
Collaborator

I am tagging this PR to highlight an issue fixed here. All conditions in ternary expressions or left-hand operands on conditional renders, should be boolean. This PR is one of the PRs that uses conditional render with string operands, hence I am tagging it here for the contributors to check.

We've also updated the item in the checklist with this PR to avoid this issues in the future.

@MariaHCD
Copy link
Contributor

MariaHCD commented May 4, 2023

Thanks, @mananjadhav. Could you point out the line(s) of code in this PR that used conditional render with string operands?

);
</View>
<View style={[styles.flexRow, styles.menuItemTextContainer, styles.pointerEventsNone]}>
{props.badgeText && <Badge text={props.badgeText} badgeStyles={[styles.alignSelfCenter, (props.brickRoadIndicator ? styles.mr2 : undefined)]} />}
Copy link
Collaborator

@mananjadhav mananjadhav May 4, 2023

Choose a reason for hiding this comment

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

@MariaHCD here is one example. But now when I searched with badgeText it looks like it existed before the PR too (sorry about that, had to link too many PRs here). I'll find the original PR and comment there too.

Copy link
Contributor

@MariaHCD MariaHCD May 4, 2023

Choose a reason for hiding this comment

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

All good, thanks for clarifying! It was mostly for my understanding :)

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.

6 participants