[FIX] web_editor, *: correctly set the ProgressBar component props
*: web_unsplash Before this commit, if we were in debug mode, when we tried to replace or add an image, a traceback appeared when selecting an Unsplash image for the first time or when uploading an image of size 0 (also for the first time). Note that once the traceback was closed, it did not reappear until the page was refreshed, but the progress bar was not displayed anymore. It happened because in debug mode, there is a validation of the different owl components props and some props of the `ProgressBar` component were not correctly set when adding Unsplash images or empty image files, causing the props validation to fail. Those props definition were incorrectly added with [1]. The traceback was not reappearing because the `UploadProgressToast` component (= the parent of `ProgressBar`) has been destroyed and so the props validation was not done anymore since the components were not there. This commit fixes these issues by correctly setting the `ProgressBar` props and by adding default props, in order for them to always have a value when omitted. Steps to reproduce: - Activate the debug mode. - In edit mode, drop the Text-Image snippet. - Double-click on the image to replace it. - Type something in the search bar and select an Unsplash image or upload an empty image file. => A traceback appears. [1]: https://github.com/odoo/odoo/commit/886f3de768b647f4b402c97098abf274d6258f75 opw-3413299 closes odoo/odoo#132377 X-original-commit: 425dfb07f21288caf56bceea3a86e0b7ecac4a91 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
+12
-5
@@ -10,12 +10,19 @@ export class ProgressBar extends Component {
|
||||
}
|
||||
ProgressBar.template = 'web_editor.ProgressBar';
|
||||
ProgressBar.props = {
|
||||
progress: Number,
|
||||
hasError: Boolean,
|
||||
uploaded: Boolean,
|
||||
progress: { type: Number, optional: true },
|
||||
hasError: { type: Boolean, optional: true },
|
||||
uploaded: { type: Boolean, optional: true },
|
||||
name: String,
|
||||
size: String,
|
||||
errorMessage: String,
|
||||
size: { type: String, optional: true },
|
||||
errorMessage: { type: String, optional: true },
|
||||
};
|
||||
ProgressBar.defaultProps = {
|
||||
progress: 0,
|
||||
hasError: false,
|
||||
uploaded: false,
|
||||
size: "",
|
||||
errorMessage: "",
|
||||
};
|
||||
|
||||
export class UploadProgressToast extends Component {
|
||||
|
||||
@@ -74,7 +74,7 @@ export const uploadService = {
|
||||
return null;
|
||||
}
|
||||
if (!fileSize) {
|
||||
fileSize = null;
|
||||
fileSize = "";
|
||||
} else {
|
||||
fileSize = humanNumber(fileSize) + "B";
|
||||
}
|
||||
@@ -87,10 +87,6 @@ export const uploadService = {
|
||||
id,
|
||||
name: file.name,
|
||||
size: fileSize,
|
||||
progress: 0,
|
||||
hasError: false,
|
||||
uploaded: false,
|
||||
errorMessage: '',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -246,8 +246,6 @@ patch(uploadService, {
|
||||
name: records.length > 1 ?
|
||||
_t("Uploading %s '%s' images.", records.length, records[0].query) :
|
||||
_t("Uploading '%s' image.", records[0].query),
|
||||
size: null,
|
||||
progress: 0,
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user