mirror of https://github.com/zulip/zulip.git
js: Convert static/js/ui_report.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
76bfa78beb
commit
26710a4370
|
@ -216,7 +216,6 @@
|
|||
"typing_events": false,
|
||||
"ui": false,
|
||||
"ui_init": false,
|
||||
"ui_report": false,
|
||||
"ui_util": false,
|
||||
"unread": false,
|
||||
"unread_ops": false,
|
||||
|
|
|
@ -2,21 +2,28 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const rewiremock = require("rewiremock/node");
|
||||
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
|
||||
const ui_report = set_global("ui_report", {
|
||||
const ui_report = {
|
||||
__esModule: true,
|
||||
displayed_error: false,
|
||||
|
||||
error: () => {
|
||||
ui_report.displayed_error = true;
|
||||
},
|
||||
});
|
||||
};
|
||||
rewiremock("../../static/js/ui_report").with(ui_report);
|
||||
set_global("location", {
|
||||
protocol: "https:",
|
||||
host: "example.com",
|
||||
pathname: "/",
|
||||
});
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
const hash_util = zrequire("hash_util");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const people = zrequire("people");
|
||||
|
@ -172,3 +179,4 @@ run_test("test_search_public_streams_notice_url", () => {
|
|||
"#narrow/streams/public/sender/15-hamlet",
|
||||
);
|
||||
});
|
||||
rewiremock.disable();
|
||||
|
|
|
@ -25,7 +25,7 @@ set_global("recent_topics", {
|
|||
});
|
||||
// Still required for page_params.initial_pointer
|
||||
set_global("page_params", {});
|
||||
set_global("ui_report", {
|
||||
rewiremock("../../static/js/ui_report").with({
|
||||
hide_error: noop,
|
||||
});
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ rewiremock("../../static/js/reload_state").with({
|
|||
// we also directly write to pointer
|
||||
set_global("pointer", {});
|
||||
|
||||
set_global("ui_report", {
|
||||
rewiremock("../../static/js/ui_report").with({
|
||||
hide_error() {
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -56,6 +56,8 @@ stub_templates((name, data) => {
|
|||
const overlays = set_global("overlays", {});
|
||||
|
||||
const _ui_report = {
|
||||
__esModule: true,
|
||||
|
||||
success(msg, elem) {
|
||||
elem.val(msg);
|
||||
},
|
||||
|
@ -79,7 +81,7 @@ set_global("FormData", _FormData);
|
|||
set_global("jQuery", _jQuery);
|
||||
rewiremock("../../static/js/loading").with(_loading);
|
||||
set_global("realm_logo", _realm_logo);
|
||||
set_global("ui_report", _ui_report);
|
||||
rewiremock("../../static/js/ui_report").with(_ui_report);
|
||||
rewiremock("../../static/js/list_widget").with(_ListWidget);
|
||||
|
||||
// setup is only imported to set the
|
||||
|
|
|
@ -30,7 +30,9 @@ const user_groups = {
|
|||
add: noop,
|
||||
};
|
||||
rewiremock("../../static/js/user_groups").with(user_groups);
|
||||
const ui_report = set_global("ui_report", {});
|
||||
const ui_report = {__esModule: true};
|
||||
|
||||
rewiremock("../../static/js/ui_report").with(ui_report);
|
||||
|
||||
const page_params = set_global("page_params", {});
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ const render_uploaded_files_list = require("../templates/uploaded_files_list.hbs
|
|||
const channel = require("./channel");
|
||||
const ListWidget = require("./list_widget");
|
||||
const loading = require("./loading");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
let attachments;
|
||||
let upload_space_used;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// execution.
|
||||
|
||||
const blueslip_stacktrace = require("./blueslip_stacktrace");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
if (Error.stackTraceLimit !== undefined) {
|
||||
Error.stackTraceLimit = 100000;
|
||||
|
|
|
@ -26,7 +26,6 @@ import "../narrow";
|
|||
import "../reload";
|
||||
import "../compose_actions";
|
||||
import "../subs";
|
||||
import "../ui_report";
|
||||
import "../message_scroll";
|
||||
import "../info_overlay";
|
||||
import "../ui";
|
||||
|
|
|
@ -26,6 +26,7 @@ import * as settings_config from "./settings_config";
|
|||
import * as stream_data from "./stream_data";
|
||||
import * as stream_edit from "./stream_edit";
|
||||
import * as transmit from "./transmit";
|
||||
import * as ui_report from "./ui_report";
|
||||
import * as upload from "./upload";
|
||||
import * as util from "./util";
|
||||
import * as zcommand from "./zcommand";
|
||||
|
|
|
@ -87,7 +87,6 @@ declare let timerender: any;
|
|||
declare let typeahead_helper: any;
|
||||
declare let typing_events: any;
|
||||
declare let ui: any;
|
||||
declare let ui_report: any;
|
||||
declare let ui_util: any;
|
||||
declare let unread: any;
|
||||
declare let unread_ops: any;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const stream_data = require("./stream_data");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
exports.get_hash_category = function (hash) {
|
||||
// given "#streams/subscribed", returns "streams"
|
||||
|
|
|
@ -9,6 +9,7 @@ import render_settings_dev_env_email_access from "../templates/settings/dev_env_
|
|||
import * as channel from "./channel";
|
||||
import * as common from "./common";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as ui_report from "./ui_report";
|
||||
|
||||
function reset_error_messages() {
|
||||
$("#invite_status").hide().text("").removeClass(common.status_classes);
|
||||
|
|
|
@ -13,6 +13,7 @@ import * as message_viewport from "./message_viewport";
|
|||
import * as resize from "./resize";
|
||||
import * as rows from "./rows";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as ui_report from "./ui_report";
|
||||
import * as upload from "./upload";
|
||||
|
||||
const currently_editing_messages = new Map();
|
||||
|
|
|
@ -2,6 +2,7 @@ import render_message_edit_history from "../templates/message_edit_history.hbs";
|
|||
|
||||
import * as channel from "./channel";
|
||||
import * as people from "./people";
|
||||
import * as ui_report from "./ui_report";
|
||||
|
||||
const {format, isSameDay} = require("date-fns");
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ const huddle_data = require("./huddle_data");
|
|||
const people = require("./people");
|
||||
const pm_list = require("./pm_list");
|
||||
const stream_data = require("./stream_data");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
const consts = {
|
||||
backfill_idle_time: 10 * 1000,
|
||||
|
|
|
@ -3,6 +3,7 @@ import * as compose_state from "./compose_state";
|
|||
import {localstorage} from "./localstorage";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as reload_state from "./reload_state";
|
||||
import * as ui_report from "./ui_report";
|
||||
import * as util from "./util";
|
||||
|
||||
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
|
||||
|
|
|
@ -8,6 +8,7 @@ const reload = require("./reload");
|
|||
const reload_state = require("./reload_state");
|
||||
const sent_messages = require("./sent_messages");
|
||||
const server_events_dispatch = require("./server_events_dispatch");
|
||||
const ui_report = require("./ui_report");
|
||||
// Docs: https://zulip.readthedocs.io/en/latest/subsystems/events-system.html
|
||||
|
||||
let waiting_on_homeview_load = true;
|
||||
|
|
|
@ -12,6 +12,7 @@ const people = require("./people");
|
|||
const pill_typeahead = require("./pill_typeahead");
|
||||
const settings_ui = require("./settings_ui");
|
||||
const setup = require("./setup");
|
||||
const ui_report = require("./ui_report");
|
||||
const user_pill = require("./user_pill");
|
||||
|
||||
exports.update_email = function (new_email) {
|
||||
|
|
|
@ -5,6 +5,7 @@ const emojisets = require("./emojisets");
|
|||
const loading = require("./loading");
|
||||
const settings_config = require("./settings_config");
|
||||
const settings_ui = require("./settings_ui");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
const meta = {
|
||||
loaded: false,
|
||||
|
|
|
@ -8,6 +8,7 @@ const channel = require("./channel");
|
|||
const ListWidget = require("./list_widget");
|
||||
const loading = require("./loading");
|
||||
const people = require("./people");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
const meta = {
|
||||
loaded: false,
|
||||
|
|
|
@ -6,6 +6,7 @@ const channel = require("./channel");
|
|||
const ListWidget = require("./list_widget");
|
||||
const loading = require("./loading");
|
||||
const people = require("./people");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
const meta = {
|
||||
loaded: false,
|
||||
|
|
|
@ -8,6 +8,7 @@ const ListWidget = require("./list_widget");
|
|||
const loading = require("./loading");
|
||||
const people = require("./people");
|
||||
const settings_config = require("./settings_config");
|
||||
const ui_report = require("./ui_report");
|
||||
const util = require("./util");
|
||||
|
||||
const meta = {
|
||||
|
|
|
@ -5,6 +5,7 @@ const render_admin_filter_list = require("../templates/admin_filter_list.hbs");
|
|||
const channel = require("./channel");
|
||||
const ListWidget = require("./list_widget");
|
||||
const loading = require("./loading");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
const meta = {
|
||||
loaded: false,
|
||||
|
|
|
@ -9,6 +9,7 @@ const loading = require("./loading");
|
|||
const settings_config = require("./settings_config");
|
||||
const settings_ui = require("./settings_ui");
|
||||
const stream_data = require("./stream_data");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
const meta = {
|
||||
loaded: false,
|
||||
|
|
|
@ -6,6 +6,7 @@ const channel = require("./channel");
|
|||
const ListWidget = require("./list_widget");
|
||||
const loading = require("./loading");
|
||||
const stream_data = require("./stream_data");
|
||||
const ui_report = require("./ui_report");
|
||||
|
||||
const meta = {
|
||||
loaded: false,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as loading from "./loading";
|
||||
import * as ui_report from "./ui_report";
|
||||
|
||||
export function display_checkmark($elem) {
|
||||
const check_mark = document.createElement("img");
|
||||
|
|
|
@ -8,6 +8,7 @@ const render_confirm_delete_user = require("../templates/confirm_delete_user.hbs
|
|||
const channel = require("./channel");
|
||||
const people = require("./people");
|
||||
const pill_typeahead = require("./pill_typeahead");
|
||||
const ui_report = require("./ui_report");
|
||||
const user_groups = require("./user_groups");
|
||||
const user_pill = require("./user_pill");
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ const people = require("./people");
|
|||
const settings_config = require("./settings_config");
|
||||
const settings_data = require("./settings_data");
|
||||
const settings_ui = require("./settings_ui");
|
||||
const ui_report = require("./ui_report");
|
||||
const user_pill = require("./user_pill");
|
||||
|
||||
const section = {
|
||||
|
|
|
@ -7,6 +7,7 @@ import * as loading from "./loading";
|
|||
import * as peer_data from "./peer_data";
|
||||
import * as people from "./people";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as ui_report from "./ui_report";
|
||||
|
||||
let created_stream;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import * as stream_color from "./stream_color";
|
|||
import * as stream_data from "./stream_data";
|
||||
import * as stream_pill from "./stream_pill";
|
||||
import * as stream_ui_updates from "./stream_ui_updates";
|
||||
import * as ui_report from "./ui_report";
|
||||
import * as user_pill from "./user_pill";
|
||||
import * as util from "./util";
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ const stream_data = require("./stream_data");
|
|||
const stream_edit = require("./stream_edit");
|
||||
const stream_muting = require("./stream_muting");
|
||||
const stream_ui_updates = require("./stream_ui_updates");
|
||||
const ui_report = require("./ui_report");
|
||||
const util = require("./util");
|
||||
|
||||
exports.show_subs_pane = {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
"use strict";
|
||||
import _ from "lodash";
|
||||
|
||||
const _ = require("lodash");
|
||||
import * as common from "./common";
|
||||
|
||||
const common = require("./common");
|
||||
/* Arguments used in the report_* functions are,
|
||||
response- response that we want to display
|
||||
status_box- element being used to display the response
|
||||
cls- class that we want to add/remove to/from the status_box
|
||||
*/
|
||||
|
||||
exports.message = function (response, status_box, cls, remove_after) {
|
||||
export function message(response, status_box, cls, remove_after) {
|
||||
if (cls === undefined) {
|
||||
cls = "alert";
|
||||
}
|
||||
|
@ -28,9 +27,9 @@ exports.message = function (response, status_box, cls, remove_after) {
|
|||
}, remove_after);
|
||||
}
|
||||
status_box.addClass("show");
|
||||
};
|
||||
}
|
||||
|
||||
exports.error = function (response, xhr, status_box, remove_after) {
|
||||
export function error(response, xhr, status_box, remove_after) {
|
||||
if (xhr && xhr.status.toString().charAt(0) === "4") {
|
||||
// Only display the error response for 4XX, where we've crafted
|
||||
// a nice response.
|
||||
|
@ -42,27 +41,27 @@ exports.error = function (response, xhr, status_box, remove_after) {
|
|||
}
|
||||
}
|
||||
|
||||
exports.message(response, status_box, "alert-error", remove_after);
|
||||
};
|
||||
message(response, status_box, "alert-error", remove_after);
|
||||
}
|
||||
|
||||
exports.client_error = function (response, status_box, remove_after) {
|
||||
exports.message(response, status_box, "alert-error", remove_after);
|
||||
};
|
||||
export function client_error(response, status_box, remove_after) {
|
||||
message(response, status_box, "alert-error", remove_after);
|
||||
}
|
||||
|
||||
exports.success = function (response, status_box, remove_after) {
|
||||
exports.message(response, status_box, "alert-success", remove_after);
|
||||
};
|
||||
export function success(response, status_box, remove_after) {
|
||||
message(response, status_box, "alert-success", remove_after);
|
||||
}
|
||||
|
||||
exports.generic_embed_error = function (error) {
|
||||
export function generic_embed_error(error) {
|
||||
const $alert = $("<div class='alert home-error-bar'></div>");
|
||||
const $exit = "<div class='exit'></div>";
|
||||
|
||||
$(".alert-box").append(
|
||||
$alert.html($exit + "<div class='content'>" + error + "</div>").addClass("show"),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
exports.generic_row_button_error = function (xhr, btn) {
|
||||
export function generic_row_button_error(xhr, btn) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
btn.closest("td").html(
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg),
|
||||
|
@ -70,17 +69,15 @@ exports.generic_row_button_error = function (xhr, btn) {
|
|||
} else {
|
||||
btn.text(i18n.t("Failed!"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.hide_error = function ($target) {
|
||||
export function hide_error($target) {
|
||||
$target.addClass("fade-out");
|
||||
setTimeout(() => {
|
||||
$target.removeClass("show fade-out");
|
||||
}, 300);
|
||||
};
|
||||
}
|
||||
|
||||
exports.show_error = function ($target) {
|
||||
export function show_error($target) {
|
||||
$target.addClass("show");
|
||||
};
|
||||
|
||||
window.ui_report = exports;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue