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

Update isReportMessageAttachment logic #8117

Merged
merged 6 commits into from
Apr 5, 2022

Conversation

sobitneupane
Copy link
Contributor

Details

Solves the issue "When [Attachment] is sent as the message, 'Edit Comment' option does not appear in contextMenu "

Fixed Issues

$ #7739

Tests

  1. Send attachment and hover over attachment to see only three options ('Copy to clipboard', 'Mark as unread', 'Delete comment')
  2. Send message text '[Attachment]' and hover over the message to see all four options ('Copy to clipboard', 'Mark as unread', 'Edit comment', 'Delete comment')
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I verified the PR has a small number of commits behind main
  • 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 clearly indicated the environment tests should be run in (Staging vs Production)
  • I wrote testing steps that cover success & fail scenarios (if applicable)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests & veryfy they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors related to changes in this PR
  • I followed proper code patterns (see Reviewing the code)
    • I added comments when the code was not self explanatory
    • I put all copy / text shown in the product in all src/languages/* files (if applicable)
    • I followed proper naming convention for platform-specific files (if applicable)
    • I followed style guidelines (in Styling.md) for all style edits I made
    • I followed the JSDocs style guidelines (in STYLE.md)
  • 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 corroborated the UI performance was not affected (the performance is the same than main branch)
  • If I created a new component I verified that a similar component doesn't exist in the codebase

PR Reviewer Checklist

  • I verified the PR has a small number of commits behind main
  • 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 testing environment is mentioned in the test steps
  • I verified testing steps cover success & fail scenarios (if applicable)
  • 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 related to changes in this PR
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified comments were added when the code was not self explanatory
    • I verified any copy / text shown in the product was added in all src/languages/* files (if applicable)
    • I verified proper naming convention for platform-specific files was followed (if applicable)
    • I verified style guidelines were followed
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components are not impacted by changes in this PR (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 the UI performance was not affected (the performance is the same than main branch)
  • If a new component is created I verified that a similar component doesn't exist in the codebase

QA Steps

  1. Send attachment and hover over attachment to see only three options ('Copy to clipboard', 'Mark as unread', 'Delete comment')
  2. Send message text '[Attachment]' and hover over the message to see all four options ('Copy to clipboard', 'Mark as unread', 'Edit comment', 'Delete comment')
  • Verify that no errors appear in the JS console

Screenshots

Web

Screen.Recording.2022-03-13.at.21.18.36.mov

Mobile Web

Screen.Recording.2022-03-13.at.22.47.22.mov

Desktop

Screen.Recording.2022-03-13.at.21.34.43.mov

iOS

Screen.Recording.2022-03-13.at.22.45.17.mov

Android

Screen.Recording.2022-03-13.at.23.19.19.mov

@sobitneupane sobitneupane requested a review from a team as a code owner March 13, 2022 17:58
@MelvinBot MelvinBot requested review from Luke9389 and parasharrajat and removed request for a team March 13, 2022 17:58
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

Do you see a pattern here that can be optimized?

Comment on lines 32 to 33
function isReportMessageAttachment(reportMessageText, reportMessageHtml) {
return reportMessageText === '[Attachment]' && reportMessageHtml !== '[Attachment]';
Copy link
Contributor

Choose a reason for hiding this comment

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

could put the lodashGet in here rather than passing it in as an argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops! Sorry @parasharrajat, didn't see this before leaving this comment 😅

Copy link
Member

Choose a reason for hiding this comment

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

No worries.

@sobitneupane
Copy link
Contributor Author

Do you see a pattern here that can be optimized?

reportMessageText and reportMessageHtml are obtained from different variables in different cases.
In reportUtils.js, ContextMenuAction.js and Report.js, they are obtained from reportAction but
in OptionsListUtils.js, they are obtained from report.

So, they are extracted from variable(reportAction or report) before passing to the function isReportMessageAttachment().

@parasharrajat
Copy link
Member

Ok. Awesome. let's do it. pass a single param to that function that checks both values.

@sobitneupane
Copy link
Contributor Author

Ok. Awesome. let's do it. pass a single param to that function that checks both values.

Is this what you are suggesting?

function isReportMessageAttachment(reportMessage) {
    return lodashGet(reportMessage, 'text', '') === '[Attachment]' && lodashGet(reportMessage, 'html', '') !== '[Attachment]';
}
isReportMessageAttachment({text: lodashGet(reportAction, ['message', 0, 'text'], ''), html: lodashGet(reportAction, ['message', 0, 'html'], '')});

@sobitneupane

This comment was marked as resolved.

src/libs/actions/Report.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/reportUtils.js Outdated Show resolved Hide resolved
src/pages/home/report/ContextMenu/ContextMenuActions.js Outdated Show resolved Hide resolved
parasharrajat
parasharrajat previously approved these changes Mar 18, 2022
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

LGTM.

cc: @Luke9389

PR Reviewer Checklist

  • I verified the PR has a small number of commits behind main
  • 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 testing environment is mentioned in the test steps
  • I verified testing steps cover success & fail scenarios (if applicable)
  • 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 related to changes in this PR
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified comments were added when the code was not self explanatory
    • I verified any copy / text shown in the product was added in all src/languages/* files (if applicable)
    • I verified proper naming convention for platform-specific files was followed (if applicable)
    • I verified style guidelines were followed
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components are not impacted by changes in this PR (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 the UI performance was not affected (the performance is the same than main branch)
  • If a new component is created I verified that a similar component doesn't exist in the codebase

🎀 👀 🎀 C+ reviewed

Copy link
Contributor

@Luke9389 Luke9389 left a comment

Choose a reason for hiding this comment

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

Lookin' good.
Just one NAB. Up to you if you'd like to implement that.

src/libs/reportUtils.js Outdated Show resolved Hide resolved
Co-authored-by: Luke Donahue <49007721+Luke9389@users.noreply.github.com>
@sobitneupane sobitneupane requested a review from marcaaron as a code owner April 3, 2022 16:02
@sobitneupane
Copy link
Contributor Author

Lookin' good.
Just one NAB. Up to you if you'd like to implement that.

@Luke9389 Made the suggested change.

@Luke9389 Luke9389 merged commit 4b5abf6 into Expensify:main Apr 5, 2022
@OSBotify
Copy link
Contributor

OSBotify commented Apr 5, 2022

✋ 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

OSBotify commented Apr 5, 2022

🚀 Deployed to staging by @Luke9389 in version: 1.1.51-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Apr 6, 2022

🚀 Deployed to production by @roryabraham in version: 1.1.51-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Apr 6, 2022

🚀 Deployed to production by @roryabraham in version: 1.1.51-0 🚀

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

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.

4 participants