MM-22967 : Fixing file upload error feedback from server (#22972)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -87,6 +87,20 @@ export function uploadFile({file, name, type, rootId, channelId, clientId, onPro
|
||||
]));
|
||||
|
||||
onSuccess(response, channelId, rootId);
|
||||
} else if (xhr.status >= 400 && xhr.readyState === 4) {
|
||||
const errorResponse = JSON.parse(xhr.response);
|
||||
const errorMessage =
|
||||
(errorResponse?.id && errorResponse?.message) ? localizeMessage(errorResponse.id, errorResponse.message) :
|
||||
localizeMessage('file_upload.generic_error', 'There was a problem uploading your files.');
|
||||
|
||||
dispatch({
|
||||
type: FileTypes.UPLOAD_FILES_FAILURE,
|
||||
clientIds: [clientId],
|
||||
channelId,
|
||||
rootId,
|
||||
});
|
||||
|
||||
onError?.(errorMessage, clientId, channelId, rootId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -998,9 +998,9 @@ class AdvancedCreatePost extends React.PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
handleUploadError = (err: string | ServerError, clientId?: string, channelId?: string) => {
|
||||
let serverError = null;
|
||||
if (typeof err === 'string' && err.length > 0) {
|
||||
serverError = new Error(err);
|
||||
let serverError = err;
|
||||
if (typeof serverError === 'string') {
|
||||
serverError = new Error(serverError);
|
||||
}
|
||||
|
||||
if (!channelId || !clientId) {
|
||||
|
||||
Ссылка в новой задаче
Block a user