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

[Search v1] Add handling of actions and improve Search list items #41725

Conversation

Kicu
Copy link
Contributor

@Kicu Kicu commented May 7, 2024

Details

  • Adds different action buttons and badges to both Transaction and Report list items in Search
  • Not all possible searches are yet supported, this PR makes it look good for these actions:
    • view + review (I assumed review does the exact same thing as view)
    • hold
    • unhold

Fixed Issues

$ #39890
PROPOSAL:

Tests

  • go to Search and verify that every item has correctly looking button
  • for hold and unhold verify that when clicked a correct request to backend is made
  • unfortunately for now backend returns only View action, until more actions are supported this can't be manually checked;
    For testing different badges I suggest either editing ActionCell component to hardcode action or go to SearchUtils.getTransactionsSections and add hardcoded action value into the return around lines 130-132
  • consult with @luacmartins what should work, but to my knowledge this commands do not yet work on backend side

Offline 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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:
    • 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 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(theme.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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.

Screenshots/Videos

Android: Native Screenshot 2024-06-21 at 12 53 48 Screenshot 2024-06-21 at 12 57 52
Android: mWeb Chrome
iOS: Native search-ios
iOS: mWeb Safari
MacOS: Chrome / Safari
rec-web-search-actions.mp4

Screenshot 2024-06-19 at 14 39 54
Screenshot 2024-06-19 at 14 43 53
Screenshot 2024-06-25 at 12 57 13
Screenshot 2024-06-21 at 12 35 05

MacOS: Desktop

@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch 2 times, most recently from eb85b2c to 8738a5b Compare May 9, 2024 12:29
@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch from 8738a5b to fcb8ade Compare May 23, 2024 12:23
@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch from fcb8ade to 12dded7 Compare June 6, 2024 08:32
@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch from 12dded7 to 012eaa9 Compare June 19, 2024 12:37
@Kicu Kicu changed the title [Search v1] [WIP] Add handling of actions to TransactionListItem [Search v1] Add handling of actions to TransactionListItem Jun 19, 2024
@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch from e0f2ee5 to ea52e69 Compare June 20, 2024 11:25
@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch from ea52e69 to b84088e Compare June 21, 2024 09:32
@Kicu Kicu changed the title [Search v1] Add handling of actions to TransactionListItem [Search v1] Add handling of actions to Transaction and Report items Jun 21, 2024
@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch from b84088e to 1584ced Compare June 21, 2024 10:01
@Kicu Kicu marked this pull request as ready for review June 21, 2024 10:59
@Kicu Kicu requested a review from a team as a code owner June 21, 2024 10:59
@melvin-bot melvin-bot bot requested review from eh2077 and removed request for a team June 21, 2024 10:59
Copy link

melvin-bot bot commented Jun 21, 2024

@eh2077 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@Kicu
Copy link
Contributor Author

Kicu commented Jun 21, 2024

@luacmartins ready for review, please take a look if this is what you expected.

src/types/onyx/SearchResults.ts Outdated Show resolved Hide resolved
src/types/onyx/SearchResults.ts Outdated Show resolved Hide resolved
src/components/SelectionList/Search/ReportListItem.tsx Outdated Show resolved Hide resolved
src/components/SelectionList/Search/ActionCell.tsx Outdated Show resolved Hide resolved
@WojtekBoman
Copy link
Contributor

LGTM! I left some minor comments

@luacmartins luacmartins self-requested a review June 21, 2024 15:17
Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

@Kicu FYI I have this PR for the paid/done labels, which is just pending an internal review. We'll have to update this PR to account for those changes. I'll hold on reviewing this PR until that's done.

@Kicu
Copy link
Contributor Author

Kicu commented Jun 24, 2024

@luacmartins oh this is surprising, I was attached to this issue so I thought I will take care of all the actions.

Then perhaps I will just wait for your PR to be merged and then re-create this PR? Feels like you implemented most of the changes, so I will just add mine on top

@luacmartins
Copy link
Contributor

@Kicu my PR was merged, so please update yours to handle the remaining actions

@shawnborton
Copy link
Contributor

But the button still has the same color as selected row. This is non-trivial to fix as the the behavior of button background colors is encoded within the generic Button component and I need to consult with some other devs if and how we want to change it.

Yeah, we definitely need to solve this though. @Expensify/design any strong feelings here? Basically we have a collision between the :selected/:active row BG color and our standard button BG color, which both use the same value.

I like the idea of just making those buttons slightly darker, to match the same thing we're doing with the receipt thumbnails. Alternatively we could find a different color entirely for our :active/:selected rows too, which might actually give us the least amount of headaches because it means we wouldn't need to change the receipt BG color, the border on badges, or the button components. Thoughts?

@shawnborton
Copy link
Contributor

Unrelated to my comment above.. looks like the BG of the receipt thumbnail changes for some cases, but not all:
CleanShot 2024-07-08 at 19 49 21@2x

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

LGTM and tests well. Left a small comment below

src/components/Search/SearchContext.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

@Kicu seems like we need to make some some design changes as well.

@dannymcclain
Copy link
Contributor

@shawnborton Collisions are the worst!

Alternatively we could find a different color entirely for our :active/:selected rows too, which might actually give us the least amount of headaches because it means we wouldn't need to change the receipt BG color, the border on badges, or the button components.

I really feel like this is the way to go. Changing the receipt BG color and border color on the badges is rough, but I really don't love the idea of having to change our button colors.

What if we used row-hover as the hover AND selected state for these? It avoids all collisions, but is it different enough? I kinda think with the green checkbox + the background it is. Curious for more thoughts though!

Made some mocks for us to check it out. The items are as follows:

  • default
  • hover
  • default
  • selected

Labeled colors (also, LOL at "buton" instead of "button" 😂):
CleanShot 2024-07-08 at 15 40 13

Light & Dark mode:
image

@shawnborton
Copy link
Contributor

Dang, I am a bit torn. I don't mind it too much but I do find myself wanting some more clear separation between the hover style and the selected style.

We could use our buttonHover color for the selected rows... we'd just need to consider using a different color for buttonHover in these rows. It still puts is in a bit of a pickle, but in the very least it wouldn't change the default button color:
image

Any other ideas to explore?

@dubielzyk-expensify
Copy link
Contributor

Hmm this sure is tricky. I do like the idea of having different row-hover and row-active colors so we don't have to run into this issue all the time.

I tried changing the thumbnail background to app-bg (though I don't mind button color either though it's a tad strong) and then creating a new row-active color variable. It gave me this:

CleanShot 2024-07-09 at 11 53 24

Alternatively, our border and button color is the same color now and I wonder if we could make the border color a bit subtler (which I would love regardless 😅 ) and therefor we could use it for active state!?

Anyways. I've set up a Figma playground if you wanna duplicate and play around with the prototype.

@shawnborton
Copy link
Contributor

In your prototype, what color are you using for row-active? It kinda looks similar to what I have above.

I think I prefer keeping the thumbnail BG using borders, as the appBG version feels quite dark when hovering or active.

@Kicu
Copy link
Contributor Author

Kicu commented Jul 9, 2024

hey yall,
I have a suggestion since I see some great discussion about colors - good colors are tricky 😅 but we probably don't want to block this PR. It introduces a lot of app/code logic around the actions on buttons and it will be helpful to merge it. I suggested to add styling changes here since I thought they would be small - I have not yet known about these color collisions.

Here is my suggestion:

  • I will fix a small code-comment from @luacmartins and I will fix the right padding issue @shawnborton - since this is easy to do
  • then, Carlos let's merge this PR; the button/color changes can be done in a separate PR
  • the bulk selection is already merged to main, which means these color problems are already there and merging this PR will not make anything worse.

Meanwhile we can use github and figma to iron out the colors :)

