Skip to content

Commit 664f199

Browse files
authored
[5.2] MediaManager: improve error handling (#38536)
1 parent 088e878 commit 664f199

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

administrator/components/com_media/resources/scripts/app/Api.es6.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ function handleError(error) {
5151
const response = JSON.parse(error.response);
5252
if (response.message) {
5353
notifications.error(response.message);
54+
// Check for App messages queue
55+
if (response.messages) {
56+
Object.keys(response.messages).forEach((type) => {
57+
response.messages[type].forEach((message) => {
58+
if (type === 'error') {
59+
notifications.error(message);
60+
} else {
61+
notifications.notify(message);
62+
}
63+
});
64+
});
65+
}
5466
} else {
5567
switch (error.status) {
5668
case 409:

administrator/components/com_media/resources/scripts/app/Notifications.es6.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function notify(message, options) {
2020
}
2121

2222
const notifications = {
23-
/* Send and success notification */
23+
/* Send a success notification */
2424
success: (message, options) => {
2525
notify(message, {
2626
type: 'message', // @todo rename it to success
@@ -38,6 +38,15 @@ const notifications = {
3838
});
3939
},
4040

41+
/* Send a general notification */
42+
notify: (message, options) => {
43+
notify(message, {
44+
type: 'message',
45+
dismiss: true,
46+
...options,
47+
});
48+
},
49+
4150
/* Ask the user a question */
4251
ask: (message) => window.confirm(message),
4352
};

administrator/language/en-GB/lib_joomla.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ JLIB_MEDIA_ERROR_UPLOAD_INPUT="Unable to upload file."
701701
JLIB_MEDIA_ERROR_WARNFILENAME="File name must only have alphanumeric characters and no spaces."
702702
JLIB_MEDIA_ERROR_WARNFILETOOLARGE="This file is too large to upload. You can change the limits for your site in the component options."
703703
JLIB_MEDIA_ERROR_WARNFILETYPE="This file type is not supported."
704-
JLIB_MEDIA_ERROR_WARNIEXSS="Possible IE XSS Attack found."
704+
JLIB_MEDIA_ERROR_WARNIEXSS="The file looks suspicious, therefore cannot be uploaded."
705705
JLIB_MEDIA_ERROR_WARNINVALID_IMG="Not a valid image."
706706
JLIB_MEDIA_ERROR_WARNINVALID_MIME="Invalid mime type detected."
707707
JLIB_MEDIA_ERROR_WARNINVALID_MIMETYPE="Illegal mime type detected: %s"

language/en-GB/lib_joomla.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ JLIB_MEDIA_ERROR_UPLOAD_INPUT="Unable to upload file."
687687
JLIB_MEDIA_ERROR_WARNFILENAME="File name must only have alphanumeric characters and no spaces."
688688
JLIB_MEDIA_ERROR_WARNFILETOOLARGE="This file is too large to upload."
689689
JLIB_MEDIA_ERROR_WARNFILETYPE="This file type is not supported."
690-
JLIB_MEDIA_ERROR_WARNIEXSS="Possible IE XSS Attack found."
690+
JLIB_MEDIA_ERROR_WARNIEXSS="The file looks suspicious, therefore cannot be uploaded."
691691
JLIB_MEDIA_ERROR_WARNINVALID_IMG="Not a valid image."
692692
JLIB_MEDIA_ERROR_WARNINVALID_MIME="Invalid mime type detected."
693693
JLIB_MEDIA_ERROR_WARNINVALID_MIMETYPE="Illegal mime type detected: %s"

0 commit comments

Comments
 (0)