web: Move web app to ‘web’ directory.

Ever since we started bundling the app with webpack, there’s been less
and less overlap between our ‘static’ directory (files belonging to
the frontend app) and Django’s interpretation of the ‘static’
directory (files served directly to the web).

Split the app out to its own ‘web’ directory outside of ‘static’, and
remove all the custom collectstatic --ignore rules.  This makes it
much clearer what’s actually being served to the web, and what’s being
bundled by webpack.  It also shrinks the release tarball by 3%.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-02-22 14:03:47 -08:00
parent be0098146c
commit c1675913a2
866 changed files with 978 additions and 993 deletions

125
web/src/user_search.js Normal file
View File

@@ -0,0 +1,125 @@
import $ from "jquery";
import * as popovers from "./popovers";
import * as resize from "./resize";
import * as stream_popover from "./stream_popover";
export class UserSearch {
// This is mostly view code to manage the user search widget
// above the buddy list. We rely on other code to manage the
// details of populating the list when we change.
$widget = $("#user_search_section").expectOne();
$input = $(".user-list-filter").expectOne();
constructor(opts) {
this._reset_items = opts.reset_items;
this._update_list = opts.update_list;
this._on_focus = opts.on_focus;
$("#clear_search_people_button").on("click", () => this.clear_search());
$("#userlist-header").on("click", () => this.toggle_filter_displayed());
this.$input.on("input", opts.update_list);
this.$input.on("focus", (e) => this.on_focus(e));
}
input_field() {
return this.$input;
}
text() {
return this.$input.val().trim();
}
searching() {
return this.$input.is(":focus");
}
empty() {
return this.text() === "";
}
clear_search() {
if (this.empty()) {
this.close_widget();
return;
}
this.$input.val("");
this.$input.trigger("blur");
this._reset_items();
}
escape_search() {
if (this.empty()) {
this.close_widget();
return;
}
this.$input.val("");
this._update_list();
}
hide_widget() {
this.$widget.addClass("notdisplayed");
resize.resize_sidebars();
}
show_widget() {
// Hide all the popovers but not userlist sidebar
// when the user wants to search.
popovers.hide_all_except_sidebars();
this.$widget.removeClass("notdisplayed");
resize.resize_sidebars();
}
widget_shown() {
return this.$widget.hasClass("notdisplayed");
}
clear_and_hide_search() {
if (!this.empty()) {
this.$input.val("");
this._update_list();
}
this.close_widget();
}
close_widget() {
this.$input.trigger("blur");
this.hide_widget();
this._reset_items();
}
expand_column() {
const $column = this.$input.closest(".app-main [class^='column-']");
if (!$column.hasClass("expanded")) {
popovers.hide_all();
if ($column.hasClass("column-left")) {
stream_popover.show_streamlist_sidebar();
} else if ($column.hasClass("column-right")) {
popovers.show_userlist_sidebar();
}
}
}
initiate_search() {
this.expand_column();
this.show_widget();
this.$input.trigger("focus");
}
toggle_filter_displayed() {
if (this.widget_shown()) {
this.initiate_search();
} else {
this.clear_and_hide_search();
}
}
on_focus(e) {
this._on_focus();
e.stopPropagation();
}
}