Commit Graph

3776 Commits

Author SHA1 Message Date
evykassirer a55979ebf8 typeahead: Fix buggy advanceKeyCodes code.
The `advanceKeyCodes` option was introduced in #10092.
It included a buggy check for `$.inArray` that returned
a falsey value only when the keycode was the first
element of `advanceKeyCodes`.

Because the only instance of `advanceKeyCodes` right now
is for search and contains only one element, this change
is functionally equivalent.
2024-03-11 09:56:18 -07:00
evykassirer 99c119b01b typeahead: Add missing option to lookup call. 2024-03-11 09:56:18 -07:00
evykassirer 593784b35f typeahead: Remove unused on_move option. 2024-03-11 09:56:18 -07:00
evykassirer aa4e92ee18 typeahead: Stop using html() to set value from updater().
I confirmed that updater() only returns a string or undefined.

composebox_typeahead.js

- compsebox calls `content_typeahead_selected` which returns the composebox
  text content
- stream and PM: implicitly returns undefined

pill_typeahead.js

- implicitly returns undefined

search.js

- narrow_or_search_for_term — returns `get_search_bar_text` or empty string

custom_profile_fields.js, settings_playground.js

- no updater function

If no updater function is provided, then updater returns the
value passed to it, which is
`this.$menu.find(".active").data("typeahead-value")`, which is a string.
2024-03-11 09:56:18 -07:00
evykassirer 30ecf6fafd typeahead: Don't call html with a jquery object.
This is helpful beyond appeasing the linter, because TypeScript only
[permits](https://unpkg.com/browse/@types/jquery@3.5.29/JQuery.d.ts#L5287)
`.html(…)` to accept a `string` or `HTMLElement` argument (or
function returning those), not JQuery. The behavior with a JQuery
argument is also [undocumented](https://api.jquery.com/html/#html2).
2024-03-11 09:56:18 -07:00
evykassirer 2140138f5e typeahead: Confirm that highlighter text is safe html.
All existing typeaheads have values for highlighter that are one
of the following:

* render_search_list_item (a handlebars render function)
* render_typeahead_item which calls a handlebars render function
* another function in typeahead_helper which eventually calls
  typeahead_helper
2024-03-11 09:56:18 -07:00
evykassirer 7219e3835d typeahead: Confirm that header text is safe html.
All current definitions of header(), which is renamed to
header_text() in this commit:

composebox_typeahead.js
- `get_header_html` uses `_.escape`
- `render_topic_typeahead_hint` — is a handlebars function
- third typeahead doesn’t have a header function

custom_profile_fields.js, pill_typeahead.js, search.js,
and settings_playground.js have typeaheads, but none of them
have header functions.
2024-03-11 09:56:18 -07:00
evykassirer 135395e8ce typeahead: Remove unused header_html option. 2024-03-11 09:56:18 -07:00
evykassirer 60018dfd12 typeahead: Use text() instead of html() in set_value.
This particular codepath is never reached right now,
because set_value is only called when `naturalSearch`
is `true`, and the only instance of `naturalSearch`
isn't for a `contenteditable` field.

But we don't need to use `html()` here because it's
displaying a plain string typeahead option.
2024-03-11 09:56:18 -07:00
evykassirer 099810e80f typeahead: Import jquery instead of passing it to a wrapper function. 2024-03-11 09:56:18 -07:00
evykassirer 827b42dd9f typeahead: Replace substring with slice.
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-slice.md
2024-03-11 09:56:18 -07:00
evykassirer d131f4119f typeahead: Remove unused `hideOnEmpty` option. 2024-03-11 09:56:18 -07:00
evykassirer dc4244b9d8 typeahead: Rename e to event for legibility. 2024-03-11 09:56:18 -07:00
evykassirer 6d30e3e01c typeahead: Stop using deprecated window.event.
See https://developer.mozilla.org/en-US/docs/Web/API/Window/event
for more about this.
2024-03-11 09:56:18 -07:00
evykassirer 8986846436 typeahead: Remove unnecessary that = this.
This isn't needed with arrow functions.
2024-03-11 09:56:18 -07:00
evykassirer 331efb0def typeahead: Refactor to avoid no-case-declarations issue. 2024-03-11 09:56:18 -07:00
evykassirer e12543f957 typeahead: Use const instead of let when not reassigned. 2024-03-11 09:56:18 -07:00
evykassirer 0a321f5e16 typeahead: Fix no-jquery/variable-pattern. 2024-03-11 09:56:18 -07:00
evykassirer 40b4db3323 typeahead: Refactor switch statements to avoid fallthrough. 2024-03-11 09:56:18 -07:00
evykassirer ff1f62bc56 typeahead: Use ?? instead of ||. 2024-03-11 09:56:18 -07:00
evykassirer 64b262d514 typeahead: Replace empty backup functions with inline functions. 2024-03-11 09:56:18 -07:00
evykassirer bb68dde1da typeahead: Use `startsWith` instead of a falsey index check. 2024-03-11 09:56:18 -07:00
evykassirer b034875216 typeahead: Replace ~ operator with includes().
Before ES2016, `indexOf` and jQuery's `inArray`
were used more often. They return -1 for a missing
element, and 0 is the only integer that’s falsy, so
-1 is the only integer whose bitwise complement is
falsy. Using bitwise not (~) like this is no longer
common practice and is a lot more confusing to read.
Now that we have `includes` we can use that instead.
2024-03-11 09:56:18 -07:00
evykassirer 2085d90736 typeahead: Change unused expression to just function calls. 2024-03-11 09:56:18 -07:00
evykassirer 624a879b4e typeahead: Remove unused variables. 2024-03-11 09:56:18 -07:00
evykassirer bcdde201ec typeahead: Use !== instead of !=. 2024-03-11 09:56:18 -07:00
evykassirer 7ccb833b35 typeahead: Run prettier for automatic format cleanup. 2024-03-11 09:56:18 -07:00
evykassirer 99ee72860e typeahead: Run eslint for automatic format cleanup. 2024-03-11 09:56:18 -07:00
sujal 29ca4ba662 stream_settings: Convert name to pills.
Convert anchor tag to pills containing an image/avatar
and username within both existing and new stream
subscriber member lists and group member lists
using the new user_display_only_pill.hbs template.
If user has long username that breaks the UI,
overflow is handled with ellipsis.
add a context class (panel_subscriber_member_list)
to add 'padding 5px'to 'pill_value' for stream
subscriber member list and group member list.

To retrieve  an avatar of a user add a
'img_src: people.small_avatar_url_for_person(user/person)'
field in 'stream_editsubscriber.js', 'user_group_edit_members.js',
'stream_create_subscribers.js' and 'user_group_create_members.js'.

Fixes: #25724.
2024-03-08 17:33:14 -08:00
N-Shar-ma 90cf911e89 typeahead: Update activity score computation algorithm for streams.
Earlier, streams were prioritised like this: pinned streams > subscribed
streams > other streams, with message volume serving as the tie breaker.

Now we prioritise them like: stream being composed to > pinned unmuted
streams > unpinned unmuted streams > pinned muted streams > unpinned
muted streams > unsubscribed streams, with the same tie breaker.

Fixes: #20618.
2024-03-08 16:11:17 -08:00
Temidayo32 11e498f937 resize_handler: Convert module to Typescript. 2024-03-08 10:49:52 -08:00
Lauryn Menard 4d470a52f8 remote-support: Highlight if audit log data is stale or current.
Includes has_stale_audit_log boolean in the remote support view
data so that we can style the last audit log data for the remote
server to visually highlight if it is stale or current.
2024-03-08 09:40:43 -08:00
Lauryn Menard c9caad20d0 support: Have distinct labels for remote vs Cloud support views. 2024-03-08 09:40:43 -08:00
Lauryn Menard 3fe15e048e remote-support: Make approve sponsorship button stand out more.
Adds some color to the approve sponsorship button so that it is
more visible in the support sponsorship forms.
2024-03-08 09:40:43 -08:00
Lauryn Menard b421f3c7ca remote-support: Add class to form for removing a CustomerPlanOffer.
Adds a class to the form for removing a configured CustomerPlanOffer
so that we can add some margin between the form and the information
about the plan offer.
2024-03-08 09:40:43 -08:00
Alya Abbott 736070ca2e portico: Align plans on /for/education with /plans. 2024-03-07 17:31:20 -08:00
nimishmedatwal 8e0518d777 user_profile: Navigate tabs by arrow keys.
Left/right keys arrows in User Profile now navigates
between tabs when it's first opened.
Fixes #28615
2024-03-07 16:48:04 -08:00
Alya Abbott e4cf5ba0c5 bookends: Add periods to stream status bookends.
Also change "deactivated"->"archived" for consistency.
2024-03-07 16:16:02 -08:00
Temidayo32 42dd55df42 condense: Convert module to Typescript. 2024-03-07 16:15:30 -08:00
evykassirer c0bce2c4bf state_data: Fix alphabetical sorting. 2024-03-07 13:25:20 -08:00
evykassirer 3622bff379 activity_ui: Convert module to typescript. 2024-03-07 12:46:37 -08:00
evykassirer c78de3cbc1 state_data: Add realm properties. 2024-03-07 12:46:37 -08:00
Lauryn Menard f3906f4a2f remote-support: Add ability to deactivate and reactivate remote servers. 2024-03-07 11:51:00 -08:00
evykassirer 33484e7ac3 people: Cache results of remove_diacritics. 2024-03-07 11:46:54 -08:00
evykassirer 1db2d0fd0f people: Move comments above fields. 2024-03-07 11:46:54 -08:00
Varun Singh 1fb03a27d8 compose_fade: Convert module to TypeScript. 2024-03-06 14:47:47 -08:00
Varun Singh d60848bb81 compose_fade: Refactor 'set_focused_recipient' function.
Previously we  declared the 'focused_recipient' object
with an initial field of 'msg_type' and progressively added
fields by mutating the object(depending on the 'msg_type' ie. 'stream'
or 'private'). This was not TypeScript friendly and the compiler threw.

Now, we first fetch those fields and then create the 'focused_recipient'
object depending on the value of 'msg_type' field.
2024-03-06 14:47:47 -08:00
Varun Singh c67b38fa7d message_viewport: Consistently use 'row_to_output' for callback.
This callback(initially named 'row_to_id') is part of two different
code paths.For one it refers to 'get_row' function local to
'visible_groups' and for other it refers to 'row_to_id' function
local to 'visible_messages'(same namings cause a confusion and is
also inconsistent).

Here I have renamed the callback to 'row_to_output', this is
more explanatory and consistent with name '_divisible_divs' uses
for the same callback.
2024-03-06 14:47:47 -08:00
Varun Singh 99ea6ae3fc rows: Fix type of 'message_group'. 2024-03-06 14:47:47 -08:00
Varun Singh ead68e731b compose_fade: Fix argument to be a jQuery object. 2024-03-06 14:47:47 -08:00
Tim Abbott 242c5cbb1d condense: Pass message objects to collapse functions.
This creates a much cleaner API and types for these functions. Since
the callers already had the message objects, this avoids extra work
both in the most callers and in these functions.

We also loop through all_rendered_message_lists rather than hardcoding
logic for message_lists.home.
2024-03-06 14:40:47 -08:00
Sayam Samal 70013d0f28 navbar: Add navigate to home view tooltip to the organization logo.
The organization logo in the upper left navigates to the user's home
view. We add a tooltip to make this easier to discover.

We show `Esc` as the keyboard shortcut here, unless the user has
disabled it, in which case we show the alt shortcut `Ctrl` + `[`.

Fixes #29185.
2024-03-06 13:58:36 -08:00
afeefuddin 5e18bd762f left_sidebar_navigation_area: Convert module to TypeScript. 2024-03-06 13:57:33 -08:00
Karl Stolley b20beda905 emoji_picker: Express colors as CSS variables.
This also adds a previously missing dark-mode background color for
reacted emoji's :focus state in the picker.
2024-03-05 14:58:58 -08:00
Karl Stolley 11fcd4091c emoji_picker: Reorder CSS to match template structure. 2024-03-05 14:58:58 -08:00
Karl Stolley e22666f116 emoji_picker: Remove selectors not used with Tippy. 2024-03-05 14:58:58 -08:00
Sayam Samal a60e3d93e9 compose: Fix topics required banner closing on enter to send.
We were updating the compose banners on every `keyup` event on the
topic input. Since, `keyup` also gets triggered for the modifier and
non-printing keys such as "Enter", this lead to banner for topic
required being closed via the `check_posting_policy_for_compose_box`
when pressing "Enter" to send a message with no topic.

This bug was probably introduced in 5c993f0, which moved additional
logic into `update_on_recipient_change`.

To solve this issue, we use the `input` event instead of the `keyup`
event to update the compose banners only when the value inside the
input element changes.

This change also prevents the the compose banner from being closed
when we only press modifier keys - such as Shift.
2024-03-05 14:57:02 -08:00
Karl Stolley a5a6afb0ab portico: Remove All plans tab at mobile scale. 2024-03-05 14:55:43 -08:00
evykassirer 0062d3f999 reactions: Deduplicate shared code.
Creates a function for code shared by update_user_fields
and make_clean_reaction.
2024-03-05 14:54:45 -08:00
evykassirer 2de1486719 reactions: Send full message object to update_ui_and_send_reaction_ajax. 2024-03-05 14:54:45 -08:00
evykassirer 3d854771a2 reactions: Make count non-optional on ReactionUserIdAndCount. 2024-03-05 14:54:45 -08:00
Lauryn Menard bd1450f7b0 markdown-css: Wrap longer code elements in documentation.
Add a word-wrap rule so that longer code elements, such as example
URLs or long return value names in the API documentation, do not
overflow out of the view in narrowed browsers or mobile views.
2024-03-05 12:23:16 -08:00
Mateusz Mandera 898e47fbdd config_error: Change the look of the page.
Replaces the green theme with the old Zulip octopus with a plain, white
page.
2024-03-05 11:53:51 -08:00
Mateusz Mandera 1ede8da46c events: Change format of authentication_methods realm_update_dict event.
Makes the event in line with state_data.realm_authentication_methods.
2024-03-05 11:48:58 -08:00
Mateusz Mandera da9e4e6e54 backends: Implementation of restricting certain backends by plan.
Only affects zulipchat, by being based on the BILLING_ENABLED setting.

The restricted backends in this commit are
- AzureAD - restricted to Standard plan
- SAML - restricted to Plus plan, although it was already practically
  restricted due to requiring server-side configuration to be done by us

This restriction is placed upon **enabling** a backend - so
organizations that already have a backend enabled, will continue to be
able to use it. This allows us to make exceptions and enable a backend
for an org manually via the shell, and to grandfather organizations into
keeping the backend they have been relying on.
2024-03-05 11:48:58 -08:00
N-Shar-ma bff750e825 copy_and_paste: Fix formatting of code pasted from VS Code.
Since the html copied from VS Code is not structured as code but as
styled divs for each line, any code copied from it would be pasted
unformatted with blank lines between each line of code.

This has now been fixed, by detecting VS Code style code blocks by the
CSS property `white-space: pre` and pasting the text within as is, as
code.
2024-03-05 11:34:22 -08:00
evykassirer af8263fb87 people: Don't refetch user when we already have it. 2024-03-05 11:27:34 -08:00
Sahil Batra e965ed2eb8 stream_settings: Show banner on successful stream creation.
This commit adds banner which is shown on successful stream
creation which contains a link to stream narrow. This banner
makes it more clear that stream was created successfully and
also makes it easy to navigate to the new stream.

Fixes #29171.
2024-03-05 10:56:30 -08:00
Sayam Samal 24e5004a54 compose_tooltips: Rename "non-stream" to "non-specific" type/view.
We want to name types/views that are not Stream or Direct related to be
"non-specific". The previously used term "non-stream" could be confusing
since it would literally mean any type/view which is not a stream type/
view, which would encapsulate the Direct type/view also.

Thus, we finally use the following terms to describe the type of
conversation:
1. Stream type (Streams or Topics)
2. Direct type (A)
3. Non specific type (Inbox, Recent conversation, All messages)
2024-03-05 10:55:20 -08:00
Sayam Samal 1091938252 compose_tooltips: Fix compose buttons not updating for inbox view.
This commit fixes the bug, where navigating to inbox view does not
update the closed compose buttons. Due to this the tooltip over the
"Start new conversation" button also showed the wrong content.
2024-03-05 10:55:20 -08:00
Sayam Samal a0411e32b6 compose_tooltips: Fix tooltips for disabled conversation button.
In the situation where the DMs are disabled in an organization, we
disable the new conversation button. But due to this, the tooltip
hinting towards the same, was also being disabled because it was
attached to a disabled element which does not fire any events.

This commit fixes this bug, by wrapping the new conversation button
inside a div, and attaching the tooltip to this wrapper instead.
2024-03-05 10:55:20 -08:00
Sayam Samal f00d79399e compose_tooltips: Change new conversation button tooltip logic.
As reported on CZO, the new conversation button sometimes had stale
tooltip content rendered on it. In this commit, we change the logic
used to render this tooltip, to now render the tooltip content on the
fly via `instance.setContent()` which should eliminate any such bug.

Fixes #27158.
2024-03-05 10:55:20 -08:00
Aman Agrawal de61a91738 message_list: Fix delayed events finding current msg list undefined.
Events that are called after a delay can find message_lists.current
to be undefined if user has moved to non-message list view.
2024-03-05 10:54:07 -08:00
evykassirer fb7d77545f reactions: Convert module to typescript. 2024-03-04 19:07:49 -08:00
evykassirer 07671997ca reactions: Calculate vote_text before creating clean reaction.
This is essential for converting to typescript, because
we can't create half a clean reaction and then calculate
vote_text afterwards. Instead, we should calculate it
with the information we already have, and create the
clean reaction object afterwards, all at once.
2024-03-04 19:07:49 -08:00
evykassirer 9d859ddbc9 reactions: Calculate should_display_reactors without clean reactions.
When we move to typescript, we want to be able to calculate
this value *before* creating the clean reactions, so that
we can generate the clean reactions in one go instead of
having some half-created object.
2024-03-04 19:07:49 -08:00
afeefuddin 72681c2d5a hotspots: Convert module to TypeScript. 2024-03-04 18:17:34 -08:00
afeefuddin 6314139d4a zcommand: Convert module to TypeScript. 2024-03-04 18:10:38 -08:00
N-Shar-ma b4d53c7930 compose: Fix bug where inserted content would not be scrolled into view.
On chromium browsers, the scroll position is not restored when the text
in a textarea is replaced. So instead of directly replacing the text,
we call the `insert_and_scroll_into_view` function with `replace_all`
set to true.
2024-03-04 17:14:11 -08:00
N-Shar-ma ef0be22899 compose: Add parameter `replace_all` to `insert_and_scroll_into_view`.
We refactor the `insert_and_scroll_into_view` function to accept a new
parameter, `replace_all`, defaulting to false, that when set to `true`,
will replace all existing content of the textarea with the new content,
instead of inserting the new content at the current cursor position.

This is a prep commit for the next commit, which will set this new flag.
2024-03-04 17:14:11 -08:00
Aman Agrawal ad2e176625 help: Link mark as read in conversation banner to help page.
Fixes #29115
2024-03-04 16:55:59 -08:00
tnmkr 25cca93bc9 stream_settings: Show relevant streams in left panel.
We want to make the default stream listing more relevant. To do this,
we always show "All streams" tab when stream is opened from another
user's profile. From other places, we show "Subscribed" if the user
is subscribed to the stream they are trying to edit otherwise
"All streams" are shown.
2024-03-04 16:52:57 -08:00
tnmkr 9275a8ded4 group_settings: Show relevant groups in left panel.
We want to make default group listing in left panel more relevant.
Thus "All groups" are shown when group is opened from another user's
profile. From other places, "Your groups" are shown if the user is in
the group they are trying to edit otherwise "All groups" are shown.
2024-03-04 16:52:57 -08:00
tnmkr ca6e0ce8c8 user_profile: Add links to group settings.
This commit adds links to open group settings from "User groups" tab
of user profile. These links are not shown to guests as they cannot
view `#groups` urls.

Fixes #25214.
2024-03-04 16:52:57 -08:00
Prakhar Pratyush 6630981de8 inbox: Remove 'default' visibility policy indicator.
We no longer show the 'default' visibility policy in
the inbox view. 'Unmute', 'Follow', and "Mute' are
still shown.

For topics with 'default' visibility policy, it is
still possible to change the visibility policy via the
three-dot menu.

The motivation is not to have the default state so
prominently called out.
2024-03-04 14:07:59 -08:00
Anders Kaseorg aaa6f16538 web: Use Zod z.discriminatedUnion more.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-03-02 15:39:04 -05:00
Anders Kaseorg a03a26151c onboarding_steps: Depluralize OnboardingStep type name.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-03-02 15:39:04 -05:00
Anders Kaseorg f39675f061 rows: Make errors fatal in id, local_echo_id.
This lets us simplify their types and remove dead error-handling code.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-03-02 07:30:44 -08:00
Anders Kaseorg 398c63566e rows: Fix get_message_id type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-03-02 03:50:11 -05:00
Anders Kaseorg 6f50ed4ca3 user_status_ui: Fix input_field() type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-03-02 03:48:26 -05:00
Varun Singh bda6470951 user_status_ui: Convert module to TypeScript. 2024-03-01 18:02:20 -08:00
Varun Singh 063287d459 user_status_ui: Extract repetitive conditional logic into a function.
The function 'emoji_status_fields_changed' separates the conditional
logic into two parts. Now, we compare 'selected_emoji_info' and
'old_emoji_info' only when both of them have the fields necessary for
comparison.This helps with upcoming type inference and we no longer have
to write same conditional logic twice.
2024-03-01 18:02:20 -08:00
Varun Singh 70c14d0d3f user_status_ui: Refractor to satisfy '.trim()' function.
'.val()' function returns 'string','string[]' and 'number' type
whereas '.trim()' only accepts a 'string' type argument.
2024-03-01 18:02:20 -08:00
Varun Singh da18350b5b user_status_ui: Replace logical OR with null coalescing operator.
While || targets null, undefined, false, NaN, 0, -0, 0n, "",
and document.all, ??(null coalescing) specifically targets
null and undefined,which we are looking for here.
2024-03-01 18:02:20 -08:00
Varun Singh 0a7bdfaa1c user_status_ui: Add missing argument. 2024-03-01 18:02:20 -08:00
nimishmedatwal 3d30fcd10a onboarding: Improve placeholder message for dm with yourself.
Fixes #29078
2024-03-01 16:09:54 -08:00
evykassirer c60cc07605 drafts: Convert module to typescript. 2024-03-01 15:49:53 -08:00
evykassirer e26b4bbd3e drafts: Reimplement handlers for buggy drafts using zod. 2024-03-01 15:49:53 -08:00
evykassirer bd4da24086 drafts: Create formatted draft all at once.
Instead of partially creating it and then adding
more attributes, this commit creates the return
value (formatted draft) in a single assignment.
This is needed for typescript work, in an upcoming
commit.
2024-03-01 15:49:53 -08:00
evykassirer e8d5241c0d drafts: Return updatedAt timestamp in snapshot_message.
It was always being set after the fact, and it will
be easier to manage types for the conversion to
Typescript if we just set this when setting the
rest of the data for the draft message.
2024-03-01 15:49:53 -08:00