-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[HOLD for payment 2024-01-24] Refactor and Fix Attachment Handling in File Download and Carousel #31791
[HOLD for payment 2024-01-24] Refactor and Fix Attachment Handling in File Download and Carousel #31791
Conversation
Some bugs can be caught earlier if we're warned when `file` or `file.name` is missing
@aimane-chnaif 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] |
Introduce getFileName in FileUtils to generate fallback names for attachments lacking original file names. This function extracts and sanitizes filenames from URLs, ensuring attachments in AttachmentCarousel have meaningful names even when original names are missing. Updated AttachmentCarousel to utilize this new utility function. At this time, the only know case is embedded attachments shared by the Concierge account via drag and drop
Addressed a bug in libs/fileDownload where the intended fallback for filenames was never reached due to `FileUtils.appendTimeToFileName` always providing a return value. This fix refines the filename determination logic, ensuring effective use of fallback mechanisms across various components including AttachmentCarousel, particularly for cases like attachments shared by the Concierge account.
3c65733
to
1b58d05
Compare
Update: added specific test steps |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
@kidroca please complete author checklist. Some platform screenshots are still missing |
✔️ Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
@kidroca you've got conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good aside from conflicts!
…loads # Conflicts: # src/components/Attachments/AttachmentCarousel/extractAttachmentsFromReport.js
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…d-to-file-downloads Refactor and Fix Attachment Handling in File Download and Carousel (cherry picked from commit 3915fb2)
…ng-31791-2 🍒 Cherry pick PR #31791 to staging 🍒
🚀 Deployed to staging by https://github.com/NikkiWines in version: 1.4.8-2 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.8-3 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.8-3 🚀
|
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.25-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-01-24. 🎊 |
Details
Pull Request Description
This pull request introduces several changes aimed at improving the handling of attachments in file download processes and the Attachment Carousel component. The key changes are as follows:
Refactor
libs/FileUtils
: The functiongetAttachmentName
has been removed. It has been replaced bygetFileName
, which extracts and sanitizes filenames from URLs for filesystem usage. This new function decodes the URL segment, replaces illegal characters with underscores, and includes logging for cases where the filename cannot be determined.Fix in
libs/fileDownload
: Modifications have been made to ensure there is a reachable fallback for filenames. This includes changes in various platform-specific files (index.android.ts
,index.ios.ts
,index.ts
) to utilizegetFileName
for generating fallback filenames when necessary.Update in
AttachmentCarousel
: The CarouselItem component now uses the source URL for fallback file names. This change is reflected inextractAttachmentsFromReport.js
, where the source and filename are determined based on either the provided attributes or the fallback logic.PropTypes Enhancements: In
AttachmentCarousel/CarouselItem.js
andAttachments/propTypes.js
, thefile
property within the attachment prop types has been updated to be required, ensuring better type safety and clarity in the component's expected data structure.Technical Details:
AttachmentCarousel/CarouselItem.js
Attachments/propTypes.js
AttachmentCarousel/extractAttachmentsFromReport.js
fileDownload/FileUtils.ts
fileDownload/index.android.ts
fileDownload/index.ios.ts
fileDownload/index.ts
The changes aim to enhance the robustness of attachment handling, ensuring filenames are correctly determined and handled across different components and platforms. Additionally, the update in PropTypes enforces stricter type checking, contributing to the overall reliability of the components.
Fixed Issues
$ #30931
PROPOSAL: #30931 (comment)
Tests
Case 1 - Concierge Drag & Drop Attachments
Objective: Ensure attachments added by Concierge through Drag & Drop are downloadable across platforms.
Prerequisites: A chat session with Concierge.
General:
On Web / Desktop:
On iOS / Android (a regression prevents testing this flow in the current PR):
Case 2 - File Names Compliance
Objective: Verify that downloaded file names adhere to the specified naming conventions.
General:
Case 1
for this test.Naming Rules Verification:
For files with original names:
sample.pdf
.sample-2023-11-29 17_42_33.461.pdf
.:
) in datetime with underscores (_
) as colons are not permitted in filenames.For files without original names (e.g., Concierge Drag & Drop attachments):
https://s3-us-west-1.amazonaws.com/concierge-responses-expensify-com/uploads%2F1676033736079-1676033736079.png
.uploads_F1676033736079-1676033736079-2023-11-29 17_44_14.113.png
.Case 3 - Prop-Type Warnings for Attachment Carousel
Objective: Ensure there are no prop-type warnings in the console related to file names when opening attachments in the attachment carousel.
General Procedure:
Interaction with Various Attachments:
Observation in Attachment Carousel:
Expected Outcome:
Offline tests
N/A - attachments cannot be downloaded while offline
QA Steps
The following tests are applicable to both staging and production
Case 1 - Concierge Drag & Drop Attachments
Objective: Ensure attachments added by Concierge through Drag & Drop are downloadable across platforms.
Prerequisites: A chat session with Concierge.
General:
On Web / Desktop:
On iOS / Android (a regression prevents testing this flow in the current PR):
Case 2 - File Names Compliance
Objective: Verify that downloaded file names adhere to the specified naming conventions.
General:
Case 1
for this test.Naming Rules Verification:
For files with original names:
sample.pdf
.sample-2023-11-29 17_42_33.461.pdf
.:
) in datetime with underscores (_
) as colons are not permitted in filenames.For files without original names (e.g., Concierge Drag & Drop attachments):
https://s3-us-west-1.amazonaws.com/concierge-responses-expensify-com/uploads%2F1676033736079-1676033736079.png
.uploads_F1676033736079-1676033736079-2023-11-29 17_44_14.113.png
.Case 3 - Prop-Type Warnings for Attachment Carousel
Objective: Ensure there are no prop-type warnings in the console related to file names when opening attachments in the attachment carousel.
General Procedure:
Interaction with Various Attachments:
Observation in Attachment Carousel:
Expected Outcome:
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop