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

[FIX] web_editor: show toaster notification error on uploading folder #151755

Closed

Conversation

visp-odoo
Copy link
Contributor

@visp-odoo visp-odoo commented Jan 30, 2024

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

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

@robodoo
Copy link
Contributor

robodoo commented Jan 30, 2024

@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch from 11be7e4 to 04bf5e8 Compare January 30, 2024 12:23
@C3POdoo C3POdoo added the RD research & development, internal work label Jan 30, 2024
@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch from 04bf5e8 to 2862974 Compare January 30, 2024 13:00
Comment on lines 828 to 832
@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
Copy link
Contributor

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 😃

Copy link
Contributor Author

@visp-odoo visp-odoo Jan 31, 2024

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

(see other comment)

@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch 3 times, most recently from cb28461 to f743ff4 Compare March 13, 2024 13:11
@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch 4 times, most recently from 3054b83 to 3d591a0 Compare March 19, 2024 09:42
deleteFile(file.id);
env.services.notification.add(
_.str.sprintf(
env._t('Could not load the file "%s". Please select a single file.'),
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 😊

@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch from 3d591a0 to 7469789 Compare March 20, 2024 04:59
@visp-odoo visp-odoo changed the title [FIX] web_editor: show validation error on uploading folder [FIX] web_editor: show toaster notification error on uploading folder Mar 20, 2024
@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch from 7469789 to 153b493 Compare March 20, 2024 05:04
@awa-odoo
Copy link
Contributor

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!

@awa-odoo
Copy link
Contributor

@robodoo delegate=@abd-msyukyu-odoo

Copy link
Contributor

@abd-msyukyu-odoo abd-msyukyu-odoo left a 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(
Copy link
Contributor

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?

Copy link
Contributor Author

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".'),
Copy link
Contributor

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)

Copy link
Contributor Author

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 👍

@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch 2 times, most recently from 741d0b2 to ed090cd Compare March 28, 2024 06:51
Copy link
Contributor

@abd-msyukyu-odoo abd-msyukyu-odoo left a 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";
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done changes 👍

@abd-msyukyu-odoo abd-msyukyu-odoo marked this pull request as ready for review March 28, 2024 09:11
@C3POdoo C3POdoo requested a review from a team March 28, 2024 09:13
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
@visp-odoo visp-odoo force-pushed the 16.0-traceback-on-uploading-folder-visp branch from ed090cd to 9ee5613 Compare March 28, 2024 09:50
@abd-msyukyu-odoo
Copy link
Contributor

@robodoo r+

robodoo pushed a commit that referenced this pull request Mar 28, 2024
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>
robodoo pushed a commit that referenced this pull request Mar 28, 2024
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>
@robodoo robodoo closed this Mar 28, 2024
1 similar comment
@fw-bot fw-bot deleted the 16.0-traceback-on-uploading-folder-visp branch April 11, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants