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] web_editor: show toaster notification error on uploading folder #151755
[FIX] web_editor: show toaster notification error on uploading folder #151755
Conversation
11be7e4
to
04bf5e8
Compare
04bf5e8
to
2862974
Compare
@http.route('/web_editor/get_valid_file', type='json', auth='user') | ||
def get_valid_file(self, filetype, extension): | ||
if not filetype and not extension: | ||
raise ValidationError(_("Please select a single file.")) | ||
return True |
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 don't think you need to add a new route just to check that the file type and file extension are defined. You can do that in pure Javascript 😃
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.
Yes, you are right but we want to show validationError.So, i create new route. I think that we can not raise validation error and we can only use toaster notifications in javascript.
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.
(see other comment)
addons/web_editor/static/src/components/upload_progress_toast/upload_service.js
Outdated
Show resolved
Hide resolved
addons/web_editor/static/src/components/upload_progress_toast/upload_service.js
Outdated
Show resolved
Hide resolved
addons/web_editor/static/src/components/upload_progress_toast/upload_service.js
Outdated
Show resolved
Hide resolved
cb28461
to
f743ff4
Compare
addons/web_editor/static/src/components/upload_progress_toast/upload_service.js
Outdated
Show resolved
Hide resolved
3054b83
to
3d591a0
Compare
deleteFile(file.id); | ||
env.services.notification.add( | ||
_.str.sprintf( | ||
env._t('Could not load the file "%s". Please select a single file.'), |
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.
The upload service can be used to upload multiple files. Therefore, the error message does not always give correct instructions to the user.
I would therefore either remove the second part of the error message either provide a relevant hint to the user on how they can solve that issue. Other than that, it's looks great to me 😃
Sorry for the back and forth 🙏 It was not really clear to me what the issue was. I followed the task specification but that was not really what we had to do. For the next step, we will have to contact the editor team because we are updating their module.
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.
Also: Can you update the PR description and the commit message to be inline with the changes we made? Thanks in advanced.
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 👍
Thanks in Advance 😊
3d591a0
to
7469789
Compare
7469789
to
153b493
Compare
Hereby delegating to @abd-msyukyu-odoo as it seems like it is an editor issue and already largely validated by Julien, so I don't have much added value here 😄 The only thing I will mention is to not forget to update the .POT files if you guys add labels and messages. Cheers! |
@robodoo delegate=@abd-msyukyu-odoo |
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.
@visp-odoo Hello, thanks for the PR, I added some comments :)
Could you add in the commit message and the PR description the OS you're using to reproduce the error, and the file browser you use ? (i.e. ubuntu version xxx with nautilus)
} catch { | ||
deleteFile(file.id); | ||
env.services.notification.add( | ||
_.str.sprintf( |
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.
Could you use the odoo sprintf
from odoo/addons/web/static/src/core/utils/strings.js
instead of _
library?
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 👍
deleteFile(file.id); | ||
env.services.notification.add( | ||
_.str.sprintf( | ||
env._t('Could not load the file "%s".'), |
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.
Could you add this line to the .pot
file since it will need new translations ?
Also, could you use _t
from odoo/addons/web/static/src/core/l10n/translation.js
instead of the one from the environment ? (will be easier on the forward ports)
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.
@abd-msyukyu-odoo Done changes 👍
741d0b2
to
ed090cd
Compare
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.
@visp-odoo Hello! Thanks for the update, I'll confirm with @odoo/rd-framework-editor to see if they are ok with the change, but LGTM.
I added a small comment to sort the imports
@@ -5,6 +5,8 @@ import { UploadProgressToast } from './upload_progress_toast'; | |||
import { getDataURLFromFile } from 'web.utils'; | |||
import { checkFileSize } from "@web/core/utils/files"; | |||
import { humanNumber } from "@web/core/utils/numbers"; | |||
import { _t } from "@web/core/l10n/translation"; |
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.
You could move this line above "@web/core/utils/files";
to keep imports grouped in some sort of alphabetical order (based on the path) => web/core/utils
are grouped together, after web/core/10n
(no need to adjust already existing imports)
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 👍
Steps to reproduce: OS: Ubuntu 20.04.4 LTS with nautilus Browser: Google Chrome Version 123.0.6312.58 - type /file command in knowledge - select a folder and click on open - traceback occurs Before this commit: When a user attempts to upload a folder using /file command, the processing begins, but the folder is not actually uploaded because the `getDataURLFromFile` return promise which is not fulfiled. Additionally, there is no indication of any warnings or errors during the folder upload process. After this commit: If a user attempts to upload a folder instead of a file using the /file command, it results in a error message in toaster notification. task-3690847
ed090cd
to
9ee5613
Compare
@robodoo r+ |
Steps to reproduce: OS: Ubuntu 20.04.4 LTS with nautilus Browser: Google Chrome Version 123.0.6312.58 - type /file command in knowledge - select a folder and click on open - traceback occurs Before this commit: When a user attempts to upload a folder using /file command, the processing begins, but the folder is not actually uploaded because the `getDataURLFromFile` return promise which is not fulfiled. Additionally, there is no indication of any warnings or errors during the folder upload process. After this commit: If a user attempts to upload a folder instead of a file using the /file command, it results in a error message in toaster notification. task-3690847 closes #151755 Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
Steps to reproduce: OS: Ubuntu 20.04.4 LTS with nautilus Browser: Google Chrome Version 123.0.6312.58 - type /file command in knowledge - select a folder and click on open - traceback occurs Before this commit: When a user attempts to upload a folder using /file command, the processing begins, but the folder is not actually uploaded because the `getDataURLFromFile` return promise which is not fulfiled. Additionally, there is no indication of any warnings or errors during the folder upload process. After this commit: If a user attempts to upload a folder instead of a file using the /file command, it results in a error message in toaster notification. task-3690847 closes #151755 Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
@visp-odoo @abd-msyukyu-odoo this pull request has forward-port PRs awaiting action (not merged or closed): |
1 similar comment
@visp-odoo @abd-msyukyu-odoo this pull request has forward-port PRs awaiting action (not merged or closed): |
Steps to reproduce:
OS: Ubuntu 20.04.4 LTS with nautilus
Browser: Google Chrome Version 123.0.6312.58
Current behavior before PR:
When a user attempts to upload a folder using /file command, the processing begins, but the folder is not uploaded because the
getDataURLFromFile
return promise is not fulfilled. Additionally, there is no indication of any warnings or errors during the folder upload process.Desired behavior after PR is merged:
If a user attempts to upload a folder instead of a file using the /file command, it results in an error message in the toaster notification.
task-3690847