Commit Graph

453 Commits

Author SHA1 Message Date
Brijmohan Siyag 4e7bf3c4fb upload: Support drag and dropping files anywhere on message viewport.
While Zulip has supported drag/drop into the compose box for some
time, if you drag/drop the file onto other parts of the message
viewport, it would just do the default browswer behavior of replacing
the Zulip app with that file opened in a new tab, which nobody wants.

The inline comments document the set of rules for how we choose
whether to drop the upload into the compose box or an edit widget, and
also how to open the compose box in different situations.

Fixes #14579.
2023-08-16 17:06:45 -07:00
Tim Abbott 0e2bce3bcb recent_topics: Move is_in_focus to UI module.
This better fits how this function is used, and cuts unnecessary
dependencies from recent_topics_util.js.
2023-08-15 18:17:02 -07:00
Joelute eb78264162 navbar_alerts: Delay showing "Complete the organization profile" banner.
Currently, we are displaying the "Complete the organization profile"
banner immediately after the organization was created. It's important to
strongly encourage orgs to configure their profile, so we should delay
showing the banner if the profile has not been configured after 15 days.
Thus also allows the users to check out Zulip and see how it works before
configuring the organization settings.

Fixes: #24122.
2023-08-15 10:46:33 -07:00
Zixuan James Li b8a770d9c6 list_widget: Pass filter_value to modifier.
The information can be useful when we want to determine if a filter
has been applied.
2023-08-15 10:21:22 -07:00
Junyao Chen 7140149373 ts: Migrate `bot_data.js` to TypeScript.
Add type annotations. Create custom types for Bot and Service.
Add zod data validation for incoming bot data from server.
Based on `zerver/openapi/zulip.yaml` description, `add` operation
(`op`) carries data that follows `Bot` structure. So taking
reference from `bot` structure, I create `ServerAddBotData` zod
schema and infer its type. Similarly, `update` operation carries
data that follows `BasicBot`, so I create `ServerUpdateBotData`.
Note that `Bot` inherits from `BasicBot`.

`zerver/openapi/zulip.yaml` describes that `services` in `BasicBot`
can be one of two objects, one with `{base_url, token, interface}`,
another with `{service_name, config_data}`. Therefore, I create
two corresponding schema and infer their types.

Fix two test cases `bot_data.test.js` and `settings_bots.test.js`
whose synthetic objects should have had followed the schema.
2023-08-14 16:06:15 -07:00
Junyao Chen c008ba1172 common: Fix parameter type of `autofocus` function.
Throughout the codebase there is currently one usage of `autofocus`
excepts in test files. The only one usage is in `signup.js` and was
supposed to pass a `JQuery` selector to `autofocus` rather than a
string. Passing a selector is more convenient in this case: The
selector accessed in `signup.js` is ready to `trigger` the `focus`
function, while getting a attirubte string from the selector and then
passing to `autofocus` and then accessing the selector by attribute
cost extra layers of work. Therefore writing this commit to simplify
the type for easy usage.

Fixes the test case(s) accordingly.
2023-08-14 16:00:20 -07:00
Julia Bichler fed866449d drafts: Add functionality to bulk delete drafts.
Fixes #19360.

Co-authored-by: Satyam Bansal <sbansal1999@gmail.com>
2023-08-11 15:54:17 -07:00
Satyam Bansal 0f0c52e096 drafts: Remove classes that had the same effect.
In commit 5edc8fc, abstract classes were added to the
drafts overlay, but the classes that were already there
were not removed. This resulted in the same styles being
applied twice.
2023-08-11 15:54:17 -07:00
Karl Stolley cd0fd49a83 copy_paste: Strip back tests to only test handler.
This gets us out of the brittle business of trying to mock a
complex event like "paste"--which mocking basically means we
are testing against the mock more than a real event.

The test name is also changed to clarify the handler being
tested.

See CZO discussion behind this change:
https://chat.zulip.org/#narrow/stream/43-automated-testing/topic/mocking.20browser.20events.3F/near/1615110
2023-08-09 15:35:14 -07:00
Hemant Umre a81715786c stream_settings: Add 'Default stream' option in edit stream UI.
This commit adds a 'Default stream for new users' checkbox in
the stream editing UI to allow admins to easily add or remove
a stream as the default stream for new users. Previously, this
functionality required navigating to separate menu.

Fixes a part of #24048.
2023-08-09 14:38:52 -07:00
evykassirer c3fe96af52 compose: Use stream id instead of stream name for composebox opts. 2023-08-07 17:08:59 -07:00
evykassirer 41b900c2c0 compose: Get stream name from id in create_message_object.
Since this is based off of the id now and doesn't try
to get a stream from a name (because stream is now
selected by a dropdown and not a free-form input field),
we can also remove the error handling for when the
stream name doesn't correspond to any streams.
2023-08-07 17:08:59 -07:00
evykassirer f190419bc9 composebox_typeahead: Get topics_seen_for stream id instead of name. 2023-08-07 17:08:59 -07:00
evykassirer d9edcba724 narrow_state: Rename stream() to stream_name() which is more accurate. 2023-08-07 17:08:59 -07:00
Sahil Batra ae72151ec1 streams: Pass stream_weekly_traffic field in stream objects.
This commit adds code to pass stream traffic data using
the "stream_weekly_traffic" field in stream objects.

We already include the traffic data in Subscription objects,
but the traffic data does not depend on the user to stream
relationship and is stream-only information, so it's better
to include it in Stream objects. We may remove the traffic
data and other stream information fields for Subscription
objects in future.

This will help clients to correctly display the stream
traffic data in case where client receives a stream
creation event and no subscription event, for an already
existing stream which the user did not have access to before.
2023-08-06 18:06:42 -07:00
Prakhar Pratyush 3d5d434e71 settings: Add a saving-saved indicator to the 'SETTINGS/TOPICS' UI.
This commit adds a 'saving...' - 'saved' indicator to the
'SETTINGS/TOPICS' UI.

This improves the UX by reflecting that the changes are saved.
2023-08-06 13:55:21 -07:00
Anders Kaseorg 63c9296d53 tests: Fix direct mutation of ES modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-08-04 18:00:38 -07:00
Anders Kaseorg 64c973d8ec namespace: Tighten override_rewire old_value check.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-08-04 18:00:38 -07:00
Anders Kaseorg 529d35c530 namespace: Clean up template_path manipulation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-08-04 14:38:37 -07:00
Karl Stolley 73fbca7ae9
tests: Correct the spelling of 'caret'. 2023-08-03 12:54:43 -05:00
Anders Kaseorg 6632eca2dc stream_data: Use yield*.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-08-02 19:01:20 -07:00
Lalit Singh 2893685890 people: Revert to using `ignore_missing` parameter.
We revert to use `ignore_missing` parameter for `maybe_get_user_by_id`
function to avoid sending unnecessary `blueslip.error()` calls to
sentry.
2023-08-02 17:25:14 -07:00
Aman Agrawal 875d564f2d stream_settings: Migrate to new DropdownWidget.
Also, remove old DropdownListWidget since it is no longer used.
2023-07-27 14:10:08 -07:00
Aman Agrawal aa8e94ca6d settings_org: Migrate dropdowns to new DropdownWidget.
This also moves [Disabled] button inside the dropdown.
2023-07-27 14:10:08 -07:00
Aman Agrawal 6efcb7a349 dropdown_widget: Refactor to use Class. 2023-07-27 14:10:08 -07:00
Ujjawal Modi fbcc3b5c84 user_groups: Rename `can_mention_group_id` parameter.
Earlier the API endpoints related to user_group accepts and returns a
field `can_mention_group_id` which represents the ID
of user_group whose members can mention the group.

This commit renames this field to `can_mention_group`.
2023-07-25 18:33:04 -07:00
Ujjawal Modi c8bcb422f5 streams: Rename `can_remove_subscribers_group_id` parameter.
Earlier the API endpoints related to streams accepts and returns a
field `can_remove_subscribers_group_id` which represents the ID
of user_group whose members can remove subscribers from stream.

This commit renames this field to `can_remove_subscribers_group`.
2023-07-25 18:33:04 -07:00
Zixuan James Li 000761ac0c realm_playgrounds: Replace url_prefix with url_template.
Dropping support for url_prefix for RealmPlayground, the server now uses
url_template instead only for playground creation, retrieval and audit
logging upon removal.

This does the necessary handling so that url_template is expanded with
the extracted code.

Fixes #25723.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-07-24 17:40:59 -07:00
lapaz 5d5e1963b9 settings: Add "Copied" tooltip in bots/streams copy feedback.
This provides a bit nicer feedback to the user that the copy worked.

Fixes #26181
2023-07-24 13:21:43 -07:00
Hardik Dharmani cd24620c4a js: Rename top_left_corner.js to left_sidebar_navigation_area.js.
This provides a much clearer and more consistent codebase name for
this part of the app.

Fixes part of #25902.
2023-07-24 13:02:28 -07:00
Lalit 4a4d23a548 realm_playground: Remove `generated_pygments_data` parameter for
initialization function.

We are already importing `generated_pygments_data.json` directly in
`realm_playground.js` so there is no need to pass it via initialization
method.
2023-07-24 12:49:53 -07:00
Lalit 8c12494c16 realm_playground: Cut dependency on `typeahead_helper.js`. 2023-07-24 12:49:53 -07:00
Anders Kaseorg 7746e11486 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-21 15:58:42 -07:00
evykassirer 0652efc473 topic generator test: Use strings for stream name instead of numbers.
This function takes the stream name (a string) and using numbers
makes it seem like it's actually using a stream id, which is
confusing. This change adjusts `stream` to always be a string.
2023-07-21 14:19:55 -07:00
evykassirer 834f759e8b message view: Don't mark message as read in mentions view. 2023-07-21 13:10:07 -07:00
Alex Vandiver ba7492a314 web: Do not assume error responses are valid, or our, JSON.
Partially fixes #24815.
2023-07-19 16:18:31 -07:00
Alex Vandiver 7efe989a72 web: Switch from JSON.parse(xhr.responseText) to xhr.responseJSON. 2023-07-19 16:18:31 -07:00
Alex Vandiver d05a1e9efa web: Remove nonsense round-trip through JSON.parse() + JSON.stringify(). 2023-07-19 16:18:31 -07:00
Alex Vandiver d05a9d4000 reactions: Do not send server error reports for duplicate requests. 2023-07-19 16:18:31 -07:00
Prakhar Pratyush 1a2831059d notifications: Enable audible notifications for the FOLLOWED topic.
This commit adds support for triggering audible desktop
notifications when:

* A message is sent to a followed topic with the global user setting
'enable_followed_topic_audible_notifications' enabled.

* A message with wildcard mentions is sent to a followed topic with
the global user setting
'enable_followed_topic_wildcard_mentions_notify' enabled.
2023-07-17 17:39:17 -07:00
Prakhar Pratyush 67d4334bf1 notifications: Enable desktop notifications for the FOLLOWED topic.
This commit adds support for triggering visual desktop
notifications when:

* A message is sent to a followed topic with the global user setting
'enable_followed_topic_desktop_notifications' enabled.

* A message with wildcard mentions is sent to a followed topic with
the global user setting
'enable_followed_topic_wildcard_mentions_notify' enabled.
2023-07-17 17:39:17 -07:00
Prakhar Pratyush 93a18b999a settings: Update SETTINGS/TOPICS panel to include followed topics.
This commit updates the existing 'Topics' settings UI
to add support for followed topics.

Changes:
- Add "Followed" as the first option in the topic status dropdowns.
- Modify the intro text.
- Replace the "Learn more." link with a question mark linking to
'/help/mute-a-topic' on the "Topic settings" heading.

The changes are visible in the development environment only.

Fixes #25918.
2023-07-17 17:39:17 -07:00
Prakhar Pratyush 08c952a2a3 user_topics: Add the missing node tests.
This commit adds the missing node tests for the case
when the visibility policy is UNMUTED.

This should have been included in c526543.
2023-07-17 17:39:17 -07:00
Prakhar Pratyush 32b201d5e0 user_topics: Rename 'muted_topics_ui' to 'user_topics_ui'.
This commit renames the file 'muted_topics_ui.js' to
'user_topics_ui.js', as we also support visibility policies
other than MUTED.
2023-07-17 17:39:17 -07:00
evykassirer d293e869bd search: Bold search operands in the first search result.
Specifically when it's the last operand of the search
filter. This makes the first line of search results
more consistent with the lines that come after.
2023-07-17 17:19:08 -07:00
evykassirer 8f5305a4ce search: Create a template for search descriptions. 2023-07-17 17:19:08 -07:00
evykassirer 6346110b56 search: Remove unused base_query variable. 2023-07-17 17:19:08 -07:00
evykassirer 7116526492 compose: Use compose_state.stream_id when name isn't needed.
This partially fixes #25742.
2023-07-17 16:30:39 -07:00
Lalit d58085dde2 list_widget: Check length of JQuery collection instead of collection
itself.

We were checking for the undefined value of `$html_item` but this
variable is always true since `$.find` never returns an undefined value
and it returns a JQuery collection instead.

So we need to check the length of that JQuery collection here to make
sure that the condition works as expected.
2023-07-17 11:31:51 -07:00
Lalit ed7588152e list_widget: Remove over defensive validation code.
After migrating to TypeScript, we don't need to manually validate the
configuration passed to the `ListWidget`, that's what typescript complier
will do for us, hence I removed `validate_opts` and `valid_filter_opts`
functions.
2023-07-17 11:31:51 -07:00
Lalit b51bdd33bb ts: Migrate `list_widget` to TypeScript. 2023-07-17 11:31:51 -07:00
Lalit b04dfd8c29 list_widget: Explicitly pass generic sort functions to the list widget.
This is a prep commit for typescript migration of this module. In this commit
I made all the users of ListWidget pass generic sort functions like 'alphabetic'
and 'numeric' explicitly to avoid type conversions which we may need when moving
to typescript, also it simplifies our `set_sorting_function` a bit more.
2023-07-17 11:31:51 -07:00
Lalit 3720fd5c76 list_widget: Make `get_item` option required and pass a default where needed.
This is a prep commit for moving towards typescript migration of this module.
We should make `get_item` required on `list_widget` because its intended to be
used with a set of keys and then hydrate the keys lazily. Also this will help
us to avoid writing messy if-conditions while filtering and sorting and make
our life much easier when we migrate to TypeScript.

I added a `default_get_item` function which is just n identity function and
also refactored some code to make use of default get item.
2023-07-17 11:31:51 -07:00
Lalit 61d4670f9a user_group_pill: Add test coverage for `append_user_group`. 2023-07-17 10:38:24 -07:00
Lalit e06726a5cf peer_data: Remove over defensive `assert_number` function.
Removes the `assert_number` over defensive function which was being used
for validating the type of `stream_id` but now that this module is
converted to TypeScript we do not need this function anymore since
typescript compiler will do the type checking for us.
2023-07-17 10:37:29 -07:00
Hemant Umre 30ab2781b1 left_sidebar: Fix exception exiting "more topics".
The `stream_list.build_stream_list()` function is responsible for
rendering the stream list in the left sidebar. Previously, it uses
`topic_list.clear()` to clear the `active_widgets` that tracks active
stream(s) in the left sidebar. This led to a bug where rendering stream
list after adding or removing a stream through `build_stream_list()`
while a stream was zoomed in ("more topics" clicked) didn't fully exit
the "more topics" view. So clicking "BACK TO STREAMS" throws an exception
with the message "Error: Unexpected number of topic lists to zoom out"
because `active_widgets`, cleared by `topic_list.clear()`, became
inaccessible.

To address this issue, instead of clearing the topics list with
`topic_list.clear()`, the code now ensures the closure of the zoomed
stream by using `topic_zoom.clear_topics()`. This change ensures a
proper exit from the "more topics" view and avoids the exception.

Fixes #25670.
2023-07-17 10:13:53 -07:00
Prakhar Pratyush 4c9d26ce17 mention: Send notifications for @topic wildcard mentions.
This commit completes the notifications part of the @topic
wildcard mention feature.

Notifications are sent to the topic participants for the
@topic wildcard mention.
2023-07-17 09:39:24 -07:00
Karl Stolley ce04c98b47 me_messages: Clean up unused .sender_name-in-status class. 2023-07-13 14:01:32 -07:00
Prakhar Pratyush 0891f9f65a mention: Determine @topic mention during message rendering.
This commit adds a boolean field `mentions_topic_wildcard`
to the `MessageRenderingResult` dataclass.

The field is set to true only if message rendering determines
the message has an actual topic wildcard mention in it (and not,
e.g., topic wildcard mention syntax inside a code block).

The rendered content for topic wildcard mention is
'<span class="topic-mention">{wildcard}</span>'.

The 'topic-mention' class is the identifier for the wildcard
mention being a topic wildcard mention.

We don't use 'data-user-id="*"' and "user-mention" class for
topic wildcard mentions and eventually plan to remove them for
stream wildcard mentions too in a separate mini-project.
2023-07-13 11:34:48 -07:00
Prakhar Pratyush 2b42df4ef1 mention: Replace 'wildcard' with 'stream_wildcard'.
This is a prep commit to replace 'wildcard' with 'stream_wildcard'.

This wasn't included in 179d5cb because we didn't decide to
use a different rendered_content for topic wildcard mention,
i.e., ''<span class="user-mention topic-mention">{wildcard}</span>'.

Our intention was not to create separate tests for both stream
and topic wildcard mentions, as they were expected to have the
same rendered content format.
2023-07-13 11:34:48 -07:00
Karl Stolley 42919ed2e1 message_avatar: Preserve clickable area from image to user name. 2023-07-13 09:02:00 -07:00
nimish c238327899 settings: Change "Display settings" to "Preferences".
This includes changing the URL to #settings/preferences, with a
transparent redirect so that existing links, like the one from Welcome
Bot, continue to work.
2023-07-12 07:09:03 -07:00
Lalit a434523d1f search: Cut dependency on `narrow.js` module. 2023-07-11 22:34:00 -07:00
Lalit 452db76b24 reactions: Cut dependency on `emoji_picker.js`. 2023-07-11 22:33:59 -07:00
Lalit 9447381d03 echo: Cut dependency on `message_events.js`. 2023-07-11 22:33:59 -07:00
Lalit 59e78f96ba
ts: Migrate people.js to TypeScript.
We use `get_by_user_id` instead of directly accessing the global dict, because
when accessing person objects directly from one of the global dicts we
need callers to check for undefined values, this can be fixed by using
`get_by_user_id` method to get person objects because that functions
makes sure to assert that we indeed have a valid user id, so it will
never return undefined values.

Co-authored-by: Zixuan James Li <p359101898@gmail.com>
2023-07-11 22:22:30 -07:00
Sahil Batra 2e4f7f6336 user_groups: Remove "@" from name of role-based system groups.
This commit removes "@" from name of role-based system groups
since we have added a restricion on having user group names
starting with "@" in the previous commit as they look odd in
mention syntax.

We also add a migration in this commit to update the name of
role-based system groups in existing realms to remove "@"
from the name. This migration also updates the names of
non-system user groups by removing the invalid prefixes
from their names and if there is a group already with that
name, we insted name the group as "group:{group_id}".

Fixes #26148.
2023-07-11 13:46:02 -07:00
Aman Agrawal 29b3769b59 stream_data: Extract function to get stream options for dropdown.
To be used by various dropdown widgets in the app.
2023-07-11 13:37:50 -07:00
Daniil Fadeev c959ac5849 upload: Simplify the query for the "send_button". 2023-07-06 17:48:22 -07:00
evykassirer cbd4aad0a5 upload: Append file markdown to textarea when placeholder is missing.
Fixes #26037.
2023-07-06 17:46:51 -07:00
nicmar-8 f688dc4c85 people: Add new function `get_realm_active_human_users`.
There was no function to retrieve users while excluding bots,
this was needed to allow for typeahead user fields that require
to exclude bots from the autocomplete suggestions.

Fixes part of #25092.
2023-07-06 16:32:08 -07:00
nicmar-8 7be72e65e5 people: Rename get_active_human_ids function for clarity.
Rename `get_active_human_ids` to `get_realm_active_human_user_ids`
to better fit naming conventions and to be more clear about the
detail that it only includes active users.

Fixes part of #25092.
2023-07-06 16:32:08 -07:00
lapaz 87932e1eef compose: Show wildcard mentions according to policy.
Users are permitted to see  wildcard mentions for all/everyone
during message composition in large streams according to
`restrict wildcard mentions` policy.
Fixes #25429
2023-07-06 16:29:37 -07:00
Ganesh Pawar fff9b334ff default_streams: Convert inline form to modal.
Fixes #20838.
2023-07-06 16:24:44 -07:00
palashb01 4ce720f0da upload: Rename the switch case of close button to hide button.
With the previous commit, we now have two buttons. One button cancels
the upload, while the other simply hides the upload banner. This
commit renames the switch case inside upload.js so that instead of
'upload_banner_close_button', it is now called
'upload_banner_hide_button', which appears to be more aligned with
the actual functionality of the icon.
2023-07-06 16:11:09 -07:00
Palash Baderia 624fea2e8e upload_banner: Add a cancel button.
This commit adds a cancel button to the upload banner, replacing
the previous close icon. Now, the cancel button is used to cancel
the upload process, while the close icon is used to remove the
upload banner without interrupting the upload.

A new case has been added to the switch statement in the 'upload.js'
file to handle the functionality of hiding the banner called
'upload_banner_hide_button'.

Replaced the functionality of the 'compose_banner_close_banner' case
inside the switch statement with a new case called
'upload_banner_cancel_button'. The cancel button is now assigned
the selector 'upload_banner_cancel_button'.

`Cancel` button is only preset for banner which tracks
progress while a file is being uploaded.

To maintain consistency with other banners, the cancel button's
dimensions and color have been adjusted to match the style of other
buttons present in different banners.

Fixes: #21156
2023-07-06 16:11:09 -07:00
Lalit 3b270ed159 popovers: Fix giphy being mocked but not used.
While running test for `popovers.js` we get warning that `giphy` is
mocked but never used.
This bug was introduced in #25676.
2023-07-06 10:34:40 -07:00
Aman Agrawal 7b6d549604 compose_pm_pill: Fix `compose_recipient` being mocked but not used.
While running test for `compose_pm_pill` we get warning that
`compose_recipient` is mocked but never used.
This bug was introduced in #26052.
2023-07-03 21:48:58 -07:00
Aman Agrawal d547b838ac theme: Change recipient bar color and theme in the same paint.
`update_recipient_bar_background_color` changes in a paint
after change in theme without using `requestAnimationFrame` to
make sure they happen in the same paint..

Replaced `setTimeout` with `requestAnimationFrame` in
`server_events_dispatch` since `requestAnimationFrame` already
ensures that they happen in the next paint, assuming that was the
intention of `setTimeout` being preset there.
2023-07-03 21:47:45 -07:00
Lalit 1c8bf4f050 people: Make `get_by_user_id` type-safe.
We should make `get_by_user_id` type-safe in the sense that it's caller
should not expect undefined values and hence it's caller should not
need to validate the user ids.

To do this I extracted a method `maybe_get_user_by_id` which is
type-unsafe version of this function which will allow undefined values
and will behave exactly the same as the previous version. So the callers
which expects the undefined values from this function should use this
new function `maybe_get_user_by_id`.

Probably about half of these callers are implicitly iterating through
all users in the people.js data set and thus by construction should
never fail, but it's simpler to just convert all existing callers than
do that audit.
2023-07-02 16:57:16 -07:00
Anders Kaseorg 407c16fc77 eslint: Expand no-unused-vars check to all function parameters.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-02 16:16:38 -07:00
Sahil Batra 632191b8c4 composebox_typeahead: Hide user groups from mention typeahead.
This commit adds code to hide the user groups which a user is
not allowed to mention from the mention typeahead.

Fixes a part of #25927.
2023-06-30 17:28:33 -07:00
Sahil Batra 767c2ebbe4 user_groups: Add can_mention_group_id field to user_group objects.
This commit adds can_mention_group_id field to user_group objects
in webapp.

Fixes a part of #25927.
2023-06-30 17:28:33 -07:00
Sahil Batra e6accb0ad9 user_groups: Add can_mention_group_id field to UserGroup objects.
This commit adds code to include can_mention_group_id field to
UserGroup objects passed with response of various endpoints
including "/register" endpoint and also in the group object
send with user group creation event.

Fixes a part of #25927.
2023-06-30 17:28:33 -07:00
evykassirer 367030ebfe search: Stop disabling and enabling the search close button.
This is logic from 10 years ago (dbc4798594)
that is no longer relevant. It seems like we used to show the
search bar open all the time and only showed the buttons when
there was focus in the search bar. Now we close the search bar
when it's not being used, and no longer need to update button
visibility or disable the search close button.
2023-06-30 12:05:30 -07:00
Karl Stolley 7f4fe7282f search: Adjust text in has: message suggestions. 2023-06-29 13:02:06 -07:00
Lauryn Menard 0d1c43d1d9 server-events: Remove unused home_view_loaded.zulip event trigger.
In commit 92ad988144, we removed the local echo code that tried
to re-render locally echoed messages that were rendered right before
a server/browser restart. These changes removed the only event
triggered by `"home_view_loaded.zulip"`.

This removes the remaining `"home_view_loaded.zulip"` event trigger
in web/src/server_events.js since it no longer triggers any events.
2023-06-27 18:04:04 -07:00
Evy Kassirer adcf088740
filter: Rename describe to search_description_as_html.
Changing this since wobbly naming on HTML variables is dangerous.
2023-06-26 11:11:17 -07:00
Lauryn Menard 73e5812831 node-tests: Update references to "private message" and "PM".
Updates any use of "private message" and "PM" in the `web/tests`
directory to instead use "direct messages".
2023-06-26 11:07:28 -07:00
Lauryn Menard 3c6d283aa9 compose-actions: Update trigger for composing a new direct message.
Updates the trigger in the compose box from "new private message"
to "new direct message".
2023-06-26 11:07:28 -07:00
evykassirer ca6e93ac7d condense: Remove _message_content_height_cache.
Since `scrollHeight` is very quick, we don't need
the cache anymore, and the code is easier to reason
about without it.

Profiling checks described on CZO here:
https://chat.zulip.org/#narrow/stream/6-frontend/topic/resize.20undo.20redo.20condense/near/1581520
2023-06-26 10:59:53 -07:00
Daniil Fadeev daab1d4265
compose_banner: Remove uploads banners when clearing compose box.
Upload banners were not cleared after closing compose box, which meant
that they would remain present in a paused state after compose was reopened.

https://chat.zulip.org/#narrow/stream/9-issues/topic/Incomplete.20Upload.20banner.20remains.20on.20closing.20compose/near/1582602
2023-06-23 11:45:04 -07:00
Lalit 13187ff8f6 ts: Convert `web/src/billing` module to TypeScript.
Converted all files inside `web/src/billing` to TypeScript.
2023-06-23 11:42:29 -07:00
Lalit 1f4dd0705d page_params: Make seperate `page_params` for billing module.
This commit introduces a seperate `page_params` file for billing module
since we only use certain page_params in billing module only that it does
not make sense to include them in the main `page_params.ts`.

Also introduced `zpage_billing_params` for proper testing new `page_params`
in billing module.
2023-06-23 11:42:29 -07:00
evykassirer e360a896f6 message view header: Don't initalize multiple times.
The `initialize` function registers a click handler, and
previously it was being registered another time each time
one of these calls to `initialize()` happened. The only
other thing that happens in `initialize` is a call to
`render_title_area`, so this commit replaces the extra
calls to initialize with that.
2023-06-23 11:33:44 -07:00
Aman Agrawal 5efa32be66 wildcard_mention: Don't highlight for unsubbed users. 2023-06-23 11:20:28 -07:00
Lalit 50dc8c87e9 typing_status: Refactor `recipient` family of variables.
Refactored `recipient` family of variables to better names like
`recipient_ids` which also aligns with the type of these variables.

Also, refactored `typing_status.test.js` to use array of user ids
instead of string names like `alice` and `bob` to stay consistent with
the actual type of these parameters.
2023-06-23 10:52:53 -07:00
Lalit 3613404581 typing_status: Refactor `state` object to either be null or has all
fields set.

This commit refactors the `state` object to either be null or has all
the fields set at the same time because they are note really decoupled.

This helps us to clean our code a little bit as well as makes it easier
to migrate this module to TypeScript.
2023-06-23 10:52:53 -07:00
Lalit 6ade7dcfb9 compose_typeahead: Cut dependency on `compose.js`. 2023-06-19 16:54:28 -07:00
Lalit e1ef8c623c compose_pm_pill: Cut dependency on compose_recipient.js. 2023-06-19 16:54:28 -07:00
Lalit 039b29c260 compose_actions: Add `hooks` for `compose.js` modules.
This commit cuts the dependency on `compose.js` module for
`compose_actions.js` module by introducing a hook system for
registering different hooks from external modules.
2023-06-19 16:54:28 -07:00
Prakhar Pratyush cbde01e9e3 settings: Add a "Followed topics" row to Notification Triggers table.
This commit adds a "Followed topics" row to the 'Notification Triggers'
table in the 'Personal settings > Notifications' panel and the
'Organization settings > Default user settings' panel.

This adds support to control email, push, wildcard mention,
visual desktop, and audible desktop notifications for messages
sent to followed topics by toggling corresponding global
notification settings.

The "Followed topics" row is available in the development
environment only.
2023-06-13 18:01:41 -07:00
Joelute 80ace5c789 compose_banner: Update classnames to main-view-banner-close-button.
Previously, we have duplicate stylings in compose banner and unread banner.
This is rather messy and creates a lot of styling rules. We should define
an abstraction for them. This change will rename compose_banner_close_button
to main-view-banner-close-button.
2023-06-09 11:31:51 -07:00
Tim Abbott 81526936ab starred_messages: Use standard initialization patterns.
We aim to only call .initialize methods from ui_init.js, and prefer to
pop fields off page_params there and pass them into modules.
2023-06-08 09:42:56 -07:00
evykassirer aa270bcef0 search: Remove support for experimental search pills.
This in-progress feature was started in 2018 and hasn't
been worked on much since. It's already in a broken state,
which makes it hard to iterate on the existing search bar
since it's hard to know how those changes will affect search
pills.

We do still want to add search pills eventually, and when
we work on that, we can refer to this diff to readd the
changes back.
2023-06-06 18:36:02 -07:00
Tim Abbott 7ad3225ecc starred_messages: Extract starred_messages_ui.js. 2023-06-05 21:57:35 -07:00
Tim Abbott 713a64d415 message_scroll: Extract module message_feed_top_notices. 2023-06-05 21:57:35 -07:00
Tim Abbott f99f567521 unread_ops: Centralize window focused logic. 2023-06-05 21:57:35 -07:00
Tim Abbott c961ad4f37 notifications: Inline handle_global_notification_updates. 2023-06-05 21:57:35 -07:00
Tim Abbott b75964a6cc stream_list: Break dependency on narrow.js. 2023-06-05 21:57:35 -07:00
Tim Abbott 5c0d63fb9a stream_list: Extract initialize_stream_cursor.
This does not create an event handler and thus did not belong in
set_event_handlers.
2023-06-05 21:57:35 -07:00
Anders Kaseorg 8a2086fb4c dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-06-05 21:51:26 -07:00
Satyam Bansal 8343cf1b4f
drafts: Update drafts count when opening and closing the overlay.
Previously, if the drafts modal was open in two different tabs and 
if the user deletes one or more drafts in one tab, then the count of
drafts wouldn't get updated on the other tab. 

The right long-term fix likely involves moving drafts from local storage to 
the cloud. But we can greatly reduce the impact of the bug by updating the count 
whenever the overlay is opened or closed.
2023-06-05 12:03:54 -07:00
Aman Agrawal 0f4bccd107 recent_conversation: Make all topics visible with compose open.
Fixes #25751
2023-05-30 12:41:08 -07:00
Aman Agrawal 6a5cfd2c05 popovers: Fix popovers not being hidden on scrolling. 2023-05-27 08:04:45 -07:00
Aman Agrawal 61f7ede43c hashchange: Never set empty hash `#` in URL.
Setting empty hash `#` scrolls user to the top of message feed if
done via `window.location.hash` or using browser back / forward button.

To avoid this, we set don't set `hash` after org URL for default view
when user uses `escape` key or clicks on org logo.

In other situations, we explicitly set the hash of the view.
2023-05-26 16:28:45 -07:00
Aman Agrawal a55c1ab2da server_events_dispatch: Remove body fade out on changing theme.
This causes the app to scroll to top and causes slow paint.
2023-05-26 09:40:24 -07:00
Aman Agrawal a78dc4a2bd css: Scroll on `html` instead of `.app`. 2023-05-24 15:43:19 -07:00
Daniil Fadeev 3e2d5b3c86 compose_validate: Use correct stream_id value for different context.
This commit addresses the issue of relying on `compose_state` for
retrieving the `stream_id` to display warning banners. Previously,
warnings were shown for syntax in the message edit box based on
whether that syntax would trigger a warning for the draft content (if
any) currently in the compose box.

We fix this by using a new `get_stream_id_for_textarea` function to
obtain the correct `stream_id` value for the check being done.

Fixes: #25410.
2023-05-24 12:48:44 -07:00
sbansal1999 7c68a30363 billing-helpers: Add commas to formatted amount. 2023-05-24 11:32:24 -07:00
Hardik Dharmani d9716bc189 left_sidebar: Improve mentions in muted topics.
When there are only muted unread mentions in a stream, show `@` icon
and unread count in faded style, also align the `@` on more topics
with no unead counter on it.

If there are only muted unread messages without mentions don't show
the unread counter on the stream.

Fixes #25382.
2023-05-19 18:40:57 -07:00
Lalit 7ac891a6b9 people: Add `version` parameter for medium sized avatar urls.
We need to append the `version` parameter when constructing the urls for
medium-sized images so that the browser updates the image in real time when
the user uploads a new avatar.

Fixes #25558.
2023-05-19 13:52:00 -07:00
Akarsh Jain 12db83b011 help: Open Help Center links in new tab for empty message lists.
This commit updates the Help Center links in all relevant empty message
list views to open in a new tab by default. This prevents users from being
navigated away from the app.

Fixes #25337.
2023-05-19 13:51:00 -07:00
Lalit 656a31d38d refactor: Move `maybe_get_stream_name` from `stream_data` to `sub_store`.
This commit moves `maybe_get_stream_name` function from `stream_data` to `sub_store`
as it didn't had any dependency on `stream_data` and it also helps us to cut off
dependency on `stream_data` for some of the modules including `user_topics`.
2023-05-18 08:46:16 -07:00
Karl Stolley 386d87635e popovers: Shorten 'Quote or reply' label.
This removes the previous "or forward" text from the message
actions popover, and keeps the documentation in sync with the
new text. Internationalization tests are updated, too.

Fixes #25603.
2023-05-16 12:36:29 -07:00
Aman Agrawal c96de330b0 stream_color: Dim recipient bar background color. 2023-05-16 12:35:17 -07:00
Brijmohan Siyag cb00fbc42f compose: Check posting policy for direct messages.
Prior this commit, changing the message type from a stream (where posting
was not allowed) to a direct message using the compose box dropdown, did not
changed the state of the send button from disabled to enabled even though
direct messages were allowed in the organization.

This was happening because `check_stream_posting_policy_for_compose_box` was
only for streams.

Now, function is updated to check for both streams and direct
messages, as it checks if direct messages are allowed or not, and depending on
that, it updates the send button's state, tooltip and displays a relevant banner.
2023-05-16 11:24:35 -07:00
Tim Abbott 3876171df1 compose: Fix opening compose box when viewing invalid stream.
This likely needs further refactoring to switch to using stream IDs
rather than names in this code path, but this change fixes an
exception that would be throw when opening the compose box while
viewing a narrow to an invalid stream name/ID.
2023-05-16 10:39:33 -07:00
Daniil Fadeev cb69413301 send_later: Add keyboard navigation to message scheduling modal.
Fixes: #25404.
2023-05-15 14:52:06 -07:00
Daniil Fadeev e64e5f2413 scheduled_messages: Add keyboard navigation.
Keyboard navigation has been added to the scheduled messages modal
in this commit. The solution is based on the `modals_handle_events`
function from the `messages_overlay_ui.js` module, as well as some
helpful functions from the same module.

Fixes: #25181.
2023-05-15 14:46:21 -07:00
Daniil Fadeev f2e627ba51 drafts: Move code handling keyboard navigation to a separate module.
The keyboard navigation that used to only work in drafts can now be
reused. This commit has moved the related functions to a separate
module.
2023-05-15 14:46:21 -07:00
Daniil Fadeev 35c23d0269 drafts: Refactor keyboard functions for reusability.
This is a preparatory commit to implement keyboard navigation in the
 message scheduling modal. The main goal is to make the
 `modals_handle_events` function reusable. To achieve this, we have
 extracted all the context-related variables and replaced all
 mentions of "draft" with the more neutral term "item". The
 `modals_handle_events` function now also has a context parameter,
 which contains all the necessary methods and properties to work in
 different modal contexts.
2023-05-15 14:46:20 -07:00
Lalit cab3a992c0 refactor: Extract `message_feed_loading` module from `message_scroll`.
This new module allows us to remove dependency on `message_scroll` in `fetch_status`
and hence allowing us to migrate it to TypeScript.
2023-05-14 11:24:31 -07:00
Lalit 9e1b4dafc0 message_list_data: Remove dependency on `filter.js`.
This commit removes dependency on `filter.js` by lifting the construction
of `Filter` object up in `all_messages_data.js`.
2023-05-14 11:24:31 -07:00
Alex Vandiver 9912b4c815 sentry: Unify logic for skipping span reporting.
This changes to not report any `call POST /json/users/me/presence`
spans, which we previously reported despite not including the inner
auto-instrumented HTTP spans.
2023-05-12 13:53:57 -07:00
Joelute 99dbea3331 narrow_banner: Drop empty action line from empty `dm-including:` views.
Previously, when a user enters a empty dm-including view, they'll notice
the "Why not start the conversation" action line and click on the link.
When this happens, the compose box would open but the receipent box is
never populated.

Since the dm-including view is a search view, we should drop that phrase
from dm-including views altogether. It also isn't super natural to
have a button that starts the conversation with the user anyways.

Fixes: #25524.
2023-05-10 18:07:53 -07:00
Lalit 407629b46c compose_banner: Add `update_or_append_banner` method in `compose_banner`.
`update_or_append_banner` abstracts the logic for not creating another compose
banner if one is already present in the DOM, it just replaces the content of the
old banner with the new one.
2023-05-10 17:54:28 -07:00
Tim Abbott 59daf54ec9 scheduled_messages: Fix broken node test.
This test just used the current hour, and thus would always fail at
24:00 UTC.
2023-05-10 17:06:59 -07:00
Daniil Fadeev e10997b0e6 scheduled_messages: Rerender send later options at specific time.
Fixes: #25451.
2023-05-10 16:14:10 -07:00
Tim Abbott 859a96e0d7 message_store: Keep track of wildcard_mentioned.
We'll need this to check if a message already had a wildcard mention
in the message edit code path.
2023-05-09 23:05:04 -07:00
Daniil Fadeev 209e9edd9d compose: Add container parameter to functions.
This commit introduces a new container parameter for functions that
can be used for both compose and edit mode. It provides the function
with information about the context in which it is being used.
2023-05-09 23:05:04 -07:00
Aman Agrawal 8ea59f7f02 compose: Use tippy for stream select dropdown.
Fixes #25434
2023-05-09 14:11:26 -07:00
Alex Vandiver 64b277d845 blueslip: Reduce cardinality of blueslip.error() calls.
Particularly when grouping in Sentry, pushing the ids and such into
the additional data section helps group like errors together better.
2023-05-09 13:16:28 -07:00
Alex Vandiver 5d97dbf8b3 zblueslip: Show chained causes in unexpected messages. 2023-05-09 13:16:28 -07:00
Alex Vandiver 9d6ca32c59 sentry: Annotate all channel calls. 2023-05-09 13:16:28 -07:00
Alex Vandiver 3cc2adcd3b sentry: Switch to using Sentry spans for message send timings. 2023-05-09 13:16:28 -07:00
Alex Vandiver 00ea197744 sentry: Switch to using Sentry spans for narrow/unnarrow timings. 2023-05-09 13:16:28 -07:00
Alex Vandiver 3ab22233f0 sentry: Add tracing extensions when Sentry is not enabled. 2023-05-09 13:16:28 -07:00
Tim Abbott 9e5c1eff4b scheduled messages: Fix incorrect mapping of 4PM to 16:00 hours. 2023-05-08 15:10:52 -07:00
Karl Stolley a318e7cbf4 scheduled_messages: Don't offer to reschedule in the past.
This introduces a function that checks for both the existence and the
expiration of the `selected_send_later_timestamp`.

The logic it supports prevents users from scheduling a message to send
in the past or less than five minutes into the future at the level of
the UI (specifically the popover on the \vdots component of the Send
button). That can happen if a user attempts to edit a previously
scheduled message.

Fixes #25439.
2023-05-08 15:10:52 -07:00
Karl Stolley 3e2422c8fe scheduled_messages: Prepare proper sending timestamps in Node test.
This corrects the scheduled message test to ensure that each relative
day (today, tomorrow) has the correct GMT timestamp for 9am and 4pm.
2023-05-07 11:57:20 -07:00
Hardik Dharmani b9611489ca node_tests: Extend unread.test.js to catch private message mentions bug.
In the "mentions" test, an additional unread message with the type
"private" and directly mentioning me has been added. This test case
checks for the scenario when the stream_id is null during the
reverse_lookup, which would have caused the test to fail before the
bug fix was implemented which now passes after the fix is applied.
2023-05-05 16:27:03 -07:00
Karl Stolley 5113f4e2e9 scheduled_messages: Render localized, streamlined modal opts.
This commit ensures that user-locale and 24-hour preferences are
respected in the message-scheduling modal. It also simplifies the
translation of text strings in the scheduling modal.

Available scheduling options and their time values, including whether
the options are allowed, are now calculated every time a user opens
the scheduling modal.

In order to achieve those things, additional interrelated fixes here
accomplish the following:

1. Modal-scheduling opts now have data- attributes containing
timestamps for the time a message will be scheduled to send.

2. With those timestamps in place, the logic for setting the
scheduled send-time is simplified.

3. There are no more `send_later_xxx` global variables in the
`schedule_send` module.

Fixes #25403.
2023-05-05 14:00:46 -07:00
Daniil Fadeev 0756ac9250 channel: Refactor xhr_error_message to accept message optionally. 2023-05-05 13:43:08 -07:00
Karl Stolley 715fa3aff6 scheduled_messages: Extract options logic from popover.
This commit extracts date-based logic from the popover menu file and
puts it in with the scheduled-messages logic.

The aim is for greater testability, with some initial tests now
presented on the date-based logic.
2023-05-04 13:52:22 -07:00
Tim Abbott 804f473214 message_list: Extract visibly_empty helper method.
This function will allow us to adjust the codebase to write what it
means semantically -- whether a check is for the message list being
visibly empty, or completely empty.

In this commit, we leave the .empty() method incorrect, because
several other adjustments need to be made atomically with fixing it.
2023-05-03 18:40:59 -07:00
Tim Abbott 976b0662ea top_left_corner: Fix new mention animation when loading app.
Apparently some past refactor caused the animation for new mentions to
be triggered when initialization the app.

(This seems pretty clearly unintentional: A user loading the app
doesn't need their attention specifically drawn to the @-mentions view
in the same way that a user who is using the app and receives a
mention right now does.)
2023-05-03 11:12:52 -07:00
Aman Agrawal 770a789651 hashchange: Hide popovers on change in hash.
Fixes #24641

When the user clicks on a link which has `stopPropagation`
and doesn't trigger `scroll`, then we don't hide any existing
popovers if the element being clicked doesn't hide popovers
explicitly.

To fix this, we hide all popovers on change in hash which makes sense
on its own given how we use hashes.
2023-05-02 15:41:37 -07:00
Karl Stolley cfbfc37927 scheduled_messages: Hide Scheduled messages on 0 count.
This commit introduces structures and logic to hide the Scheduled
messages item from the left sidebar if there are no messages
scheduled to be sent.

Test coverage has been added for counts and visibility, too.

Fixes: #25101
2023-05-02 15:26:33 -07:00
Karl Stolley 2d9cbfa8f1 scheduled_messages: Add left sidebar count.
This commit introduces logic to present a message count with the
Scheduled messages item in the left sidebar.

The count is present on the initial load, and is updated as a user
adds or removes scheduled messages.
2023-05-02 15:26:33 -07:00
Daniil Fadeev 6dc10f8696 compose: Pass a container to which the banner should be applied.
This fixes banners related to message editing incorrectly appearing
next to the compose box.

Fixes: #25230.
2023-05-02 14:09:09 -07:00
evykassirer 9ea6eca253 compose: Move cursor to end of topic input after stream selection.
Fixes #25321.
2023-05-02 12:49:31 -07:00
Joelute 5018cec311 unread_banner: Refactor unread banner HTML structure.
Previously, the unread banner templates just rendered on the contents of
the unread banner. This works fine if we don't want to make changes towards
the parent/container of the contents.

This change introduces a new container to each unread banner templates and
a rename. Thus, we can make unique styling changes to the unread banners
while also bring the structure closer to how it is for compose banners.
2023-05-02 09:14:28 -07:00
Aman Agrawal 7d373c54a9 scheduled_mesages: Use events to update scheduled message data.
This also allows to display scheduled message overlay without
fetching any data.
2023-05-01 22:45:03 -07:00
Lalit 7aa1763d73 typeahead: Delete display mode slash commands.
This commit deletes `/fixed-width` and `/fluid-width` slash commands
from the typeahead and also hides the slash commands `/light` and
`/dark` in production.

Fixes #25374.
2023-05-01 22:31:04 -07:00
Tim Abbott 7425079814 topic_list: Show muted unread counts in muted streams.
When all the unread messages in a muted stream are in specifically
muted topics, this ensures that the total unread count for the stream
that the user sees before clicking "more topics" will match the total
unreads number for the stream itself.

This behavior is limited to muted streams, since in a normal / not
muted stream, we don't display a "muted topics only" faded unread
count by the stream's summary line to avoid distracting the user with
it, we match that behavior for the "more topics" line.

We also now display the `@` , again to ensure the stream's summary
line never displays an `@` without some topic row having one.
2023-05-01 21:13:53 -07:00
N-Shar-ma c6ba33b7b4 hotkey: Repurpose `s` to toggle conversation view and remove `shift+s`.
Earlier, the `s` hotkey just narrowed to the stream of the selected
message (to a topic), while `shift+s` narrowed to the conversation view
(topic / dm) of the selected message.

Now, the `shift+s` hotkey has been removed (but retained for toggling
subscription to a stream when the stream overlay is active), and the `s`
hotkey takes on double duty: if the current view is not topic / dm, it
narrows to that, else when in topic view, it switches to stream view. It
has no effect when in dm view. Documentation has been updated for this
both in the help center, and the in-app `Keyboard shortcuts` menu.

A deprecation notice has been added for `shift+s` as well.

Fixes: #24226.
2023-05-01 20:32:58 -07:00
Tim Abbott 18e2cee572 typeahead: Do not prioritize exact name matches for users.
As discussed in the comment, this resulted in the many inactive users
in chat.zulip.org with "Tim" as their full display name from being
incorrectly prioritized over me in a stream where I've been active;
and this class of problem seems like it will be common in large open
communities.

This reverts a portion of 4dc1b2f812,
with explanatory comments for why this behavior is preferred.

The stream name changes in the original PR remain very helpful.
2023-05-01 17:10:59 -07:00
Tim Abbott 6fe02e933a timerender: Extract new variant of get_full_datetime.
Separating these concepts allows us to provide a much nicer format for
contexts where ultra-specific clarification is not a priority.

This new variant is currently only used in the scheduled messages UI.
2023-04-30 22:39:52 -07:00
palashb01 cee0cabd8d left_sidebar: Replace the presence dot with bot icon for bots.
This commit replaces the presence dot display with a bot icon
for bots in the left sidebar PM list.
2023-04-28 19:14:00 -07:00
Tim Abbott d42ac60d61 scheduled_message: Fix i18n for scheduled time. 2023-04-28 17:25:00 -07:00
Aman Agrawal f40855bad2 reminder: Remove feature from zulip.
This is being removed to make the code simpler. We have plans
to add it as a feature in the future , but it will most likely
not use the same code.
2023-04-28 17:25:00 -07:00
evykassirer 19d5fedfd2 compose: Move functions around to reduce circular imports. 2023-04-27 17:04:19 -07:00
evykassirer 18312be6db compose: Add ability to switch to PM in stream dropdown.
Fixes #3409
2023-04-27 17:04:19 -07:00
evykassirer 695946746e compose: Rename stream selection widget to "select_recipient".
Previously this dropdown was only for selecting streams, but
soon it will also be for switching to a private message. This
name helps it be clearer that the dropdown is more general
purpose.
2023-04-27 17:04:19 -07:00
N-Shar-ma 4dc1b2f812 typeahead: Always show exact matches first for streams and users.
We refactor the triage function to optionally take in a comparator
function, and use this to sort the results, except any exact match,
which is placed highest. Now we don't need to sort the results of triage
for streams, languages and slash commands since we just pass in the
comparator function. The overall effect is same as before, except that
exact matches are always shown first.

For users, we can't use the new triage feature to achieve this goal
without sorting `rest` and breaking a key optimization, so we just add
a bit of manual code for the job.

Fixes: #25123.
2023-04-27 12:45:26 -07:00
Sahil Batra 7eacd525b4 compose: Show banner if user is not allowed to post in the stream.
We now show a banner on opening the compose box and changing the
stream in dropdown, if a user is not allowed to post in a stream.

The "Send" button is also disabled if user is not allowed to post
in the stream.

This commit also moved the CSS for disabled modal button in dark
theme below after the other CSS for modals as we are using the
same CSS for the "Send" button as well in disabled state.
2023-04-27 12:31:40 -07:00
Lalit b9223088f3 refactor: Move simplebar helper functions from `ui` to `scroll_util`.
This commit eliminates the `ui.js` module from the codebase by moving
all simplebar helper functions to the `scroll_util` module.
2023-04-26 12:59:08 -07:00
Lalit 7e52509ee7 ui: Move update_message_lists related functions to other related modules.
This commit moves mainly two functions from `ui.js` to `message_live_update`,
`update_message_in_all_views` and `update_starred_view`. This is done in favor of
eliminating `ui.js` and also these functions are more closely related to
`message_live_update` module than to `ui` module.

We also move `show_message_failed` and `show_failed_message_success` to `echo.js`
for cleaner seperation of responsibilities.
2023-04-26 12:59:08 -07:00
Sahil Batra 9ec3608569 dropdown_list_widget: Colorize stream privacy icons.
This commit adds code to colorize the stream privacy icons in
dropdown list widget. Both the selected option in button and
options in the menu are colorized as per the stream color.

Fixes #25282.
2023-04-26 10:55:58 -07:00
N-Shar-ma 9f2ef69c71 compose: Add banner for unmuting the muted topic a message is sent to.
We add a new banner informing the user if and when they send a message
to a muted topic / stream. It also has a button to unmute the topic.

Fixes: #24246.
2023-04-25 16:16:47 -07:00
Hardik Dharmani dd001e1a5f recent_conversations: Use unmute icon for topics in muted streams.
Updated click handlers for mute/unmute icons for topics in
recent_conversations to work as per their stream.

Fixes #25124
2023-04-25 13:35:38 -07:00
Sahil Batra 639af1d56d compose_ui: Refactor functions to show and hide loading spinners.
This commit refactors show_compose_spinner and hide_compose_spinner
functions to use class of the button instead of ID to select the
appropriate elements such that we can use the same function to show
and hide spinner in "Schedule" button in further commits. For this
purpose, we add a new class compose-submit-button to the "Send"
button and this class will be added to "Schedule" button as well
in the next commit.
2023-04-25 12:51:59 -07:00
Prakhar Pratyush a079bb811b user_topics: Rename 'settings_muted_topics.js'.
This commit renames 'settings_muted_topics.js'
to 'settings_user_topics.js' because the file now
supports the settings for topics with any visibility_policy,
not just MUTED.

It also renames the corresponding test file.
2023-04-25 12:46:05 -07:00
Prakhar Pratyush c526543498 settings: Update the 'Muted topics' setting.
This commit updates the existing 'Muted topics'
settings UI to add support for other visibility
policies.

Changes:
Settings sidebar:
1. Rename 'Muted topics' to 'Topics'.
2. Change icon.
Main panel:
3. Rename 'Muted topics' header to 'Topic settings'.
Topics table:
4. Rename 'Date muted' to 'Date updated'.
5. Update the search bar placeholder text to 'Filter topics'.
6. Drop the 'Actions' column.
7. Add a status column with a dropdown set of options.
(Muted, Unmuted, Default for stream)

Fixes #25081.
2023-04-25 12:46:05 -07:00
Prakhar Pratyush e87f2ff408 user_topics: Update 'get_user_topics_for_visibility_policy'.
This prep commit updates the function
'get_user_topics_for_visibility_policy' to include 'visibility_policy'
as one of the keys in the user_topic objects.
2023-04-25 12:46:05 -07:00
Lalit 9cad825d95 refactor: Rename `stream_sort.js` to `stream_list_sort.js`.
Renamed `stream_sort` to `stream_list_sort` to make it clear that this
module is part of the stream_list bundle of modules.
2023-04-25 10:05:59 -07:00
Lalit 2996e8e722 js: Break cyclic dependency between modules related to `stream_data`.
Moved `stream_data.is_active` to `stream_sort.has_recent_activity` to
remove the cyclic dependency between `stream_data` and `stream_topic_history`.
2023-04-25 10:05:59 -07:00
Lalit 833cc71181 ts: Convert input_pill.js to TypeScript.
Migrated input_pill subsystem to TypeScript, used generics to make
it a generic module so that it works with different implementations
like stream_pill or user_pill.
2023-04-25 09:09:48 -07:00
Lauryn Menard ae41e61520 narrow: Remove frontend support for "group-pm-with" operator.
Replaces "group-pm-with" in the web app with "dm-including".
2023-04-25 09:07:08 -07:00
Lauryn Menard 311f436c68 narrow: Add frontend support for `dm-including:` narrow.
Adds support in the web app for `dm-including` operator.

This will deprecate the `group-pm-with` operator, but any changes
to that narrow operator will be in a separate commit since it
returns a different message query. The `group-pm-with` operator
only returned group direct messages, while the new `dm-including`
operator returns both group and 1-on-1 direct messages.

The general API changelog and documentation updates will be done
in a final commit in the series of commits that adds support for
the various new direct message narrows.
2023-04-25 09:07:08 -07:00
Lauryn Menard 0f7341dd48 narrow: Add frontend support for `dm:` narrow and `/dm/...` URL.
Adds support in the web app for `dm` operator. This will deprecate
the `pm-with` operator, but existing links/URLs are still supported
for backwards-compatilibity.

This commit updates the web app default behaviors to default to
the new narrow/URLs `dm/...` and `/#narrow/dm/...` when navigating
and searching in the app.

There is some general clean up of references to private messages
or PMs to be either direct messages or DMs in these changes.

The general API changelog and documentation updates will be done
in a final commit in the series of commits that adds support for
the various new direct message narrows.
2023-04-25 09:07:08 -07:00
Lauryn Menard d379020726 narrow: Add frontend support for `is:dm` narrow and `/is/dm` URL.
Adds support in the web app for `is` operator with the `dm` operand.
This will deprecate the `is` operator with the `private` operand,
but we keep support for backwards-compatibility with links/URLs.

This commit updates the web app default behaviors to default to
the new narrow/URLs `is:dm` and `/#narrow/is/dm` when navigating
and searching in the app.

There is some general clean up of references to private messages
or PMs to be either direct messages or DMs in these changes.

The general API changelog and documentation updates will be done
in a final commit in the series of commits that adds support for
the various new direct message narrows.
2023-04-25 09:07:08 -07:00
Lauryn Menard 45da8c2a54 pm-list-data: Increase max conversations shown in left sidebar.
Incresase the max number of conversations shown when not zoomed
into the direct messages in the left sidebar to be 8 when there
are no unread conversations and 15 when there are unread
conversations.
2023-04-25 08:59:03 -07:00
Tim Abbott a66c8227d8 node tests: Fix drafts tests for new colors.
This should have part of a03cf8045a3bb9ea47f91901533c3ca2a15ff548.
2023-04-24 18:16:04 -07:00
evykassirer 7c9677becd search: Put typeahead under search bar in the DOM with full width.
Previously the typeahead container was being created at the bottom
of `body`, and its width (and `top` and `left`) were being set to
move it to the right position.

Now it sits in the search box container, which gives it the correct
position and width by default. This is better for DOM readability,
and is also better for the new 100% width (which is part of the
search bar redesign) because it can change width more smoothly
with the search bar when the page changes width.

This commit adds custom functionality to the bootstrap typeahead
to allow the typehead to be placed in the search box container
(whereas previously, it could only be appended to `body`).
2023-04-24 17:15:41 -07:00
AcKindle3 fd84651a16 Localstorage: Use `zod` to parse type `FormData`.
Local storage is an untyped interface external to the frontend code
itself. The `data` field after `JSON.parse`'d from `raw_data` can be
further validated using `zod`'s schema `formDataSchema`.

The test case `server_upgrade_alert hide_duration_expired` in
`navbar_alerts.test.js` has a bug at `start_time`, which is fixed in
this commit. `start_time` is a mock value of `Date.now()` used in
`localstorage.ts`, which will concatenate with a number `expires`.
So `start_time` was supposed to be an integer value. Before fix, `new
Date(1620327447050)` returns a `Date` object which is wrongly
concatenated with `expires`.

Fixes #24997.
2023-04-24 11:59:02 -07:00
palashb01 047bffe257 compose_box: Convert dynamic closed compose box tooltips to tippyjs.
This commit converts the dynamic closed_compose_box
tooltip to template-based tippy.js tooltips. The functions in
the compose_closed_ui.js file are refactored to dynamically change
the 'data-tooltip-template-id' attribute according to the situation.

The title parameter is removed from the functions in
compose_closed_ui.js so that we can change the tooltip within the
caller functions themselves, according to the situation. Since there
is no way to match the title in existing functions with different
languages to change the tooltip attribute dynamically, it is better
to change the tooltip attribute within the caller function according
to the situation, rather than passing the title as a parameter.

In the case of the reply button, we disable it when direct messages
are not allowed. However, tippy.js tooltips do not appear in the
case of disabled elements, so we have to use the container element
around it to show the tooltip. This approach is used in the case of
the reply button, where the span element wraps the button.

We used to have two titles for the reply button: one is the usual
'Reply to selected message', and the other is for the disabled state.
However, in the case of recent conversations, it makes more sense
to have a new tooltip title: 'Reply to selected conversation'.

To ensure that the tooltip content changes dynamically, it is
required to destroy the tooltip instance and then reinitialize it
every time.

Fixes: #25096
2023-04-24 11:45:56 -07:00
Hardik Dharmani 98162b7a3a left_sidebar: Show unread_mention in regular font if in unmuted topic.
If there are unread_mentions in unmuted topic in muted stream then,
show `.subscription_block unread_mention` in regular font not faded.

An additional parameter is passed to the update_count_in_dom function
to add or remove the "has-unmuted-mentions" class from the
.subscription_block, allowing for the relevant CSS to be applied to
display the unread mentions in regular font.

Fixes part of #24243.
2023-04-24 11:41:21 -07:00
Hardik Dharmani 6f1b8fe340 left_sidebar: Implement new unread_count logic for muted stream.
This commit implements a new logic to display unread messages count
in muted streams. If there are any unread messages in unmuted topics
within a muted stream, the unread counter for the stream will display
the total count of all the unread messages in the unmuted topics.
The counter will be shown in regular font (not faded).

Fixes part of #24243.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
2023-04-24 11:41:10 -07:00