mirror of https://github.com/zulip/zulip.git
web: Remove nonsense round-trip through JSON.parse() + JSON.stringify().
This commit is contained in:
parent
d05a9d4000
commit
d05a1e9efa
|
@ -221,8 +221,6 @@ function show_modal() {
|
|||
error(xhr) {
|
||||
$("#dialog_error").hide();
|
||||
dialog_widget.hide_dialog_spinner();
|
||||
const errors = JSON.parse(xhr.responseText).msg;
|
||||
xhr.responseText = JSON.stringify({msg: errors});
|
||||
ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $emoji_status);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -216,8 +216,6 @@ export function populate_user_groups() {
|
|||
setTimeout(show_saved_button, 200);
|
||||
},
|
||||
error(xhr) {
|
||||
const errors = JSON.parse(xhr.responseText).msg;
|
||||
xhr.responseText = JSON.stringify({msg: errors});
|
||||
ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $user_group_status);
|
||||
update_cancel_button();
|
||||
$(`#user-groups #${CSS.escape(data.id)} .name`).text(group_data.name);
|
||||
|
@ -324,8 +322,6 @@ export function add_user_group() {
|
|||
},
|
||||
error(xhr) {
|
||||
$user_group_status.hide();
|
||||
const errors = JSON.parse(xhr.responseText).msg;
|
||||
xhr.responseText = JSON.stringify({msg: errors});
|
||||
ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $user_group_status);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -538,21 +538,14 @@ test_ui("on_events", ({override_rewire, mock_template}) => {
|
|||
|
||||
assert.ok(!$("#dialog_error").visible());
|
||||
})();
|
||||
|
||||
(function test_post_error() {
|
||||
$("#dialog_error").show();
|
||||
ui_report.error = (error_msg, error_obj, ele) => {
|
||||
const xhr = {
|
||||
responseText: '{"msg":"fake-msg"}',
|
||||
};
|
||||
assert.equal(error_msg, "translated HTML: Failed");
|
||||
assert.deepEqual(error_obj, xhr);
|
||||
assert.deepEqual(error_obj, {responseJson: {msg: "fake-msg"}});
|
||||
assert.equal(ele, $("#dialog_error"));
|
||||
};
|
||||
const xhr = {
|
||||
responseText: '{"msg":"fake-msg", "attrib":"val"}',
|
||||
};
|
||||
opts.error(xhr);
|
||||
opts.error({responseJson: {msg: "fake-msg"}});
|
||||
|
||||
assert.ok(!$("#dialog_error").visible());
|
||||
})();
|
||||
|
@ -763,17 +756,11 @@ test_ui("on_events", ({override_rewire, mock_template}) => {
|
|||
const $user_group_error = $(user_group_selector + " .user-group-status");
|
||||
$user_group_error.show();
|
||||
ui_report.error = (error_msg, error_obj, ele) => {
|
||||
const xhr = {
|
||||
responseText: '{"msg":"fake-msg"}',
|
||||
};
|
||||
assert.equal(error_msg, "translated HTML: Failed");
|
||||
assert.deepEqual(error_obj, xhr);
|
||||
assert.deepEqual(error_obj, {responseJson: {msg: "fake-msg"}});
|
||||
assert.equal(ele, $user_group_error);
|
||||
};
|
||||
const xhr = {
|
||||
responseText: '{"msg":"fake-msg", "attrib":"val"}',
|
||||
};
|
||||
opts.error(xhr);
|
||||
opts.error({responseJson: {msg: "fake-msg"}});
|
||||
|
||||
assert.ok($user_group_error.visible());
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue