Commit Graph

739 Commits

Author SHA1 Message Date
Tim Abbott 496b403fcf tooltips: Add new central tooltip template store.
We should migrate all the static content tooltip templates to this
file to avoid duplicate DOM elements.
2023-04-27 18:12:32 -07:00
Hardik Dharmani ea6ae50326 tooltips: Add tippy tooltip for view_user_card.
Added modern tippy tootip for view_user_card tooltip by adding a
<template> with id=view-user-card-tooltip-template for the element.

Fixes part of #24311.
2023-04-27 18:12:32 -07:00
Tim Abbott 6aea3f2be5 tooltips: Use tippy tooltip for stream list toggle. 2023-04-27 18:12:32 -07:00
Hardik Dharmani dcfd374f2f left_sidebar: Correct hotkey for `All direct messages` tooltip. 2023-04-27 18:12:32 -07:00
Hardik Dharmani 941c15b802 tooltips: Add tippy tooltip for search_query.
Added tippy tooltips for search_open, search_close icon and
search_query input field with hotkey hint `/' by adding a class
`.tippy-zulip-delayed-tooltip` which adds tooltip with
LONG_HOVER_DELAY and default placement top with fallback placement
equal to bottom.

Added tippy tooltip with text `Close` on `.search_close_button`.

Fixes part of #24311
2023-04-27 18:12:32 -07:00
Hardik Dharmani 9c866f9be1 tooltips: Add tippy tooltip for message expander/condenser.
Added tippy tootip for '.message_expander' and
'.messsage_condenser' by adding '.tippy-zulip-delayed-tooltip' class,
and creating 2 <template> with id equal to crresponding
data-tooltip-template-id of the elements.

Fixes part of #24311
2023-04-27 18:12:32 -07:00
Hardik Dharmani 15a15240da tooltips: Add tippy tooltips in manage stream settings.
Added tippy tooltips for create_stream_plus_button and
preview-stream-button in manage stream settings by adding
class `.tippy-zulip-delayed-tooltip` which add tooltips
with LONG_HOVER_DELAY. Added data-tippy-placement="bottom"
to match with 'Archive stream' tooltip.

Created a new tooltip for sub_unsub_button in tippyjs with
class .toggle-subscription-tooltip that has
EXTRA_LONG_HOVER_DELAY, placement equals to bottom
and appended to body.

Fixes part of #24311.
2023-04-27 18:12:32 -07:00
Hardik Dharmani 394fcbfd51 tooltips: Add tippy tooltip for userlist-toggle icon with hotkey hint `W`. 2023-04-27 18:12:32 -07:00
Hardik Dharmani 892bd38062 tooltips: Use tippy for `gear-menu` icon with hotkey hint `G`.
Fixes part of #24311
2023-04-27 18:12:32 -07:00
Hardik Dharmani 7785fb2948 tooltips: Add new tippy configuration `.tippy-zulip-delayed-tooltip`.
Added new tippy tooltips configuration with target class
`.tippy-zulip-delayed-tooltip` which add tooltips with
`delay: LONG_HOVER_DELAY`, appended to body, and have a
default placement top with fallback placement equal to bottom.

Fixes part of #24311
2023-04-27 18:12:32 -07:00
Palash Baderia c10d33d23c tippy: Remove the focus trigger from the compose-control-buttons.
By default, tippyjs uses a trigger value of 'mouseenter focus',
which means that the tooltips can appear either when the element
is hovered over or when it receives focus (e.g., by being clicked).
Because of this, if you click on the button to open the popover,
the tooltip also appears. To prevent this behavior, we need to
remove the 'focus' trigger from the buttons so that the tooltips
don't appear when the buttons are clicked.

Fixes: #25277
2023-04-27 17:36:48 -07:00
evykassirer 19d5fedfd2 compose: Move functions around to reduce circular imports. 2023-04-27 17:04:19 -07:00
evykassirer 0e13134be2 stream header colorblock: Remove unnecessary `find`. 2023-04-27 17:04:19 -07:00
evykassirer f9bf688c9e compose: Add DM icon to the recipient dropdown.
This commit adds the new users icon and uses it in the
recipient dropdown, both in the selection options and
the selected option displayed on the button.
2023-04-27 17:04:19 -07:00
evykassirer 408bdc2273 compose recipient: Move DM to bottom of dropdown when feature is disabled. 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 e4fc197871 click handlers: Don't move focus for clicks in compose box while composing.
If a click happens somewhere within compose, we don't want to cancel compose
and we also don't necessarily want to refocus the cursor in the compose
text area.

This change was made because clicks in the compose recipient dropdown
were hitting the first `if` statement and moving focus to the text area
when it should have gone to the topic or PM recipient input fields.
This `if` block was originally written for clicking external links and
codeblocks, which are outside of the #compose div and won't be affected
by this change.
2023-04-27 17:04:19 -07:00
evykassirer 0634457731 compose: Deduplicate code for fetching recipient switcher options. 2023-04-27 17:04:19 -07:00
evykassirer 6c797904f2 compose: Let recipient switcher change width with content. 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
Sahil Batra e02111e458 compose: Show all accessible streams in stream dropdown menu.
We now show all the streams, even if user is not allowed to post
in them, in the stream dropdown in compose box. In further commits,
we would add a banner mentioning that user is not allowed to post
for such streams.
2023-04-27 12:31:40 -07:00
Karl Stolley 67f3cb67c5
left-sidebar: Provide link to scheduled messages.
This provides a basic link to view scheduled messages. At present, the
link is always visible, and it does not yet include a scheduled-message
count.

Fixes part of #25101.
2023-04-27 12:13:59 -07:00
Tim Abbott 07cb08b8c5 message_row: Share most CSS for /me message senders.
This fixes a bug where clicking on a /me message sender would display
a focus outline incorrectly, and likely also overflow-related bugs.
2023-04-27 11:42:21 -07:00
Tim Abbott 9847e7024a message_row: Add sender_name_padding for /me messages.
This fixes the region between the avatar and the sender name in /me
messages not being part of the blue hover/highlight region for the
sender's user card.
2023-04-27 11:42:21 -07:00
Tim Abbott ab0c5f3092 message_row: Shrink sender_info_hover region.
The sender_info_hover region incorrectly filled the full row to the
right of the sender's name, resulting in the blue highlight being
visible in parts of the message that should be just the message body.

Fix this by moving the selectors for it further down in the DOM.

Fixes #25276.
2023-04-27 11:42:21 -07:00
Lalit 866c91d5a5
info_overlay: Fix initial keyboard focus in keyboard shortcuts help.
The core bug here was that we opened the overlay after setting up the toggler
widget; this meant that the call to focus the correct element in the toggler 
widget setup code path was ignored due to it not being possible to focus an
element that is hidden.

Fix this bug by reordering the execution of things, now we first open
the overlay to make sure that the content is available to be focused when
setting up the toggler.
2023-04-27 10:34:18 -07:00
Lalit ae613c815e refactor: Move `append_compose_banner_to_banner_list` to `compose_banner.ts`.
Before `scroll_util` typescript migration this function was present in `compose_validate`
but this function is more closely related to `compose_banner` module, hence moved this
function to `compose_banner`.
2023-04-27 09:00:13 -07:00
Lalit c7b8f0658b ts: Migrate `scroll_util.js` to TypeScript.
This commit migrates `scroll_util.js` to typescript. I made a helper
type `JQueryOrZJQuery` for the argument of `get_scroll_element` instead
of adding a `__zjquery` property to the global JQuery object because it
isn't being used anywhere outside of this function and hence it makes
sense to have a little helper type than to add the property to the global
object.
2023-04-27 09:00:13 -07:00
Prakhar Pratyush b6aa004334 notifications: Enable desktop notifications for the UNMUTED topic.
UNMUTED topics in muted streams obey stream-specific
notification settings and global notification settings
as fallback.

A user receives or does not receive email or push
notifications for messages in UNMUTED topics depending
on the email or push stream-specific notification settings
configured, and global notification settings are used as a fallback.

This commit updates the logic to send or not send
desktop notifications for messages in the UNMUTED topic
depending on the corresponding stream-specific notification
settings configured and global notification settings as a fallback.
2023-04-27 08:56:58 -07:00
Sahil Batra e4420bcd61 dropdown_list_widget: Show stream icons when widget is disabled.
We show the stream privacy icon for the selected option in
dropdown list widget even if the widget is disabled. It is
fixed by changing the CSS to hide only the "i" element used
for the arrow toggle button and not all the "i" elements in
disabled state.
2023-04-26 15:44:35 -07:00
AcKindle3 de420f68a4 ts migration: Convert `dark_theme.js` to `dark_theme.ts`.
Add `void` type annotation to the return type of functions. The
rest of the file is not modified.
2023-04-26 15:40:23 -07:00
Daniil Fadeev 980f7df376 compose: Fix banners running off the screen.
We introduce a scrollable region, with a simplebar scrollbar.

Fixes: #25115.
2023-04-26 14:03:34 -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 b55ee161e2 refactor: Move `replace_emoji_with_text` from `ui` to `ui_util`. 2023-04-26 12:59:08 -07:00
Lalit e132a68193 refactor: Create `compose_textarea` and extracted related handlers from `ui.js`.
Created the new `compose_textarea` and moved event handlers for `#compose_textarea`
from `ui` to this new module so that it is now responsible for initializing event handlers
for compose_textarea instead of `ui` 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
sbansal1999 aad2f7c7c5 compose: Remove empty message warning border after closing.
Adding this made the line coverage of
"web/tests/lib/zjquery_element.js" equal to 100%, hence it
was required to remove it from the exempt files list.
2023-04-26 10:58:08 -07:00
Sahil Batra 95add66ed3 templates: Add missing "aria-hidden" attribute.
This commit adds missing "aria-hidden" attribute for hashtag
icon in inline_decorated_stream_name.hbs template and sets its
value to "true".
2023-04-26 10:55:58 -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
Anders Kaseorg b8023da17a dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-25 22:18:48 -07:00
Anders Kaseorg ca6b0d8c5a e2e-tests: Fix ensure_enter_does_not_send.
A variable in the Node.js context cannot be mutated by a function
evaluated in the browser context.  The boolean was also incorrectly
inverted, and a click to open the dialog containing
`enter_sends_choice` was missing.

Co-authored-by: Aman Agrawal <amanagr@zulip.com>
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-25 19:30:35 -07:00
Tim Abbott 9886cd1488 popovers: Tweak mute/unmute icons for topic menu.
While we use a different convention in recent conversations and
recipient bars, in this context, it make sense for this icon to just
match the action we'll be doing.
2023-04-25 18:00:11 -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
N-Shar-ma ff8d209807 compose: Add utility function to clear all compose banners. 2023-04-25 16:04:38 -07:00
Hardik Dharmani fa53026244 topic_sidebar_actions: Implement new mute/unmute toggle UI for topics.
For topics in muted streams, replace the "Mute topic" option in the
three-dot topic menu with an "Unmute topic" option, which should make
the topic unmuted. For unmuted topics in muted streams, show the
regular "Mute topic" option, which should specifically mark the
topic as muted, as usual.

Also, used new unmute icon for unmute option in three-dot menu for
topics in muted stream.

Fixes part of #24243
2023-04-25 15:01:52 -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
Hardik Dharmani eee5c99cd7 recipient_row: Use unmute icon for topics in muted stream.
Updated mute_or_unmute_topic to take visibility policy as parameter
and set topic visibility_policy to the passed visibility_policy.

In zulip.css, updated CSS to set opacity as per visibility_policy.

Updated click handlers for recipient_row mute/unmute icons to
work as per stream.

Fixes #25124
2023-04-25 13:35:38 -07:00
Hardik Dharmani 06709bc5da icons: Add new unmute icon SVG.
Added unmute.svg in web/shared/icons. Also added
source and license information for the icon in
docs/THIRDPARTY.

Additionally, used unmute icon for unmute option in
topic_sidebar menu for topics in muted stream.

Fixes #25124
2023-04-25 13:35:38 -07:00
Sahil Batra 99f8c19d6d compose: Show loading spinner in "Schedule" button.
We now showing spinner in the "Schedule" button while the
message is being schedules similar to how we show the spinner
for "Send" button.

Fixes #25182.
2023-04-25 12:51:59 -07:00
Sahil Batra 0e20cdfa50 compose: Fix behavior when scheduling message using slash command.
We show the loading spinner when scheduling message using slash
command as the submit button present is "Send" button and not
"Schedule" button. This commit fixes the behavior to hide the
loading spinner in case of both success and error and also resets
the UI (mainly enabling the textarea element and clearing the
compose box) after successful scheduling of message using the
slash command.
2023-04-25 12:51:59 -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 d5846ab534 user_topics: Rename 'muted_topics_settings.hbs'.
This commit renames 'muted_topics_settings.hbs' to
'user_topics_settings.hbs', because the file now represents the
settings for topics with any visibility_policy, not just MUTED.
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
sbansal1999 40cea58f87 ts: Convert fenced_code.js to TypeScript. 2023-04-25 09:31:15 -07:00
sbansal1999 5a758c74e4 fenced_code: Remove unused argument from stash_func calls.
The default stash function (which does nothing, as it's
essentially an identity function) and the function passed
from "markdown.js" do not accept any boolean input.

However, in "fenced_code.js", the function calls provide
a boolean parameter that is not used. This commit removes
that unused boolean argument.

It is required for its migration to TypeScript.
2023-04-25 09:31:15 -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
Lalit 83e1d78b7b input_pill: Break import cycle with `compose_recipient.js`.
This commit breaks the trivial import cycle between `input_pill` and
`compose_recipient.js` by manually triggering an on-change event when we remove
a pill which makes sure to run the `update_on_recipient_change` as
the event callback without us having to import it inside `input_pill`
and manually calling it.

Fixes: #25022
2023-04-25 09:09:48 -07:00
Lalit c0e9e463fb input_pill: Refactor `payload` object in `appendValidatedData` function.
Refactored `payload` object such that when we migrate this module to typescript,
we will not have to write an incomplete type definition for this object.
2023-04-25 09:09:48 -07:00
Lalit e5e8c949d3 input_pill: Consistent binding of functions.
This is a prep commit for preparing this module for typescript
migration. We should consistently use `.bind` and bind the funcs
in the final prototype correctly.
2023-04-25 09:09:48 -07:00
Lauryn Menard 9880fcb936 narrow: Document new filters `is:dm`, `dm` and `dm-including`.
Documents narrows now have support for new filters for direct messages:
`is:dm`, `dm`, and `dm-including`. Also documents that `is:private`,
`pm-with` and `group-pm-with` are now legacy aliases for these three
new filters respectively.

Note that API documentation references the help center documentation
for search/narrow filters.

Fixes #24806.
2023-04-25 09:07:08 -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
Lakshay Mittal 0b10a33565 search: Fix display of suggestion box when search bar empty.
When search bar is empty and we've reached that state
by using the `backspace` key. There are no suggestions
as there are when you select an empty search bar.

The cause of this was an explicit prevention of this
suggestion box in `typeahead.js` so that the
`backspace` key is free to interact with the other
elements.

The fix here is to add an optional `hideOnEmpty` option
so that if we want this suggestion box to appear we can
set this option to `false` and this behavior will be
prevented.

This option is enabled for the search input when pills are not
enabled.

Fixes: #25062.
2023-04-24 21:45:06 -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
Aman Agrawal 219a936aee css: Use less saturated colors for PMs. 2023-04-24 17:29:06 -07:00
Aman Agrawal defd1c30df stream_color: Try a different color mix for recipient bar color. 2023-04-24 17:29:06 -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
Lakshay Mittal e3984f119d popovers: Fix popovers not hiding when clicked on search.
Added `popovers.hide_all()` call in desired functions related
to search bar.

Fixes: #24318
2023-04-24 17:09:36 -07:00
N-Shar-ma f1ec9e139f typeahead: Hide typeahead on clicking outside after clicking its header.
Until now, the typeahead was hidden on clicking outside only if the last
click was not on the header. This happened because clicking the header would
blur the input, and any other click then would not trigger the blur event
(which is responsible for hiding the typeahead).

Now we refocus the input after clicking the header, so that clicking
elsewhere blurs the input and hides the typeahead.
2023-04-24 17:06:56 -07:00
Ujjawal Modi 449febf036 streams: Make stream settings and create stream UI more consistent.
This commit make changes in create stream panel by moving
announce stream option below stream description and adds a
"Stream permissions" section heading just above
"Who can access the stream?" and also rewords the text
"Announce stream".

Also now announce stream option is only shown if the user creating
stream have access to the announcement stream name. When option
is not shown, default behaviour is to announce public and
web-public streams.

Fixes #23327.
2023-04-24 17:02:33 -07:00
m-e-l-u-h-a-n 308f42eded css: Add word-break property to .modal__title.
Modal that were used as dialog boxes for editing info
had issues with long heading text int .modal__title,
This commit add word-break to break words and avoid
abrupt ui in such cases.
2023-04-24 16:53:35 -07:00
m-e-l-u-h-a-n ae16787a25 css: Remove redundant css rule from streams/groups overlay. 2023-04-24 16:53:35 -07:00
m-e-l-u-h-a-n 4b5c073c05 user groups: Minor fixes in CSS common to #groups and #streams overlay.
This commit does following improvements in #streams and #groups overlay.
* Adds word break in the title in the right pane to handle long stream
  and group names.
* Fix positioning of edit (pencil) button to the right end and provide
  maximum available space for stream/group name.

Co-authored-by: Hardik Dharmani <Ddharmani99@gmail.com>
2023-04-24 16:53:35 -07:00
Akarsh Jain b154722dec todo_widget: Fix cursor focus in todo lists.
Previously, when adding a task to a /todo list, after pressing "Add
task", the cursor would move to the "Description" field, which is
not the desired behavior. This commit fixes this issue by ensuring
that the cursor moves to the "New task" field after a task is created.

The core bug was introduced in
68dcdcd28e, which added the incorrect
.focus().

Also tighten the selectors while we're at it.

Fixes #25064.
2023-04-24 16:11:20 -07:00
SameepAher 9e4b5b2bed css: Fix text overflow bug for pill values.
This commit fixes the text overflow bug for pill values by adding a
maximum width of 100% for the pill along with the ellipsis property on
text overflow.

Fixes: #21807.
2023-04-24 16:04:03 -07:00
Joelute a840cd88ab click_handlers: Allow messages being edited/viewed to be clicked.
If a user is editing a message or viewing the message source, they'll notice that clicking on the messsage doesn't move the blue box to it while the keyboard works just fine. We want to allow the message to be selected while not triggering the reply function.
2023-04-24 16:02:34 -07:00
Hardik Dharmani 7a14f12031 recipient_row: Correct hotkey for mute icon tooltip. 2023-04-24 15:56:16 -07:00
Tim Abbott 28f86057d6 lint: Fix TypeScript linter error in localstorage.ts.
This was introduced because the PR converting this file to TypeScript
predated this linter rule being enabled.
2023-04-24 13:24:08 -07:00
Tim Abbott 5e8e7af066 i18n: Fix encoding of stream bookends.
Fix an issue with how 3e6f34780a
passed the stream name to the template around translation tags.
2023-04-24 12:19:06 -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
AcKindle3 70b8eb3423 TS migration: Convert `localstorage.js` to `localstorage.ts`.
Added function parameter types, return type, and types of local
varaibles. Added a `null` check for `raw_data` before `JSON.parse`.
Created a type `FormData` and an export type `LocalStorage` to
imporve conciseness and clearity.

Type `LocalStorage` is exported because it might be used in other
files based on an observation that many files have imported `localstorage`.
2023-04-24 11:59:02 -07:00
Akarsh Jain 3e6f34780a bookend: Add stream icons to subscribed/unsubscribed divider line.
Fixes: #23685.
2023-04-24 11:53:16 -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
palashb01 aa23b9deaf compose_box: Convert compose_box tooltips to tippyjs tooltips.
This commit converts the static tooltips of closed compose box
to tippy.js tooltips.
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
Hardik Dharmani 19a2365ab9 left_sidebar: Display unmuted topic in regular font (not faded).
Add class unmuted_topic to li.bottom_left_row element if topic is
unmuted. Add relevant CSS for .unmuted_topic to display unmuted
topics in regular font.

Fixes part of #24243.
2023-04-24 11:40:58 -07:00
Hardik Dharmani 8701d546f3 left_sidebar: Change CSS for fading muted stream.
Previously, muted streams in the left sidebar were faded using
opacity: 0.5, and on hover, the opacity was increased to 0.75.
This opacity was applied to all elements within the muted stream,
including the stream-privacy icon, names of the stream and topics
within, and the unread_count.

In this PR, we changed this behavior to handle opacity for each
element separately. We changed the opacity of the stream-privacy icon
and unread_count, while for the text (names of stream and topics),
we changed the alpha factor for the hsla color property.

The reason for this change is that we can have different opacity levels
for the unread_count and other elements. This will allow us to add
feature in next commits in this PR to set the opacity of unread_count
to 1 while keeping it at 0.5/0.75 for other elements in the case of
muted streams with unread messages in unmuted topics.

Fixes part of #24243
2023-04-24 11:27:53 -07:00
Lalit 2d118f098a compose: Fix opening stream picker by triggering click event.
We should trigger click event to open up the dropdown popup instead of using
`.dropdown("toggle")` because we want to clear the search state when opening up
the popup and the logic for that is registered in `on-click` handler defined in
`dropdown_list_widget`.

Fixes: #25218
2023-04-24 11:26:28 -07:00
Joelute 9192098326 unread_banner: Group all unread banners up into a folder.
Since we currently have 3 unread banners, it'd be much preferred to group
all of them up into one folder to keep them organized like how compose
banners are. This way, it's much easier to keep track of unread banners
and new ones in the future.
2023-04-24 11:20:17 -07:00
Joelute e999518d9a user_settings: Add option to only read messages on scroll in topic.
After merging #24309, we want to add an additional option to the "mark
messages as read on scroll" setting where we only mark messages as read
on scroll in conversation views.
2023-04-24 11:20:17 -07:00
Deekshith S Shetty 596abf6190 popovers: Add Copied! tooltip when `copy code` button is clicked.
`copy code` button now show a `Copied!` tooltip when clicked.
It implements a similar function used on `saved as draft` notice.

We need to modify the copy_code_button template to limit
data-tippy-trigger to not include click; otherwise, repeated clicks to
copy code will incorrectly also display the "Copy code" tooltip
alternating with "Copied".

Fixes part of #21036.
2023-04-24 11:10:19 -07:00
Lakshay Mittal f84de2212e notifications: Fix blank notification sent when no text specified.
When we send a message (for which notifications are enabled)
in format `[](file_url)`. A blank notification is sent.

Fixing this by checking if there is no text and adding
message  in that case.

Inspired from: #8796.
Fixes: #8087.
2023-04-24 10:37:23 -07:00
Aman Agrawal a90fa79bfc hotkey: Clear message sent success banners too on escape keypress.
Without this, if there was a success compose banner and user pressed
escape key, no banners were hidden and the same behaviour was repeated
without compose ever closing.
2023-04-24 10:19:19 -07:00
Joseph Ho 942cfa7118
narrow: Explicitly resume the reading state when `narrow.deactivate`.
Previously, when a user marks messages as unread in the all messages view
then enters another view and finally back to the all messages view, they'd
notice that the reading state in all messages view is still paused. 

This happened uniquely for "All messages" because we only resumed the "reading"
state in `narrow.activate` (and generally that would generate a new MessageList anyway); 
but `message_lists.home` is a singleton, so the "no longer reading" state would remain
attached to that object forever.

Fix this by explicitly resuming the reading state when we enter all messages
view/message_lists via narrow.deactivate.
2023-04-24 09:56:04 -07:00
Hardik Dharmani af24279aea
recent_conversation: Fix mute icon tooltip on focus.
Set data-tippy-trigger="mouseenter" on mute icon in recent
conversation to prevent tippy from staying on when the mute icon
is focused after clicking it. (The Tippy default is "mouseenter focus").
2023-04-24 09:52:31 -07:00
Daniil Fadeev 43669a83d8 timerender: Fix expiration date on invite modal. 2023-04-24 09:50:20 -07:00
Tim Abbott dee3d7a172 user_topics: Rerender unmuted topics in Recent conversations.
Rename get_muted_topics to `get_user_topics_for_visibility_policy()`,
since it works for both muting and unmuting.

Additionally, inline rerender_for_muted_topic, as well as removing
most of the logic to diff the sets of muted topics; the event is for a
single topic being changed.

Co-authored-by: Hardik Dharmani <Ddharmani99@gmail.com>
2023-04-21 16:59:21 -07:00
palashb01 6d1efdc013 unmute_topic: Support unmuted topics in all messages feed.
This commit refactors the logic of the 'all messages' view to
display messages from unmuted topics within muted streams.

Previously, we hid all messages from muted streams except mentions
by checking if the stream was muted. With this new change, we also
check for unmuted topics within muted streams using the
'is_topic_unmuted' function inside 'user_topics', which returns
'true' if the topic is unmuted. If there is any unmuted topic, we
show the messages from that topic in the 'all messages' narrow.

Live update was handled by the previous commit.

Fixes part of: #24243
2023-04-21 13:52:02 -07:00
Tim Abbott ae314a3ca9 message_list: Deduplicate stream muting live update code path.
We can dramtically simplify the stream muting live-update code path
for updating home_msg_list by observing the only thing it was doing
intentionally differently from update_muting_and_rerender is replacing
_all_items with a new version computed from from all_messages_data,
and the rest of update_muting_and_rerender can handle the live update
correctly unmodified.

This deduplication means live-update of "Unmute topic" just requires
updating the `in:home` filter logic appropriately, without any special
live update work.
2023-04-21 13:52:02 -07:00
Hardik Dharmani 1e1e18d28c left_sidebar: Prioritize unmuted topics in non-zoomed topic list.
Created a new function choose_topics that loops through the topics
and push filtered topics using should_show_topic function to items
array if not zoomed else just push all topics directly to array.

If stream is muted and not zoomed call the choose_topics function
twice, first with passing unmuted_topics and second time with passing
remaining topics. else, call it only once with topic_names.

Fixes part of #24243
2023-04-21 10:32:44 -07:00
Aman Agrawal ace3ca80a8 unread_ops: Add `unread` class to messages instead of a full rerender.
When user marks messages as unread, we used to rerender them but
that was not required since we only need to add `unread` class
to their `message_row` to achieve the same effect.
2023-04-21 09:43:24 -07:00
Tim Abbott c8f1325281 message_list: Move show_message_as_read to view layer. 2023-04-21 09:43:24 -07:00
Aman Agrawal c99c71a9a5 message_list_view: Don't mark message as read after re-render.
When selecting a previously selected message after a re-render,
we don't need to mark it as read. This caused a bug where
user cannot mark the selected message in a narrow as unread.

Also, added an additional check to only select messages if the
message is re-rendered in the currently visible message list since
you cannot select a message in a view which is not visible.
2023-04-21 09:43:24 -07:00
Sahil Batra c80807c962 compose: Fix "Shift+Tab" behavior for stream dropdown in compose box.
We now open the stream dropdown if a user presses "Shift+Tab" from
topic input in the compose box, instead of just changing the focus
to be on dropdown toggle button.
2023-04-20 16:09:55 -07:00
Tim Abbott f4dc5afe82 compose: Add brief comments documenting the modules. 2023-04-20 16:09:55 -07:00
evykassirer 0c706aeafc compose: Extract a compose_recipient module.
This helps reduce the amount of import cycles we have in the compose
code path following the migration to a fancier stream input.

`compose_closed_ui.initialize()` was moved further down in the
initialization order because it relies on the dropdown widget
to be defined.
2023-04-20 16:09:55 -07:00
evykassirer 5948671f92 compose: Improve responsiveness for compose recipient.
This allows the dropdown to display larger names, and also
overall improves the compose recipient experience on small
screens.
2023-04-20 16:09:55 -07:00
evykassirer 5ca73388c0 compose: Overflow long stream names with ellipsis in dropdown menu. 2023-04-20 16:09:55 -07:00
evykassirer 584d3c66a3 dropdown: Add ability to update items in dropdown widget.
This is needed for the compose stream dropdown widget,
which is also updated here. Now when a user is subscribed
or unsubscribed from a stream, or a stream is renamed, or
or a stream is deleted, the dropdown widget updates
accordingly. This fixes a regression of this functionality
that happened during the switch to the dropdown.
2023-04-20 16:09:55 -07:00
evykassirer 19a47a71d8 stream dropdown: Add a space after the stream icon.
This applies to several dropdowns, and matches the spacing of
the left sidebar.
2023-04-20 16:09:55 -07:00
evykassirer 02ae5818ae compose: Add privacy icons to the stream dropdown menu.
These were previously used in the input form field and
this commit removes the code that supported that and
replaces it by using existing dropdown_widget functionality
to display the icons in the compose dropdown.
2023-04-20 16:09:55 -07:00
evykassirer 8a2455a294 compose: Change stream field in composebox to be a dropdown.
Fixes #11832

This lets the user see more options than the three that appear
in the typeahead menu, and prevents them from inputting invalid
stream names.

This change replaces the input field with the dropdown, and
updates everything that referred to the classnames of the old
input field, so that they now get the data they need from the
new dropdown.
2023-04-20 16:09:55 -07:00
evykassirer 429f23fc4f click handler: Consolidate composebox-closing logic.
Previously, we stopped the composebox from closing on
in-composebox clicks by stopping propagation from the
composebox click handler. This was an issue because
we need to propagate the event to bootstrap in
situations like dropdown clicks. We can avoid closing
the composebox on in-composebox clicks by just checking
if the click is in the composebox.
2023-04-20 16:09:55 -07:00
evykassirer 32f75085cb dropdown hot key: Generalize enter behaviour for dropup as well as dropdown.
Also updated comment to more accurately represent that this isn't
only for the gear menu.
2023-04-20 16:09:55 -07:00
evykassirer 7f7845eb78 dropdown widget: Add method to replace list data.
This is a helpful prep commit for the upcoming compose
stream dropdown, which needs to change the list of
stream names when the user changes their stream subscriptions.
2023-04-20 16:09:55 -07:00
N-Shar-ma 3a64c8c0db compose: Change video call url text to "Join video call.".
Earlier it was "Click here to join video call".
2023-04-20 15:04:26 -07:00
Sahil Batra 6607db8a1c dropdown_list_widget: Fix fading transition during focus.
This commit sets the transition to "none" for the dropdown
list widget element during focus to remove a weird fade-in
effect. We have to set this to none as the existing CSS
sets transition for all button elements inside ".new-style"
div. This commit adds the CSS for select element too,
as both are using same CSS, but since there was no transition
effect for select elements before as well, we can do this
change safely.
2023-04-20 10:38:24 -07:00
Lauryn Menard e8c777a43c empty-narrow: Update banner for no starred messages.
Updates the empty narrow banner when there are no starred messages
for a more general use case. Previously, it indicated that the
user hadn't starred anything yet, which could be confusing for an
experienced user who had just cleared out their starred messages.
2023-04-20 10:37:53 -07:00
Anders Kaseorg 77a669c15c e2e-tests: Replace deprecated page.waitForTimeout.
https://pptr.dev/api/puppeteer.page.waitfortimeout
https://nodejs.org/api/timers.html#timerspromisessettimeoutdelay-value-options

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 17:45:01 -07:00
Prakhar Pratyush b366c37452 user_topics: Rename and refactor 'muted_topic_ui_row.hbs'.
This prep commit renames 'muted_topic_ui_row.hbs'
to 'user_topic_ui_row.hbs'.

This includes minor refactoring, as it is now the
template for rows with any visibility_policy,
not just MUTED.
2023-04-19 16:58:40 -07:00
Prakhar Pratyush ba3867bed6 user_topics: Rename and refactor 'get_muted_topics'.
This is a prep commit that renames 'get_muted_topics'
to 'get_user_topics_for_visibility_policy'.

The function is refactored to add support for
visibility policies other than MUTED.
2023-04-19 16:58:40 -07:00
Sahil Batra 3853a8bf20 dropdown_list_widget: Do not underline the option text on focus.
We remove the underline on the text in the options on focus as
we already have a outline which is enough to show that the option
is focussed.
2023-04-19 16:54:13 -07:00
Sahil Batra 1505fc30d6 dropdown_list_widget: Update focus outline of toggle button.
This commit updates the focus outline of toggle button to be
same as that of select element.
2023-04-19 16:54:13 -07:00
Anders Kaseorg 60d49ae4a6 eslint: Fix @typescript-eslint/prefer-nullish-coalescing.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg b280843e51 eslint: Fix @typescript-eslint/prefer-optional-chain.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 5ac9b644eb eslint: Fix @typescript-eslint/prefer-return-this-type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 079b74e67e eslint: Fix @typescript-eslint/no-unnecessary-type-arguments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg d958948f43 eslint: Fix @typescript-eslint/no-unnecessary-boolean-literal-compare.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 61b72f5117 eslint: Fix @typescript-eslint/non-nullable-type-assertion-style.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg b9a28df63c eslint: Fix @typescript-eslint/consistent-indexed-object-style.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg cd5fba24e0 eslint: Fix @typescript-eslint/consistent-generic-constructors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Anders Kaseorg 084771ce74 eslint: Fix @typescript-eslint/consistent-type-definitions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-19 16:52:39 -07:00
Lalit ccbba1acb0 dialog_widget: Refactor `AjaxRequest` type and moved it to `types.ts`.
Changes `AjaxRequest` name to more clear one `AjaxRequestHandler`,
also moved this type to `types.ts` with a comment to move it into
`channel.js` once it migrates to typescript.
2023-04-19 16:43:27 -07:00
Lalit cfa92aa60b js: Break cyclic dependency between `reload,js` and `server_events.js`.
Removes direct dependency cycle between `reload.js` and `server_events.js`
by calling `reload.add_reload_hook(cleanup_event_queue)` from `server_events`
initialize function which registers a hook to run on reloading.

Created a function `call_hooks` which loops over all the registered hooks
and executes them on performing a reload.
2023-04-19 16:42:45 -07:00
Lalit 915b6cd9e7 js: Break cyclic dependency between `admin.js` and `settings.js`.
There was a direct dependency between `admin.js` and `settings.js` which
was due to the fact that we needed to call `build_page` of both modules
in each other's `launch` function.

This is solved by lifting those `build_page` calls up from both modules to
`hashchange.js` which is the module which calls the `launch` function
of both modules.
2023-04-19 16:41:49 -07:00
Hardik Dharmani 98176ddb57 left sidebar: Improve tooltip for show_all_private_messages.
Switch to a full keyboard-shortcut advertising tippy tooltip for
show_all_private_messages in left sidebar by adding a class
`.tippy-left-sidebar-tooltip` which adds tooltip with LONG_HOVER_DELAY
and default placement right with fallback placement equal to bottom.

Fixes part of #24311.
2023-04-19 16:21:17 -07:00
Hardik Dharmani bfdd9adaa4 tooltips: Add tippy tooltips for all_messages, recent_topics, and drafts.
Added tippy tooltips for all_messages, recent_topics, and drafts
in left sidebar by adding class `.tippy-left-sidebar-tooltip`
which add tooltips with LONG_HOVER_DELAY and default placement right
with fallback placement equal to bottom.

Fixes part of #24311
2023-04-19 16:16:08 -07:00
Hardik Dharmani de6bca9fc5 tooltips: Add new tippy tooltip class for left sidebar elements.
Added new tippy tooltips class `.tippy-left-sidebar-tooltip`
which add tooltips with `delay: LONG_HOVER_DELAY`, appended to body,
and default placement right with fallback placement equal to bottom.

Fixes part of #24311
2023-04-19 16:16:07 -07:00
Hardik Dharmani a32c30e34c tooltips: Remove the title attribute for Mentions, Starred_messages.
This commit removes tooltips from the Mentions and Starred messages
as they do not advertise any keyboard shortcuts and do not provide
any additional information beyond what is already visible in the UI.

Fixes part of #24311
2023-04-19 16:15:06 -07:00
Hardik Dharmani ab70df5f44 tooltips: Change compose-send-button tooltip dynamically.
Added a tippy tooltip in `tippyjs.js` that delegates to
`#compose-send-button`. Content of tippy tooltip is changed
dynamically as per value of `user_settings.enter_sends`.
`user_settings.enter_sends` returns true if send shortcut is
`enter` and flase if shortcut is `Ctrl + Enter`.

Fixes #24619
2023-04-19 16:13:29 -07:00
Tim Abbott 262e8c8e8d events: Fix live update when deleting a starred message.
Previously, we didn't notify the starred messages code path when
processing the event that a message was deleted, resulting in the
displayed counter potentially being stale until the app is reloaded.

Fixes #25190.
2023-04-19 12:43:13 -07:00
Zixuan James Li 05a3456581 settings: Use url_template for internal names.
This replaces any "url_format_string" or "url_format" with
"url_template" for the linkifier settings, including HTML ids, template
variables, and etc.

This is not affected by any external API changes.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
Zixuan James Li 268f858f39 linkifier: Support URL templates for linkifiers.
This swaps out url_format_string from all of our APIs and replaces it
with url_template. Note that the documentation changes in the following
commits  will be squashed with this commit.

We change the "url_format" key to "url_template" for the
realm_linkifiers events in event_schema, along with updating
LinkifierDict. "url_template" is the name chosen to normalize
mixed usages of "url_format_string" and "url_format" throughout
the backend.

The markdown processor is updated to stop handling the format string
interpolation and delegate the task template expansion to the uri_template
library instead.

This change affects many test cases. We mostly just replace "%(name)s"
with "{name}", "url_format_string" with "url_template" to make sure that
they still pass. There are some test cases dedicated for testing "%"
escaping, which aren't relevant anymore and are subject to removal.
But for now we keep most of them as-is, and make sure that "%" is always
escaped since we do not use it for variable substitution any more.

Since url_format_string is not populated anymore, a migration is created
to remove this field entirely, and make url_template non-nullable since
we will always populate it. Note that it is possible to have
url_template being null after migration 0422 and before 0424, but
in practice, url_template will not be None after backfilling and the
backend now is always setting url_template.

With the removal of url_format_string, RealmFilter model will now be cleaned
with URL template checks, and the old checks for escapes are removed.

We also modified RealmFilter.clean to skip the validation when the
url_template is invalid. This avoids raising mulitple ValidationError's
when calling full_clean on a linkifier. But we might eventually want to
have a more centric approach to data validation instead of having
the same validation in both the clean method and the validator.

Fixes #23124.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
palashb01 acb4d7efa6 recent: Add support for unmuted topics within muted streams.
This commit refactors the logic of message filtering for
'Recent conversations' narrow.

Previously, we used to filter the recent conversations messages
based on the state of the stream and topic. If the stream or topic
was muted, we would avoid displaying the message. However, with
the new changes, we check if the topic is unmuted before applying
the aforementioned condition. If the topic is unmuted, we add the
message to the all 'Recent conversations' narrow.

Fixes part of: #24243
2023-04-19 10:05:48 -07:00
Aman Agrawal 5f0fa1b730 compose: Fix send later tooltip being cut by compose box container. 2023-04-19 09:43:50 -07:00
Aman Agrawal 1b89ab8095 tippy: Add a short delay to narrow to topic tooltip. 2023-04-19 09:43:50 -07:00
Joelute 938b7917d3 user_settings: Add option to not mark messages as read on scroll.
These changes introduces an new user option where it allows
users read messages and scroll through their feed without
marking those messages as read.

Fixes: #22804.
2023-04-18 18:32:02 -07:00
Joelute ffbe6e870a unread_ui: Rename functions names to offer a general clarity.
Previously, the naming of functions in unread_ui was targeted towards a
specific unread banner. This is terrible if we plan on having multiple
types of unread banners and this change aims to offer that level of clarity.
2023-04-18 18:32:02 -07:00
Joelute 82a805e286 compose: Fix incorrect preview area first/last child selectors.
Following up to #24961, it was discovered that emojis looked worse with
the new changes as the spacings became uneven with each emojis.

Debugging determined that the root cause that the selectors used
applied to __every__ first child of its parent inside the
rendered_markdown area, not just the first child of the main
container.
2023-04-18 17:41:37 -07:00
Joelute cdad925add popover: Scroll to top of long message when viewing message actions.
Previously, when a user scrolls down a long text of message and presses
the hotkey for viewing the message actions, the popover menu would continue
to open where the message actions button. Thus, the popover menu would be
cut short and sometimes off the screen. These changes will scroll the
client to the top of the message and ensure that the popover menu is
always visible.

Fixes: #23774.
2023-04-18 17:06:24 -07:00
brijsiyag 0c30acbe39 streams: Fix notice appears even when the panel is not empty.
This fixes regression in 55bd3220b6,
Where notice gets rendered even when there are streams shown in panel.
Now the check var to render message conditionally checks for both
`subscribed` and `all streams` tabs. We are avoiding the fully use of DOM
in this context because if the filter results in no stream, then also
it will display a notice. Also this commits swaps order of calling
`stream_data.delete_sub()` and `stream_settings_ui.remove_stream()`
functions in server_events_dispatch because `update_empty_left_panel_message`
uses stream_data, which was giving outdated data.
2023-04-18 17:02:01 -07:00
brijsiyag 5cef364c74 upload: Open compose immediately on file drop or paste event.
This commit changes the way compose box responds to a file drop or paste.
Currently, the compose box expands only after the file is uploaded to the
server, which can cause confusion if the upload fails and there is also no
progress bar. With the update, the compose box will expand immediately upon
drop or paste events showing the status of upload. Also it was opening
the stream compose box even if we are in a direct message, now it starts
a reply.

Fixes #24654.
2023-04-18 16:37:56 -07:00
palashb01 3ad5e7dfc0 tippy: Prevent second appearance of tooltips for recipient bar icons.
There are four icons in the recipient bar that have tooltips, and
each of them shows a second appearance if we click on a button of
the topic menu that is just over the area of the icon. To prevent
the second tooltip, we have used the
'hide_tooltip_if_reference_removed' function to observe changes in
the DOM and hide the tooltip if the reference is removed.
2023-04-18 10:03:09 -07:00
Palash Baderia 054098fa01 tippy: Prevent appearance of second `view_user_card` tooltip.
With the recent migration of the topic_menu popover to Tippy,
some tooltips have been impacted. If we click on a popover menu
and then click on any button where the area is above the tooltip
icon, two tooltips appear. The first one is expected to appear over
the reference element, but the second tooltip appears on the top
left corner of the screen because the associated reference element
is hidden.

This commit fixes this issue for the view_user_card tooltip with
the help of the 'hide_tooltip_if_reference_removed' function.
We have set the attributes config to be 'true', since when the
tooltip appears, the parent div with classname
'message_row include_sender' is added with the value
'sender_name_hovered' in its className. We just need to observe
this classname change to hide the tooltip.
2023-04-18 10:03:09 -07:00
Sahil Batra 41f17bf392 popovers: Fix showing resolve topic option in sidebar popover.
We previously showed "Mark as unresolved" or "Mark as resolved"
option in topic sidebar popover only is user was allowed to
move messages between streams. This commit fixes it to show
if user is allow to move within stream, or in other words edit
the topic, since resolving or unresolving topics is essentially
topic ediitng only.

Note that we still cannot show or hide the option as per the time
limit setting (since client may not have the first message of the
topic locally), so we just show or hide it as per
move_messages_within_stream_policy setting.
2023-04-18 09:01:39 -07:00
Sahil Batra 8874328b87 stream_popover: Add "Rename topic" option in topic sidebar popover.
This commit adds "Rename topic" option in topic sidebar popover
which will be shown when user is only allowed to edit topics and
not streams.

Note that we still cannot show or hide the option as per the time
limit setting (since client may not have the first message of the
topic locally), so we just show or hide it as per
move_messages_within_stream_policy setting.

Fixes #19886.
2023-04-18 09:01:39 -07:00
Sahil Batra 0b608d7952 message_edit: Add buffer when checking time to disable move message inputs.
This commit adds 5 seconds buffer when checking the permission to edit
stream and topic for disabling the inputs in "Move message" and
"Move topic" modal.

We already do this for the message content edit UI.
2023-04-18 09:01:39 -07:00
Aman Agrawal d3dc26cbad header: Improve dropdown click handler.
Minor tweaks that make sense to do.
2023-04-18 08:54:55 -07:00
Aman Agrawal 2553858c91 portico-header: Fix navbar user dropdown not working.
As part of #24678, this code was accidentally removed. We just
add it back to fix the broken user profile dropdown in the navbar
of non corporate pages.
2023-04-18 08:54:55 -07:00
Sahil Batra c27ff12b8c user_groups: Update ID of overlay container element.
This commit renames ID of the container element of group
settings overlay to group_overlay_container. We also
rename the variables used for this element. This makes
it consistent with the container element of settings overlay.
2023-04-18 08:53:08 -07:00
Sahil Batra a5580264eb stream_settings: Update ID of overlay container element.
This commit renames ID of the container element of stream
settings overlay to streams_overlay_container. This makes
it consistent with the container element of settings overlay.
2023-04-18 08:53:08 -07:00
Tim Abbott c995e48e11 recent: Clarify recenter_focus_if_off_screen.
The previous name suggested it did something unconditionally.
2023-04-17 19:10:42 -07:00
Lakshay Mittal ce578423f8 popovers: Hide popovers during scroll in recent_conversations.
Previously, popovers scrolled oddly along with the content in the
Recent Conversations tab; copy our approach in the message feed of
closing them on scroll.
2023-04-17 19:10:42 -07:00
Aman Agrawal 5b71acf21b message_list_view: Change date of sticky header more carefully.
If the sticky recipient bar hides the date separator completely,
the recipient bar needs to show the correct date for the message
next to it, otherwise the user will see the wrong date for the
message.

To fix this, we show the date on the date separator as soon as
the sticky message header starts to overlap with the date separator.
2023-04-17 18:51:00 -07:00
Ishaan Singh 96b051bec4 left_sidebar: Fix 'more topics' view scroll position.
This is a preparatory work for #24360.

'DIRECT MESSAGES' are completely collapsed in the 'more topics' view.

Clicking on 'DIRECT MESSAGES' exits the 'more topics' view and
scrolls to it from that state. One wouldn't be able to open
'DIRECT MESSAGES' without leaving the 'more topics' view.

Fixes: #25035.

Signed-off-by: Ishaan Singh <asishaan.191cs124@nitk.edu.in>
2023-04-17 17:40:35 -07:00
Sahil Batra 2700ad7903 typeahead: Show stream privacy icons in typeahead options.
We now show the stream privacy icons along with their names
in the typeahead options.
2023-04-17 17:19:11 -07:00
Sahil Batra 0676629008 dropdown_list_widget: Show stream icon in the button.
We now show the stream privacy type icon for the option
selected in dropdown list widget.

This commit also includes a minor CSS change to make the
web-public better aligned in the dropdown list widget
"Move topic" and "Move message" modal. There is no visible
change for other pages and other icons due to this CSS
change.

Fixes part of #22355.
2023-04-17 17:19:11 -07:00
Hardik Dharmani 82bf1ba58a shortcuts: Update `Shift + M` shortcut to work for unmute topics too.
Renamed toggle_topic_mute function to toggle_topic_visibility_policy.

In toggle_topic_visibility_policy function if topic is either muted or
unmuted it will set the topic's visibility_policy to Inherit else, if
stream is muted or unmuted topic's visibility_policy will be set to
unmuted and muted respectively.

Updated set_user_topic_visibility_policy to only show feedback widget
in case of muting topics with hotkey.

Fixes #25125
2023-04-17 17:16:28 -07:00
Aman Agrawal 043d54d170 scheduled_messages: Add overlay to display and edit them.
Fixes #20971
2023-04-17 16:59:25 -07:00
Aman Agrawal ff52187289 compose: Add UI to schedule messages.
Fixes #20971
2023-04-17 16:59:25 -07:00
Palash Baderia a4a8fd7bf3 typo: Remove duplicate word in comment. 2023-04-17 15:42:21 -07:00
Aman Agrawal fbb2967ff0 message_body: Remove link from message time when locally echoed.
Fixes #25069

