-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix 22306 web appropriate message is not shown when drag drop a folder #23321
Fix 22306 web appropriate message is not shown when drag drop a folder #23321
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
recheck |
@abdulrahuman5196 we can modify the Error Title and message Based on your need. |
@abdulrahuman5196 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] |
src/components/AttachmentModal.js
Outdated
* @returns {Boolean} | ||
*/ | ||
const isValidFile = useCallback( | ||
(_file) => { | ||
(_file,_data) => { |
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.
Why do we need both file and data? _data.getAsFile
provides the file right?
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.
yeah, but this function is also used in the file picker addition to drag and drop, so there you won't get data files but normal file objects. Added this condition will resolve even if a user is uploading on different platforms it won't have an effect.
we can remove _data
props but we should add this check or we can create a function which do the same.
let _file = _data
if (typeof _data.getAsFile === 'function' ){
_file = _data.getAsFile();
}
so what's your suggestion?
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.
My concern is we are literally passing a superset data
(which could also has file). But you are saying in file picker we won't get this data
, only file
value.
I think we can replace there as well. But i don't think it worth that change.
Then maybe before coming to function itself can we do a early return if the data is a directory and display appropriate error here itself
if (typeof _data.getAsFile === 'function' ){
_file = _data.getAsFile();
}
This will also provide segregated code check for directory and file check.
We can maybe create a function isDirectory
and use it on the above which will be much cleaner.
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.
/**
* @param {Object} _data
* @returns {Object}
*/
const isDirectoryCheckAndGetFile = useCallback((_data) => {
if (typeof _data.webkitGetAsEntry === 'function' && _data.webkitGetAsEntry().isDirectory) {
setIsAttachmentInvalid(true);
setAttachmentInvalidReasonTitle(props.translate('attachmentPicker.attachmentError'));
setAttachmentInvalidReason(props.translate('attachmentPicker.folderNotAllowedMessage'));
return null;
}
if (typeof _data.getAsFile === 'function' ){
return _data.getAsFile();
}
return _data
},[props.translate])
const validateAndDisplayFileToUpload = ...(_data) => {
const _file = isDirectoryCheckAndGetFile(_data)
if(!_file){
return }
....
}...
what about this approach?
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.
IMO, IsDirectorycheck and getFile is different functionality. So IsDirectorycheck is fine and getFile can stay in current validateAndDisplayFileToUpload place
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
recheck |
@luacmartins If possible could you start the workflow steps to avoid lint failures after testing? |
done |
src/languages/en.js
Outdated
@@ -168,6 +168,7 @@ export default { | |||
sizeNotMet: 'Attachment size must be greater than 240 bytes.', | |||
wrongFileType: 'Attachment is the wrong type', | |||
notAllowedExtension: 'This filetype is not allowed', | |||
folderNotAllowedMessage: 'Uploading folder is not allowed.' |
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.
@luacmartins Sorry to bother again.
Whom should we confirm the error message with? In most cases previously internal engineers would provide the required string AFAIK.
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.
@luacmartins Gentle ping on this confirmation
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.
@abdulrahuman5196 thanks for the ping, I missed the first one 😬 I added the Waiting for copy
label in the issue to get someone to review the copy. Let's see what they say.
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.
@Charan-hs @abdulrahuman5196 the updated copy is: Uploading a folder is not allowed. Try a different file.
@Charan-hs lint and signed commits are failing, kindly fix the same(I suspected lint to fail, that's why requested to run checks). Since you are a first time contributor just providing some information - |
11c23f7
to
29df310
Compare
29df310
to
ff278da
Compare
all Commits are Signed and resolved lint issues. |
recheck |
src/components/AttachmentModal.js
Outdated
if (!isDirectoryCheck(_data)) { | ||
return; | ||
} | ||
/* eslint no-underscore-dangle: 0 */ |
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.
Why do we need to want to disable a lint rule here? Can we just rename the variable @Charan-hs ?
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.
Just to stay with the previous file name so. can I change that to fileObject
@abdulrahuman5196 ?
@Charan-hs Can we also check and fix the merge conflicts? |
…wn_when_drag_drop_a_folder
…wn_when_drag_drop_a_folder
…is_not_shown_when_drag_drop_a_folder
@Charan-hs Is the changes complete from your end? |
@luacmartins I already tested previously all the changes before merge conflict and it was working fine. Can we re-run the workflow checks? If its working I can do a quick test again and we can merge. |
yes, All Good @abdulrahuman5196 |
@abdulrahuman5196 kicked off the workflow checks |
@Charan-hs Lint code is failing. Could you kindly check on the same? |
@Charan-hs lint is failing! |
resolved Lint Issue, |
All checks are passing now! @abdulrahuman5196 wanna do a final check before we merge? |
Yes. Working on it |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-08-02.at.1.22.47.PM.mp4Mobile Web - Chromeaz_recorder_20230802_134344.mp4Mobile Web - SafariUntitled.1.mp4DesktopScreen.Recording.2023-08-02.at.1.34.47.PM.mp4iOSScreen.Recording.2023-08-02.at.1.36.20.PM.mp4AndroidScreen.Recording.2023-08-02.at.1.38.29.PM.mp4Screen.Recording.2023-08-02.at.1.40.16.PM.mp4 |
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.
Changes looks good and works well. Reviewers checklist is also complete.
All yours. @luacmartins Good to merge
🎀 👀 🎀
C+ Reviewed
Just to note: I was seeing issue where the error message was not dynamically changed on language changes from other devices. But I am able to see the same issue in main as well. So Will raise a separate bug on the same. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/luacmartins in version: 1.3.50-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.50-3 🚀
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 1.3.51-0 🚀
|
🚀 Deployed to production by https://github.com/Julesssss in version: 1.3.51-2 🚀
|
Details
Fixed Issues
$ #22306
PROPOSAL: #22306 (comment)
Tests
Uploading a folder is not allowed. Try a different file.
shown.Offline tests
same as above
QA Steps
same as above
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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)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
Web
Safari-Folder-1.mov
Chrome-folder-1.mov
safari-fileWithoutType-1.mov
Mobile Web - Chrome
mobile.chrome.test.comp.mp4
Mobile Web - Safari
ios.mobile.safari.comp.mp4
Desktop
desktop.rec.comp.mp4
iOS
ios.app.comp.mp4
Android
android.app.com.test.mp4