Commit Graph

53151 Commits

Author SHA1 Message Date
Karl Stolley b5bd439769 thirdparty: Use hyphen in date ranges.
While an en dash--as replaced here with a hyphen--is sounder
typographically, the other ranges in the file use a hyphen, which
is arguably also more interoperable in a plain-text file such as
this (though other en dashes live on in the file, as part of the
original licensing text).
2023-09-12 13:08:18 -07:00
Karl Stolley d870f2af24 thirdparty: Add period after Twitter, Inc.
This makes all shortened forms of "incorporated" uniform across
the file, and matches how "Twitter, Inc." is presented in the files
in question, e.g., atop `web/third/bootstrap/js/bootstrap.js`.
2023-09-12 13:08:18 -07:00
Karl Stolley 0d3f475a91 thirdparty: Uniformly present copyright years without commas.
While the spec permits forms both with and without a comma,
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#copyright-field,
this corrects a small number of licensing lines in the file to
match the comma-less form used in the majority of other lines.
2023-09-12 13:08:18 -07:00
Karl Stolley 0c9701b921 thirdparty: Update current year on Kandra copyright. 2023-09-12 13:08:18 -07:00
Karl Stolley 8c0c2c7da6 thirdparty: Add missing comma after Kandra Labs. 2023-09-12 13:08:18 -07:00
Karl Stolley 35730f0291 thirdparty: Alphabetize entries by path. 2023-09-12 13:08:18 -07:00
Anders Kaseorg 8efa418205 typed_endpoint: Add missing tuple comma for OptionalTopic aliases.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-12 11:49:11 -07:00
Anders Kaseorg 9abb850cd9 docs: Use MyST syntax for Sphinx metadata.
https://myst-parser.readthedocs.io/en/latest/faq/index.html#sphinx-specific-page-front-matter

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-12 10:34:03 -07:00
Alex Vandiver 135acfea93 nginx: Suppress proxy warnings when the proxy itself sent the request.
This is common in cases where the reverse proxy itself is making
health-check requests to the Zulip server; these requests have no
X-Forwarded-* headers, so would normally hit the error case of
"request through the proxy, but no X-Forwarded-Proto header".

Add an additional special-case for when the request's originating IP
address is resolved to be the reverse proxy itself; in these cases,
HTTP requests with no X-Forwarded-Proto are acceptable.
2023-09-12 10:10:58 -07:00
Aman Agrawal a8e1c22687 inbox: Add support for vim keys. 2023-09-12 09:20:33 -07:00
Aman Agrawal 6c179bcc48 inbox: Show focus underline for non-dm rows. 2023-09-12 09:20:33 -07:00
Aman Agrawal 58c5701e5e css: Assign a variable to focus underline color of recent view. 2023-09-12 09:20:33 -07:00
Aman Agrawal f12fe219d9 inbox: Sort pinned streams at the top. 2023-09-12 09:20:33 -07:00
Aman Agrawal 4559a9fbf3 inbox: Save collapsed state of streams in localstorage. 2023-09-12 09:20:33 -07:00
Aman Agrawal 6ef0753a51 inbox: Add new narrow. 2023-09-12 09:20:33 -07:00
Anders Kaseorg 3d7b9e622d web: Avoid several unchecked TypeScript casts.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-11 18:04:55 -07:00
Anders Kaseorg 4650b789ce browser_history: Delay user_settings.default_view evaluation.
Commit 61f7ede43c (#25759) introduced a
bug: browser_history tried to access user_settings.default_view at top
level as soon as it was imported, before
user_settings.initialize_user_settings has been called, so
browser_history.state.spectator_old_hash was always initialized to
"#undefined".

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-11 18:04:55 -07:00
Anders Kaseorg 6988622fe8 ruff: Enable B023 Function definition does not bind loop variable.
Python’s loop scoping is misdesigned, resulting in a very common
gotcha for functions that close over loop variables [1].  The general
problem is so bad that even the Go developers plan to break
compatibility in order to fix the same design mistake in their
language [2].

Enable the Ruff rule function-uses-loop-variable (B023) [3], which
conservatively prohibits functions from binding loop variables at all.

[1] https://docs.python-guide.org/writing/gotchas/#late-binding-closures
[2] https://go.dev/s/loopvar-design
[3] https://beta.ruff.rs/docs/rules/function-uses-loop-variable/

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-11 18:03:45 -07:00
Anders Kaseorg cf4791264c python: Replace functools.partial with type-safe returns.curry.partial.
The type annotation for functools.partial uses unchecked Any for all
the function parameters (both early and late).  returns.curry.partial
uses a mypy plugin to check the parameters safely.

https://returns.readthedocs.io/en/latest/pages/curry.html

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-11 18:03:45 -07:00
Alex Vandiver ccbd834a86 postgres_exporter: Rebase the per-index stats branch.
The branch from the PR is somewhat stale, and is missing important bugfixes.
2023-09-11 17:59:54 -07:00
Prakhar Pratyush 20886b80d9 topic_list: Update the order of "Followed" topics in the muted stream.
For sorting topics in the left sidebar topics list, the "Followed"
topics are treated the same as "Unmuted" topics.

In a muted stream and not zoomed state:
* followed/unmuted topics at the top.

In an unmuted stream or zoomed state in a muted stream:
* normal recency sorting

The reason is that the "Followed" topics have a tier of interest
above being unmuted, so they shouldn't lie below the "Unmuted" topics
in the list.
2023-09-11 17:55:37 -07:00
Prakhar Pratyush 5d069b7d7a topic_list: Add an icon and update the color for "Followed" topics.
This commit adds the follow icon to the right end
(before the three-dot menu icon) of the topic list item
for followed topics.

The icon replaces '@' instead of showing both the '@' and "Follow"
icons in the case of unread mentions, as users don't care if they
are following a topic if they've got unread mentions there.

In a muted stream, the text color of followed topics in the topic list
is set to be similar to that of unmuted topics.

The reason is that the followed topic has a tier of interest above
being unmuted, so it shouldn't stay faded in the topic list.
2023-09-11 17:55:35 -07:00
Prakhar Pratyush 07fd2aa344 topic_list: Add a CSS variable for the unmuted topic's color.
This commit adds the CSS variable '--color-unmuted-topic-list-item'
for the unmuted topic's color in the topic list.

The color for both the light and dark themes is defined in
'zulip.css' and used in 'left_sidebar.css'.

This approach helps to remove the use of the selector 'unmuted_topic'
only for color definition in 'dark_theme.css'.
2023-09-11 17:12:21 -07:00
Alex Vandiver 5874c6542f migrations: Remove indexes on Message without realm_id.
These indexes should no longer be necessary after the changes in the
previous commit.
2023-09-11 15:00:37 -07:00
Alex Vandiver b94402152d models: Always search Messages with a realm_id or id limit.
Unless there is a limit on `id`, always provide a `realm_id` limit as
well.  We also notate which index is expected to be used in each
query.
2023-09-11 15:00:37 -07:00
Alex Vandiver f9dd2549eb narrow: Set a realm_id limit on messages in user searches. 2023-09-11 15:00:37 -07:00
Alex Vandiver 3518d31797 migrations: Add indexes with realm_id.
This is designed to help PostgreSQL have better specificity and
locality in its indexes.  Subsequent commits will adjust the code to
make sure that we use these indexes rather than the `realm_id`-less
versions.

We do not add a `realm_id` variation to the full-text index, since
it is a GIN index; multi-column GIN indexes are not terribly
performant, require the `btree_gin` extension for `int` types (which
requires superuser privileges on PostgreSQL 12 and earlier), and
cannot be consistently added concurrently on running instances.

After all indexes have been made, we also run `CREATE STATISTICS` in
order to give PostgreSQL the opportunity to realize that recipient and
sender are highly correlated with message realm, allowing it to
estimate that `(realm_id, recipient_id)` is likely as specific as
matching a given `recipient_id`, instead of as likely as matching
`realm_id` times matching a `recipient_id`.  Finally, those statistics
must be filled by `ANALYZE zerver_message`, which is run last.
2023-09-11 15:00:37 -07:00
Alex Vandiver 067de6f948 coverage: Skip zerver.lib.migrate coverage.
It is only covered when we run migration tests, which we are not
guaranteed to always be able to do.
2023-09-11 15:00:37 -07:00
Alex Vandiver d6745209f2 django: Use .exists() instead of .count() when possible. 2023-09-11 15:00:37 -07:00
Alex Vandiver 4d72f81257 analytics: Only join through messages once.
Using `COUNT(*) FILTER (WHERE ...)` allows getting counts of different
subsets with only one giant join.  This makes the query significantly
more performant.
2023-09-11 15:00:37 -07:00
Alex Vandiver 9d3d57e786 message_send: Inline single use of filter_by_exact_message_topic.
Matching the topic exactly, as opposed to case-insensitively, is not a
common operation, and one that we want to make difficult to do
accidentally.  Inline the single use case of it.
2023-09-11 15:00:37 -07:00
Alex Vandiver 710524465a messages: Switch limits from sender__realm to realm.
We now have a `realm_id` on Message; use it, rather than having to
check the sender's realm.  This is theoretically different for
cross-realm bots, but these changes are all in tests where that does
not apply.
2023-09-11 15:00:37 -07:00
Alex Vandiver 5a0f4a1a22 messages: Limit to "id" column for max-message-id computation.
This lets PostgreSQL use an "Index Only Scan" which is slightly faster
than an "Index scan".
2023-09-11 15:00:37 -07:00
Alex Vandiver 631868a05b users: Refactor and optimize max_message_id_for_user by removing a join.
This algorithm existed in multiple places, with different queries.
Since we only access properties in the UserMessage table, we
standardize on the much simpler and faster Index Only Scan, rather
than a merge join.
2023-09-11 15:00:37 -07:00
Alex Vandiver 0c88cfca63 postgres_exporter: Build from source for per-index stats.
This builds prometheus-community/postgres_exporter#843 to track
per-index statistics.
2023-09-11 11:59:39 -07:00
Lalit Kumar Singh 5f74b9051e ts: Migrate `user_topics.js` to typescript. 2023-09-11 10:57:38 -07:00
Lalit Kumar Singh dc142ab1d1 fold_dict: Use `IterableIterator` instead of `Iterator`.
The type `Iterator` does not allow us to loop over the iterator in a `for`
loop. but `IterableIterator` does.
2023-09-11 10:57:38 -07:00
Lalit Kumar Singh d82b3625f1 user_topics: Pop `user_topics` from `page_params`.
This avoids accessing the global page_params directly.
2023-09-11 10:57:38 -07:00
Daniil Fadeev a2b4db07f6 emoji_picker: Move module event registration to initialization. 2023-09-11 10:42:18 -07:00
Tim Abbott b0007bf5ca settings: Navigate to profile to edit self in users panel.
We don't have a "Manage user" tab in your own profile, so it would
throw an exception to do the default thing here, and the mechanism for
editing your own settings should be the main "your profile" panel,
which is a bit bigger and more user-friendly.

I'm not totally convinced that the extra logic for not having a
"Manage user" tab is worth it; the alternative of figuring out a
non-confusing label would not be terrible here. But this version is
non-broken, and it'll be easy to change later if we change our mind.
2023-09-11 10:39:00 -07:00
Tim Abbott 0174902b73 user_profile: Centralize footer logic. 2023-09-11 10:39:00 -07:00
palashb01 db47f675f0 user_profile: Add tippy tooltips to edit pencil button.
This commit adds Tippy tooltips to the edit pencil button
in the user profile. Now, when a user opens another user's
profile, they will see the tooltip 'Manage user', and when
they open their own user profile, they will see the tooltip
'Edit profile'.
2023-09-11 10:39:00 -07:00
palashb01 1c049ab5f4 user_profile: Replace the id with class for pencil button.
This commit replaces the id attribute with class attribute for the
edit pencil button in user profile modal.
2023-09-11 10:39:00 -07:00
palashb01 135518435a user_profile: Align the title header of the modal and fix edit button.
This commit unsets the padding of the bot icon and, as the anchor
tag has been replaced with the i tag, we have also set the color
and pointer. This is done so that when the user hovers over the
icon, it will appear as a clickable button.
2023-09-11 10:39:00 -07:00
palashb01 f9dd2db3e4 user_profile: Move bot icon to the left of the name.
This commit moves the bot icon to the left of the name in the user
profile and adds a margin-left and margin-right to the name to ensure
there is enough space between the icon, name, and edit pencil.
2023-09-11 10:39:00 -07:00
palashb01 c6bb7b9169 user_profile: Redirect edit pencil to manage user tab.
This commit redirects the edit pencil in the user profile modal to
the 'manage user' tab whenever a user with permission to manage
other users via the user profile opens another user's profile.
However, we still want to redirect the edit pencil to
'settings/profile' if the user opens their own profile. The user
management permission is granted if the user is an admin or the
owner of the bot. However, we do not want system bots to have
access to the edit pencil or the 'manage user' tab. Therefore,
a new variable called 'can_manage_profile' has been introduced
to manage all these permissions, and the CSS has been updated
accordingly.

To redirect to the manage user tab without opening another modal,
I have extracted the toggler. This toggler will store the
component, and if the edit pencil button is clicked, we can use
the goto function to redirect to a different tab.

Changed the id names of both the edit pencil icons to explain
better of what they do.
2023-09-11 10:39:00 -07:00
palashb01 e1322faae0 user_profile: Fix the gap between labels and input.
This commit increases the gap between the labels and input/select
of the user profile manage user/bot tab for clearer visibility.
It also reduces the gap between the 'deactivate user' button and
the last input to make it look better.
2023-09-11 10:39:00 -07:00
palashb01 6323bb1e39 user_profile: Disable deactivate user button if the admin is only user.
This commit disables the "Deactivate User" button inside the
"manage user" tab in the user profile modal. Additionally, a
tooltip is applied to the button by wrapping it inside a div
with the tooltip applied.
2023-09-11 10:39:00 -07:00
palashb01 c2f878638b user_profile: Fix inconsistent height of user profile switching tabs.
This commit fixes the inconsistent height of the user profile when
switching tabs. We now have four tabs in the user profile:
"Profile," "Streams," "User Groups," and "Manage User." However,
the "Manage User" tab has footer buttons that need to remain
sticky at the bottom without changing the overall height of
the modal.

To achieve this, we wrapped the footer inside a div element and
assigned it a class called "manage-profile-tab-footer." The main
body of the user profile is given a height of 60vh. However, for
the "Manage User" tab, we decreased this height to 52vh and
allocated the remaining 8vh height to the div element to
accommodate the footer buttons. This ensures that the user
profile maintains consistent height when switching between tabs.

However, we have a 1px border in the footer, so to ensure that
the height is consistent, we reduce the height of the modal
content by 1px, making it calc(52vh - 1px).

To implement this, CSS code was added to the "popover.css" file
and accessed through the class specified in the "user_profile.js"
file.

The default padding of the buttons inside footer is 20px, but
with the above solution on large screens the buttons are not
aligned properly, so removed the padding top and bottom
and instead applied the flex box and property to align the buttons.
2023-09-11 10:39:00 -07:00
palashb01 66bf87062e settings_users: Combine "handle_human_form" and "handle_bot_form".
To remove duplicated code this commit will combine two functions.
2023-09-11 10:39:00 -07:00