Since the locally echoed link of message doesn't work, it is
better to remove it.
2023-04-17 12:19:20 -07:00
Aman Agrawal 2c83efc6b4 message_row: Rename `local` class to be more verbose. 2023-04-17 12:19:20 -07:00
Aman Agrawal 7bd66891f0 css: Add background color for date row.
The logic to avoid first unread message with a date row to not
have an unread marker works purely based on `z-index` and seems
to be working nicely.

This avoids a bug where the background color of the date row
of the first unread message is different from others.
2023-04-17 12:12:41 -07:00
Sahil Batra 8293bbea28 message_edit: Show modal if user cannot resolve topics.
We show a modal if user is not allowed to resolve or unresolve
topics due to time limit. The modal just contains the text
mentioning user cannot resolve topic without stating the
count of messages that are within the time limit as we do
not recommend partial resolving of topics.

This commit does not include any changes for resolving or
unresolving topic using "Move topic" or "Move message" modals,
as we will still consider them as simple topic move and show
the same modal that is shown in general for moving message.
2023-04-17 11:25:28 -07:00
Aman Agrawal a941545523 drafts: Add abstract classes for messages in an overlay.
This will help up achieve 2 things:

* Have a lot of common CSS for drafts and scheduled messages.
* Have common JS for things like keyboard navigation between drafts
  and scheduled messages.
2023-04-14 17:38:37 -07:00
Aman Agrawal c8878ed6a5 drafts: Use new tooltip design to show keyboard shortcuts. 2023-04-14 17:38:37 -07:00
Joelute 5d69a54849 time_picker: Reduce increment of minutes to one.
After some discussions in CZO, it was decided that we should reduce the
increment of minutes to one because the up/down arrow isn't very helpful
at all. Most of the time, users would manual type their desired time and
micro adjust with the arrow keys if needed.

This change also solves the issue where the time picker only counts
multiples of 5s as valid time as it was tied to the increment of minutes.
2023-04-14 11:02:10 -07:00
Hardik Dharmani d7d3126f80 settings: Use `place_caret_at_end` for New Email input field.
Used updated `place_caret_at_end` function from ui_utils to focus
`New Email` input field and place the cursor at end on modal render.
2023-04-14 10:59:42 -07:00
Hardik Dharmani 17ae99f436 ui_util: Update `place_caret_at_end` to also work for input fields.
Previously, `place_caret_at_end` was only used for HTMLElement with
contenteditable="true", updated it so it takes HTMLElement as
argument and use logic to place cursor at end as per type of
element passed(i.e HTMLElement or HTMLInputElement).
2023-04-14 10:59:42 -07:00
sbansal1999 f0ef0f7157 tooltip: Change placement of tooltip according to the popover menu.
This commits changes the placement of "Add streams" tooltip
and "Filter streams" tooltip to "bottom" when the
"Add streams" popover menu is opened and changes its back
to "top" when the popover menu is closed.

It makes use of the "id" attribute that has been assigned
to those tooltips in commit 01e6121e5a.

Fixes: #20675.
2023-04-13 16:46:15 -07:00
sbansal1999 2cf9e354c0 tooltip: Append tooltips to "document.body".
This commit appends the "Add streams" and "Filter streams"
tooltip to "document.body". It was required to make sure
the tooltip appears at the top when space in
"Direct Messages" section was not enough (when only 1 Direct
Message was present).

This commit also removes the "tippy-zulip-tooltip" class
from tooltips or else the tooltips would have shown their
default behaviour.
2023-04-13 16:46:15 -07:00
sbansal1999 44ffc9c9ca tooltip: Add id attribute to "Add streams" and "Filter streams" tooltip.
This commits adds an "id" attribute to the "Add streams" and
"Filter streams" tooltip. "Add streams" tooltip has been given
the id "add_streams_tooltip" and the "Filter streams" tooltip
has been given the id "filter_streams_tooltip".

This has been done to get access of these tooltips later.
2023-04-13 16:46:15 -07:00
sbansal1999 be9fbff5cd tippyjs: Combine "delegate" functions with same functionality.
This commits combines two different "delegate" functions that
provide identical functionality by combining values of the
"target" array in the function.
2023-04-13 16:46:15 -07:00
Mateusz Mandera ef42065cec billing: Allow exempt_from_license_number_check any number of licenses.
exempt_from_license_number_check was initially added allowing
organizations with it enabled to invite new users above their number of
licenses.

However, an organization with this permission enabled,
cannot upgrade if they weren't on a plan already - because when choosing
Manual license management, you cannot enter a number of licenses lower
than the current seat count. However, an organization like that probably
already has some users that they get free of charge - and thus they need
to be able to enter a lower number of licenses in order to upgrade.
2023-04-13 15:26:44 -07:00
Alex Vandiver 2d5c678614 blueslip: Only show in dev mode, or report to Sentry.
This removes the production reporting to `/json/report/error` upon
`blueslip.error`, and replaces it with reporting to Sentry, if
enabled.  Sentry provides better reporting and grouping for exceptions
than the email- and `#errors`-reporting provided by the
`/json/report/error` endpoint.

The development behaviour of rendering `blueslip.error` messages and
stacktraces immediately, and stopping execution, is preserved.

To better chain exception information, the whole previous exception is
passed to `blueslip.error`, not just the stack, and the second
parameter is formalized to be an object to map to Sentry's "context"
concept.
2023-04-13 14:59:58 -07:00
Alex Vandiver 7152278463 blueslip: Remove unused blueslip.timings store.
This was a write-only store which was never accessed.
2023-04-13 14:59:58 -07:00
Alex Vandiver 6882ec8087 blueslip: Remove unused preview_node.
It is unused, and an XSS waiting to happen if misused.
2023-04-13 14:59:58 -07:00
Alex Vandiver 52c4cae239 blueslip: Remove unused ui_message / show_ui_msg codepath.
This was last used in 71e14674aa, a decade ago.
2023-04-13 14:59:58 -07:00
Alex Vandiver 1833afee6a js: Enable cross-origin error debugging with crossorigin="anonymous".
If the script comes from a different origin than the requesting page,
and is not marked `crossorigin="anonymous"`, the `window.onerror`
handler receives no information other than "Script error." in the
event of a runtime error.

This effectively silences blueslip errors in development if the user
is developing on a remote host (such as a DigitalOcean droplet), since
static resources are served from `hostname.zulipdev.org`, and the
realm is served from `realmname.hostname.zulipdev.org`.  It also
silenced blueslip reporting in production for any non-default (non-"")
realms.  Sentry reporting, Vagrant developments, and truly ancient or
insecure browsers were unaffected.

Add the necessary `crossorigin="anonymous"` attribute to the
`<script>` tag to allow blueslip access to this error information.
2023-04-13 14:59:58 -07:00