@shawnborton
Copy link
Contributor

That's fair. But I just checked again on staging and it looks like we're actually already handling the button color? Take a look at this:

CleanShot.2024-07-09.at.10.20.01.mp4

So maybe we aren't in a terrible spot to at least get this merged? Maybe you need to pull main or something. But it seems like the only small color adjustment would be the receipt thumbnail BG colors that we mentioned above.

@Kicu
Copy link
Contributor Author

Kicu commented Jul 9, 2024

Guys I'm very sorry for the confusion - this was already fixed on main and I actually broke the button. Here is the final solution:

rec-search-colors.mp4

both the button, border of Paid badge and the receipt fallbacks are buttonHoveredBG now which I think looks nice.

Padding right on the row is also update, now it will be 12px correctly on both ends.

@luacmartins @eh2077 I think this is now quite final and close to merging 😅

@Kicu Kicu force-pushed the search/kicu/39890-action-buttons branch from f75938c to fbf83af Compare July 9, 2024 09:18
@shawnborton
Copy link
Contributor

Nice, I think it makes sense to just go with what you are showing above for now and we can continue our color discussions elsewhere :)

@dubielzyk-expensify
Copy link
Contributor

Yep, that looks pretty good to me 😄

@dannymcclain
Copy link
Contributor

LOL - totally agree what you're showing there looks good.

We should still probably think about these color collisions because I really doubt this is the last time they'll come up, but I think we can take it to Slack and noodle on it with a bit less urgency.

@luacmartins
Copy link
Contributor

luacmartins commented Jul 9, 2024

Reviewer Checklist

  • 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 included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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
    • 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 */
    • 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(theme.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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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 reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Screen.Recording.2024-07-09.at.4.12.28.PM.mov
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

LGTM. Now that we fixed the row padding, I noticed that the header text is not aligned with the rows, but I'll fix that in a fast follower.

@luacmartins luacmartins merged commit 5499988 into Expensify:main Jul 9, 2024
14 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Jul 9, 2024

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.6-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.6-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/Julesssss in version: 9.0.6-1 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/Julesssss in version: 9.0.6-1 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.6-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.7-8 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

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

Successfully merging this pull request may close these issues.

9 participants