-
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
Change UI view for Attachments in Chat #4736
Change UI view for Attachments in Chat #4736
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
@@ -67,6 +67,8 @@ function AnchorRenderer({tnode, key, style}) { | |||
|
|||
// An auth token is needed to download Expensify chat attachments | |||
const isAttachment = Boolean(htmlAttribs['data-expensify-source']); | |||
const fileName = isAttachment && tnode.domNode && tnode.domNode.children && tnode.domNode.children[0] && tnode.domNode.children[0].data ? tnode.domNode.children[0].data : null; |
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.
Let's use lodashGet
to clean this up a bit
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.
Okay will do.
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.
Done
I have read the CLA Document and I hereby sign the CLA |
href={href} | ||
hrefAttrs={{rel, target}} | ||
|
||
props.shouldDownloadFile |
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.
Let's update this prop to isAttachment
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.
Done
src/components/AttachmentView.js
Outdated
{props.rightElement && ( | ||
<View style={styles.ml2}> | ||
{props.rightElement} | ||
</View> | ||
)} |
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.
Instead of passing down rightElement as props, pass down a prop called shouldShowDownloadIcon
to conditionally render the download icon
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.
Done
href={href} | ||
hrefAttrs={{rel, target}} | ||
|
||
props.shouldDownloadFile |
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.
update prop name to isAttachment
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.
Done
|
||
text: PropTypes.string, |
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.
Move this prop above style, and add comment
Also rename from text to fileName
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.
Done
@@ -81,6 +84,7 @@ function AnchorRenderer({tnode, key, style}) { | |||
rel={htmlAttribs.rel || 'noopener noreferrer'} | |||
style={style} | |||
key={key} | |||
text={fileName} |
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.
like above, change text prop name to fileName
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.
Done
@@ -67,6 +68,8 @@ function AnchorRenderer({tnode, key, style}) { | |||
|
|||
// An auth token is needed to download Expensify chat attachments | |||
const isAttachment = Boolean(htmlAttribs['data-expensify-source']); | |||
const fileName = isAttachment ? lodashGet(tnode, 'domNode.children[0].data') : null; |
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.
Add a default param to lodashGet(tnode, 'domNode.children[0].data')
of an empty string '' and remove the conditional and just use that
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.
Done
@thienlnam PR updated. Let me know if any other changes. |
…nt-view-in-comments
/** Flag to differentiate attachments and hyperlink. Base on flag link will be treated as a file download or a regular hyperlink? | ||
* (relevant to native platforms only) */ |
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.
Remove the ? and (relevant to native platforms only)
since it applies to all platforms
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.
Done
Changes look good, just the small name comment. I tested and it works as expected, but the file download name isn't the same name that is shown, it is still the name of a randomly generated string |
@thienlnam I have done those changes too but it doesn't work. I am getting a CORS issue when the |
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.
I've been doing some testing and am not getting the downloaded file to match the file name - are you experiencing the same issue?
Are you checking from localhost? That's what I was mentioning in the previous comment, I get a CORS error. Hence,
|
@akshayasalvi Gotcha, yeah that's where I've been testing - going to merge and we'll see if expected behavior still happens on prod |
@thienlnam Thanks for approving. We should be able to test this on staging right? |
@akshayasalvi Yup, will be tested on staging before it goes live on production (sorry, should have clarified) |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@akshayasalvi Hello! Any QA tests needed for this PR? |
@isagoico I've added the QA steps |
🚀 Deployed to production by @roryabraham in version: 1.0.88-2 🚀
|
This has been deployed to production and is now subject to a 7-day regression period. |
Details
Fixed Issues
$ #4601
Tests
QA Steps
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android