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 handling of internal errors when uploading theming files #33332

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/theming/js/settings-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ window.addEventListener('DOMContentLoaded', function () {
},
fail: function (e, response){
var $form = $(e.target).closest('form');
OC.msg.finishedError('#theming_settings_msg', response._response.jqXHR.responseJSON.data.message);
const responseJSON = response._response.jqXHR.responseJSON;
OC.msg.finishedError('#theming_settings_msg', responseJSON && responseJSON.data && responseJSON.data.message ? responseJSON.data.message : t('theming', 'Error uploading the file'));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
OC.msg.finishedError('#theming_settings_msg', responseJSON && responseJSON.data && responseJSON.data.message ? responseJSON.data.message : t('theming', 'Error uploading the file'));
OC.msg.finishedError('#theming_settings_msg', responseJSON?.data?.message || t('theming', 'Error uploading the file'));

Let's shorten this

Copy link
Member Author

Choose a reason for hiding this comment

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

I used the long syntax because the JavaScript file is not transpiled. Is it safe to use the optional chaining operator in that case?

Copy link
Member

Choose a reason for hiding this comment

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

Judging from the compatibility table and the supported browsers of our browserslist config it looks like everything is fully compatible except for 0.560% of users on v12.2-12.5 of Safari iOS

So for now I'd say to not use the modern syntax to ensure compatibility

$form.find('label.button').addClass('icon-upload').removeClass('icon-loading-small');
$('#theming_settings_loading').hide();
}
Expand Down