mirror of https://github.com/zulip/zulip.git
compose: Move uppy to upload module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
abece73c5a
commit
fb19476c4e
|
@ -46,12 +46,6 @@ import * as zcommand from "./zcommand";
|
|||
|
||||
// Docs: https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
|
||||
|
||||
let uppy;
|
||||
|
||||
export function get_compose_upload_object() {
|
||||
return uppy;
|
||||
}
|
||||
|
||||
function get_jitsi_server_url() {
|
||||
return page_params.realm_jitsi_server_url ?? page_params.server_jitsi_server_url;
|
||||
}
|
||||
|
@ -130,7 +124,7 @@ export function clear_preview_area() {
|
|||
|
||||
export function abort_xhr() {
|
||||
$("#compose-send-button").prop("disabled", false);
|
||||
uppy.cancelAll();
|
||||
upload.compose_upload_object.cancelAll();
|
||||
}
|
||||
|
||||
export const zoom_token_callbacks = new Map();
|
||||
|
@ -767,10 +761,6 @@ export function initialize() {
|
|||
compose_ui.make_compose_box_original_size();
|
||||
});
|
||||
|
||||
uppy = upload.setup_upload({
|
||||
mode: "compose",
|
||||
});
|
||||
|
||||
$("#compose-textarea").on("focus", () => {
|
||||
compose_recipient.update_placeholder_text();
|
||||
});
|
||||
|
|
|
@ -649,6 +649,7 @@ export function initialize_everything() {
|
|||
on_enter_send: compose.finish,
|
||||
});
|
||||
compose_textarea.initialize();
|
||||
upload.initialize();
|
||||
search.initialize({
|
||||
on_narrow_search: narrow.activate,
|
||||
});
|
||||
|
@ -694,7 +695,6 @@ export function initialize_everything() {
|
|||
hotspots.initialize();
|
||||
typing.initialize();
|
||||
starred_messages_ui.initialize();
|
||||
upload.initialize();
|
||||
user_status_ui.initialize();
|
||||
fenced_code.initialize(generated_pygments_data);
|
||||
message_edit_history.initialize();
|
||||
|
|
|
@ -4,7 +4,6 @@ import $ from "jquery";
|
|||
|
||||
import render_upload_banner from "../templates/compose_banner/upload_banner.hbs";
|
||||
|
||||
import * as compose from "./compose";
|
||||
import * as compose_actions from "./compose_actions";
|
||||
import * as compose_banner from "./compose_banner";
|
||||
import * as compose_state from "./compose_state";
|
||||
|
@ -15,6 +14,9 @@ import * as message_edit from "./message_edit";
|
|||
import * as message_lists from "./message_lists";
|
||||
import {page_params} from "./page_params";
|
||||
import * as rows from "./rows";
|
||||
|
||||
export let compose_upload_object;
|
||||
|
||||
// Show the upload button only if the browser supports it.
|
||||
export function feature_check($upload_button) {
|
||||
if (window.XMLHttpRequest && new window.XMLHttpRequest().upload) {
|
||||
|
@ -417,6 +419,10 @@ export function setup_upload(config) {
|
|||
}
|
||||
|
||||
export function initialize() {
|
||||
compose_upload_object = setup_upload({
|
||||
mode: "compose",
|
||||
});
|
||||
|
||||
// Allow the main panel to receive drag/drop events.
|
||||
$(".app-main").on("dragover", (event) => event.preventDefault());
|
||||
|
||||
|
@ -428,7 +434,6 @@ export function initialize() {
|
|||
|
||||
const $drag_drop_edit_containers = $(".message_edit_form form");
|
||||
const files = event.originalEvent.dataTransfer.files;
|
||||
const compose_upload_object = compose.get_compose_upload_object();
|
||||
const $last_drag_drop_edit_container = $drag_drop_edit_containers.last();
|
||||
|
||||
// Handlers registered on individual inputs will ensure that
|
||||
|
|
|
@ -122,7 +122,6 @@ function test_ui(label, f) {
|
|||
function initialize_handlers({override}) {
|
||||
override(page_params, "realm_available_video_chat_providers", {disabled: {id: 0}});
|
||||
override(page_params, "realm_video_chat_provider", 0);
|
||||
override(upload, "setup_upload", () => undefined);
|
||||
override(upload, "feature_check", () => {});
|
||||
override(resize, "watch_manual_resize", () => {});
|
||||
compose.initialize();
|
||||
|
@ -439,23 +438,17 @@ test_ui("initialize", ({override}) => {
|
|||
|
||||
page_params.max_file_upload_size_mib = 512;
|
||||
|
||||
let setup_upload_called = false;
|
||||
let uppy_cancel_all_called = false;
|
||||
override(upload, "setup_upload", (config) => {
|
||||
assert.equal(config.mode, "compose");
|
||||
setup_upload_called = true;
|
||||
return {
|
||||
cancelAll() {
|
||||
uppy_cancel_all_called = true;
|
||||
},
|
||||
};
|
||||
override(upload, "compose_upload_object", {
|
||||
cancelAll() {
|
||||
uppy_cancel_all_called = true;
|
||||
},
|
||||
});
|
||||
override(upload, "feature_check", () => {});
|
||||
|
||||
compose.initialize();
|
||||
|
||||
assert.ok(resize_watch_manual_resize_checked);
|
||||
assert.ok(setup_upload_called);
|
||||
|
||||
function set_up_compose_start_mock(expected_opts) {
|
||||
compose_actions_start_checked = false;
|
||||
|
|
|
@ -69,7 +69,6 @@ function test(label, f) {
|
|||
test("videos", ({override}) => {
|
||||
page_params.realm_video_chat_provider = realm_available_video_chat_providers.disabled.id;
|
||||
|
||||
override(upload, "setup_upload", () => {});
|
||||
override(upload, "feature_check", () => {});
|
||||
|
||||
stub_out_video_calls();
|
||||
|
@ -247,7 +246,6 @@ test("videos", ({override}) => {
|
|||
});
|
||||
|
||||
test("test_video_chat_button_toggle disabled", ({override}) => {
|
||||
override(upload, "setup_upload", () => {});
|
||||
override(upload, "feature_check", () => {});
|
||||
|
||||
page_params.realm_video_chat_provider = realm_available_video_chat_providers.disabled.id;
|
||||
|
@ -256,7 +254,6 @@ test("test_video_chat_button_toggle disabled", ({override}) => {
|
|||
});
|
||||
|
||||
test("test_video_chat_button_toggle no url", ({override}) => {
|
||||
override(upload, "setup_upload", () => {});
|
||||
override(upload, "feature_check", () => {});
|
||||
|
||||
page_params.realm_video_chat_provider = realm_available_video_chat_providers.jitsi_meet.id;
|
||||
|
@ -266,7 +263,6 @@ test("test_video_chat_button_toggle no url", ({override}) => {
|
|||
});
|
||||
|
||||
test("test_video_chat_button_toggle enabled", ({override}) => {
|
||||
override(upload, "setup_upload", () => {});
|
||||
override(upload, "feature_check", () => {});
|
||||
|
||||
page_params.realm_video_chat_provider = realm_available_video_chat_providers.jitsi_meet.id;
|
||||
|
|
|
@ -644,7 +644,6 @@ test("main_file_drop_compose_mode", ({override, override_rewire}) => {
|
|||
removeFile() {},
|
||||
};
|
||||
};
|
||||
upload.setup_upload({mode: "compose"});
|
||||
upload.initialize();
|
||||
|
||||
let prevent_default_counter = 0;
|
||||
|
|
Loading…
Reference in New Issue