frontend: Show link to delete files in quota exceeded error.

This commit is contained in:
Vishnu Ks
2017-09-05 21:46:40 +05:30
committed by Tim Abbott
parent 9c70da1a78
commit d8f8e29ff5
2 changed files with 22 additions and 7 deletions

View File

@@ -1252,26 +1252,38 @@ function test_with_mock_socket(test_params) {
$("#error-msg").text('');
}
function assert_side_effects(msg) {
function assert_side_effects(msg, check_html=false) {
assert($("#send-status").hasClass("alert-error"));
assert(!$("#send-status").hasClass("alert-info"));
assert.equal($("#compose-send-button").prop("disabled"), false);
if (check_html) {
assert.equal($("#error-msg").html(), msg);
} else {
assert.equal($("#error-msg").text(), msg);
}
}
function test(err, file, msg) {
setup_test();
compose.uploadError(err, file);
// The text function and html function in zjquery is not in sync
// with each other. QuotaExceeded changes html while all other errors
// changes body.
if (err === 'QuotaExceeded') {
assert_side_effects(msg, true);
} else {
assert_side_effects(msg);
}
}
var msg_prefix = 'translated: ';
var msg_1 = 'File upload is not yet available for your browser.';
var msg_2 = 'Unable to upload that many files at once.';
var msg_3 = '"foobar.txt" was too large; the maximum file size is 25MiB.';
var msg_4 = 'Sorry, the file was too large.';
var msg_5 = 'Upload would exceed your maximum quota.' +
' Consider deleting some previously uploaded files.';
var msg_5 = 'Upload would exceed your maximum quota. You can delete old attachments to ' +
'free up space. <a href="#settings/uploaded-files">translated: Click here</a>';
var msg_6 = 'An unknown error occurred.';
test('BrowserNotSupported', {}, msg_prefix + msg_1);

View File

@@ -766,8 +766,11 @@ exports.initialize = function () {
msg = i18n.t("Sorry, the file was too large.");
break;
case 'QuotaExceeded':
msg = i18n.t("Upload would exceed your maximum quota. Consider deleting some previously uploaded files.");
break;
var translation_part1 = i18n.t('Upload would exceed your maximum quota. You can delete old attachments to free up space.');
var translation_part2 = i18n.t('Click here');
msg = translation_part1 + ' <a href="#settings/uploaded-files">' + translation_part2 + '</a>';
$("#error-msg").html(msg);
return;
default:
msg = i18n.t("An unknown error occurred.");
break;