Commit Graph

8972 Commits

Author SHA1 Message Date
Ganesh Pawar f4dac2dd77 minor: Pass the error function to channel call in with_first_message_id.
We accidentally passed `error_cb` to the `get` function when it should
have been `error`.
2021-12-02 14:02:27 -08:00
Ganesh Pawar 4ccaff6e32 modal: Hide, instead of empty, the dialog error element.
Consider a modal with an error element displayed. When a user clicks
the submit button, the current behaviour is to empty the element. This
empties the inner HTML of the error element, but the CSS makes it still
visible, just empty. This looks bad. To avoid this, we hide the element.
We use the `ui_report` module to display errors, which adds the `show`
class to the error element every time an error is to be displayed. This
makes sure that the error element isn't hidden when the user re-clicks
the submit button while the modal is still open.
2021-12-02 14:02:27 -08:00
Aman Agrawal a91fac75ce narrow: Check if narrow is spectator compatible before activation. 2021-12-02 09:44:00 -08:00
Aman Agrawal 0254187771 hotkey: Disable message interaction for spectators with keyboard. 2021-12-02 09:44:00 -08:00
Aman Agrawal b72a9c1261 reactions: Don't create local echo for reactions at a common point.
update_ui_and_send_reaction_ajax is called from hotkeys, popovers,
reaction clicks, etc. but it is the common point to deny
spectator from creating a reaction local echo.
2021-12-02 09:44:00 -08:00
Tim Abbott 9875c9be1b stream_data: Fix web_public option defintion being development only.
The availability of this option is now controlled by fancier logic in
stream_settings_ui.js, but we neglected to remove this
development_environment guard when doing so, resulting in stream
creation being broken in production environments (because the
JavaScript code depended on this value being available).
2021-12-01 14:08:16 -08:00
Sahil Batra 988e9d2abc stream_create: Select the first enabled choice by default.
We select the first enabled radio button by default instead
of selecting "Public" because there can be case when a user
is allowed to create a private-stream only and the other
options are disabled in that case after some recent changes.
2021-12-01 13:01:19 -08:00
Sahil Batra 969bb2bf76 events: Live update stream-privacy choices on changing enable_spectator_access. 2021-12-01 13:01:19 -08:00
Sahil Batra a2ebb92649 settings: Add live-update code for updating stream privacy choices.
This commit adds code for live-updaing the stream-privacy choices
in stream creation form and privacy change modal on changing
"create_public_stream_policy", "create_private_stream_policy"
and "create_web_public_stream_policy".
2021-12-01 13:01:19 -08:00
Sahil Batra 17a955bf1e server_events_dispatch: Add create_web_public_stream_policy to realm_settings object. 2021-12-01 13:01:19 -08:00
Sahil Batra 0986141a5e stream_settings: Refactor code to disable private stream privacy option.
This commit renames disable_private_stream_privacy_option to
update_private_stream_privacy_option_state and also refactors
the code such that it can also be used to enable the option along
with disabling the option in further commit.
2021-12-01 13:01:19 -08:00
Sahil Batra 8778e5039b stream_settings: Refactor code to disable public stream privacy option.
This commit renames disable_public_stream_privacy_option to
update_public_stream_privacy_option_state and also refactors
the code such that it can also be used to enable the option along
with disabling the option in further commit.
2021-12-01 13:01:19 -08:00
Sahil Batra 8a3a5f9c19 stream_settings: Refactor code to hide or disable the web-public privacy option.
This commit renames hide_or_disable_web_public_stream_privacy_option to
update_web_public_stream_privacy_option_state and also refactors the code
such that it can also be used to enable or show the option along with disabling
and hiding the option in further commit.
2021-12-01 13:01:19 -08:00
Sahil Batra 15cf972a8e stream_settings: Split code for disabling the stream-privacy choices.
This commit splits the hide_or_disable_stream_privacy_options_if_required
function into three separate functions for public, private and web-public
streams. This is a prep commit for live-updating the stream-privacy choices
on changing the realm setting.
2021-12-01 13:01:19 -08:00
Sahil Batra b23df8dc9b popovers: Add "Manage this user" option to user info popover.
This commit adds "Manage this user" option in the user-info popover
which simply opens the administrative user-info modal.

We show a spinner on submit button in this case as modal
is not closed immediately and thus we need some indicator
to show that the task is in progress. There is no spinner
on submit button in the modal opened from "Users" section
of organization settings.

Error handling for this case is different than when the
modal is opened from "Users" section of organization
settings because there is no overlay in the background
of modal in this case.

In this case, we show error inside the modal and do not
close it and in case the change is completed successfully
we just close the modal without showing any message.

Fixes part of #18944.
2021-12-01 12:13:06 -08:00
Sahil Batra 2836879767 settings: Extract code for opening user-info edit modal into a function. 2021-12-01 12:13:06 -08:00
Sahil Batra 2c70302e19 settings: Change heading of modal used to edit user info.
This commit changes the heading of modal used by admins to
edit user info to "Manage user".
2021-12-01 12:13:06 -08:00
Anders Kaseorg a030aa5252 drafts: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-12-01 12:12:29 -08:00
YashRE42 be76d7592a reload: Manually save draft and preserve id when triggering reload.
We received a complaint about the generation of multiple duplicate
drafts for a single message. It was discovered that the likely cause
of this was how we were handling clients that were frequently
suspending/unsuspending, we would initiate a reload when we discovered
this, and expect the `beforeunload` handler to save the draft. This
behaved correctly, however, we would also save the compose state and
fill it in via `preserve_state` in reload.js. The important detail
here is that `preserve_state` would not encode and preserve the
`draft_id` for the current message, partly because it had no way of
knowing the `draft_id` of the draft... since we have not saved it yet,
the `beforeunload` event happens after `preserve_state`. As such,
performing any action that would trigger a draft to be saved, eg
pressing Esc to close the compose box, would save a duplicate draft of
the same message.

To resolve the above bug, we (1) ensure that we call
`drafts.update_draft()` in `preserve_state`, this returns a draft_id
to us, which we (2) ensure that we encode as part of the url and (3)
set on the `#composebox-textarea` as a `draft-id` data attribute,
which we check the next time we try to save the draft, post reload.

Note that this causes us to save the draft twice, once from
preserve_state and then again from the `beforeunload` handler, but we
do not add two drafts since the second update_draft call just edits
the timestamp because it finds the `draft-id` data attribute on the
`#composebox-textarea` set by the first call.
2021-12-01 12:03:20 -08:00
YashRE42 3e853d6f8f drafts: Don't notify if contents of draft have not been changed.
Previously, opening a draft and closing it without changing the
content would cause us to show the "saved as draft" tooltip. This was
annoying and would cause annoying UX after fixing a bug related to
saving drafts when reloading, as such, this commit removes the above
behaviour by introducing a simple check on whether the draft contents
are edited.
2021-12-01 12:03:17 -08:00
YashRE42 c8f18f8ae7 drafts: Extract maybe_notify function in update_draft.
This is a prep commit for adding node test coverage to
drafts.update_draft().
2021-12-01 11:54:33 -08:00
YashRE42 555f80c34b compose_actions: Add comment about spread syntax overwrite behavior. 2021-12-01 11:29:37 -08:00
Ganesh Pawar f760850993 login_to_access_modal: Migrate modal to Micromodal. 2021-11-30 14:39:46 -08:00
akshatdalton 76afb31196 filter: Show typeahead suggestions if search query has search filters.
In message header search bar, users didn't use to get any typeahead
suggestions if a normal filter follows search filter.

E.g.: query => foo bar stream:D

In the above case, users didn't use to get any typeahead suggestions.
This was because we had set that the callers of 'parse' function can
assume that the 'search' operator is present in the last in the query.
Because of which `get_search_result` function (in search_suggestion.js)
didn't use to show any typeahead suggestions as it used to assume that
the latest typed query is for search filters.

Fixes part of #19435.
2021-11-29 16:20:29 -08:00
akshatdalton 275171b592 filter: Add `maybe_add_search_terms` function to add search_term.
This function adds search_term to the operators list.
This logic is extracted as a prep commit for the
changes related to #19435.
2021-11-29 16:20:29 -08:00
Aman Agrawal 0fece515f2 hash_util: Remove dependency on narrow_state module.
We directly pass operators to remove dependency on narrow_state
module. This avoids a circular dependency of `filter` module
which is evident on the `/devtools/integrations/` page.
2021-11-29 13:30:18 -08:00
Sahil Batra c20f5a9866 dialog_widget: Add a new optional parameter validate_input.
This commit extends dialog_widget class by adding a new
optional paramter validate_input which will be a function
to validate the inputs in the dialog and will be called
before showing the spinner and calling the on_click function.

Currently, the password change modal uses this paramter to
validate that the old and new password inputs must not be
empty. Since the spinner will not be initiated in the case
where form is invalid, we need not hide the spinner after
showing the error and thus we can simplify the code to use
ui_report.error to show the error messages of empty fields.
2021-11-29 13:28:52 -08:00
Tim Abbott 23558ebd39 compose: Add missing translation tag to quoting placeholder. 2021-11-28 07:00:46 -08:00
Tim Abbott 8d1013acdb compose: Rewrite quote-and-reply cursor positioning logic.
This fixes unexpected cursor repositioning behavior when the cursor was
positioned before or inside the "Quoting..." element.

The comments document the new logic, but roughly we aim to just
preserve the logical position of your cursor after replacing the
placeholder.

We also factor out a shared variable for the "Quoting..." string which
will allow us to tag it for translation in a future commit.
2021-11-28 07:00:46 -08:00
Tim Abbott 25c9b05bd0 compose: Fix cursor position loss in quote-and-reply.
If you used "Quote and reply" to start composing a message, and
started typing before receiving the original message body from the
server, we ended up resetting your cursor to the start of the line
after the quote for two reasons:

* We were incorrectly fetching the pre_cursor for our replacement
  operation before doing the server fetch, which meant we ignored any
  editing done while waiting for the server to respond.

* Worse, we actually fetched the original cursor position before
  inserting the "[Quoting...]" placeholder text. So we were guaranteed
  to have at least some amount of error in the cursor position.

Fixes #20379.
2021-11-28 07:00:46 -08:00
YashRE42 089fdc4d94 narrow: Call reset_ui_state at start of narrowing process.
Continuing the efforts to reduce dom trashing from the previous
commits, here we remove the third forced reflow by reordering the call
to $(".top-messages-logo").show() via narrow.reset_ui_state(), such
that it happens before the other DOM writes in
recent_topics_ui.hide().

Tweaked by tabbott to avoid adding an unnecessary if/else statement
around recent_topics_ui.hide.
2021-11-27 20:18:32 -08:00
YashRE42 09d4d5b321 narrow: Extract reset_ui_state function.
This is a prep commit towards pushing the reset_ui_state calls upwards
into recent_topics_ui, in order to prevent a forced reflow. One side
effect of this change is that we add a call to
`narrow_banner.hide_empty_narrow_message()` from `narrow.activate()`.

This likely has no visible effect, in that the message list rendering
process would end up setting the narrow_banner state correctly, but
logically it could in the future avoid a banner from a stale banner
incorrectly appearing before we've rendered the current view.
2021-11-27 20:16:42 -08:00
YashRE42 0624f43633 refactor: Reorder ui state reset calls in narrow.deactivate().
This is a prep commit towards extracting a reset_ui_state function
which we can call from here, narrow.activate(), recent_topics.show()
and recent_topics.hide().
We want that function because it will enables us to prevent a forced
reflow when navigating from recent_topics to stream: xyz.
2021-11-27 17:29:11 -08:00
YashRE42 765514acb8 recent_topics: Show message list underpadding before container.
Going through the description of commit
a150b9b0ae is highly recommended since
this is a related issue.

We had received a complaint on chat.zulip.org about navigation with
the keyboard `n` key being significantly slow (~5 seconds), the first
time `n` was pressed when starting from the recent topics view.

It was difficult to reproduce the amount of lag that was reported, but
running chrome with the profile tab set to 4x slowdown helped get
close to it.

Based on profiling from the original report, as well as locally with
chrome set to 4x slowdown, led to the realisation that recent topics
to stream navigation involved a lot of dom thrashing, and so this
series of commits aims to prevent this path from causing forced
reflows.

In this commit, we reorder the calls to $(...).show() in
recent_topics_ui.hide(), this prevents the first reflow in this path,
most likely because displaying message_feed_container before
message_view_header_underpadding was guaranteed to cause style
recalculations since the underpadding is visually above the message
container.

This causes a net 60 ms decrease in the first renarrow, an ~ 70 ms
increase in the second renarrow and an ~ 5 ms increase in the third
renarrow but, more importantly, it eliminates one reflow and sets on a
path where we can achieve strong gains in subsequent commits.
2021-11-27 17:17:27 -08:00
YashRE42 5360c7d3e8 narrow: Include time for recent_topics related actions in narrow_time. 2021-11-27 17:16:52 -08:00
Aman Agrawal 64020c2358 hash_util: Encode url component derived from browser.
This is for security reasons.
2021-11-27 16:57:14 -08:00
Sahil Batra aebbbcd03d settings: Show error in change password modal if input is empty.
We show "Please enter your password" error inside the modal
if the "Old password" input is empty and "Please choose a new
password" error if the "New password" input is empty and do
not send a request to server.

Fixes #19901.
2021-11-26 22:07:50 -08:00
Sahil Batra 4e43239825 settings_account: Remove value of non-existing element.
There is no element with id as "confirm_password". This
line was added in 2ca0fb412, but there was no such element
at that point of time also.
2021-11-26 22:07:50 -08:00
Sahil Batra dcd6da0351 misc: Replace "night" and "day" with "dark" and "light".
This commit replaces "night" and "day" used in the context
of themes with "dark" and "light".
2021-11-26 22:03:29 -08:00
Sahil Batra f49346892f misc: Replace "day mode" with "light theme" in comments. 2021-11-26 22:03:29 -08:00
Sahil Batra 29dcbbb548 frontend: Rename "night-mode" class to "dark-theme". 2021-11-26 22:03:29 -08:00
Sahil Batra 30a82e1248 zcommand: Rename enter_day_mode to switch_to_light_theme. 2021-11-26 22:03:29 -08:00
Sahil Batra c1e4dc5ccc zcommand: Rename enter_night_mode to switch_to_dark_theme. 2021-11-26 22:03:29 -08:00
Sahil Batra 0a949274e9 js: Rename night_mode.ts to dark_theme.ts. 2021-11-26 22:03:29 -08:00
Sahil Batra 88e21d0387 misc: Replace "night mode" with "dark theme" in comments. 2021-11-26 22:03:29 -08:00
juliaBichler01 eaf1fa8fb7
drafts: Fix sidebar menu not closing when clicking elsewhere on page. 2021-11-25 08:02:19 -08:00
Tim Abbott b9629d72a9 stream_data: Extend comments for can_toggle_subscription.
The previous comments were a bit simple and I wanted to add an
important detail about how deactivated streams interact with this
feature.

Fixes #20262.
2021-11-24 17:44:43 -08:00
Sahil Batra 83a9401a89 settings_data: Remove redundant check from user_can_edit_topic_of_any_message.
We already check the everyone case in user_has_permission so there is no
need to check it in user_can_edit_topic_of_any_message.
2021-11-24 10:37:51 -08:00
Sahil Batra 8411c6eb21 settings_data: Move checks for nobody and owners_only case to user_has_permission. 2021-11-24 10:37:51 -08:00
Aman Agrawal 1e5866b785 hashchange: Update spectator hash when hash changed internally.
replaceState / pushState update browser hash without calling
hashchange. So, we need to update state manually in those cases.
2021-11-23 15:50:06 -08:00
Aman Agrawal dabc8fa99f hashchange: Remove unused function.
We are using sethash for the same purpose now.
2021-11-23 15:50:06 -08:00
Aman Agrawal 6da34fd283 hashchange: Extract function to update spectator_old_hash. 2021-11-23 15:50:06 -08:00
Ganesh Pawar a7badd726f api_key_modal: Migrate modal to Micromodal. 2021-11-23 15:43:38 -08:00
Ganesh Pawar f5fbf5f0e0 change_password: Migrate modal to dialog_widget. 2021-11-23 15:41:54 -08:00
Anders Kaseorg f194ffbee8 compose_actions: Remove self-import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-11-23 15:21:48 -08:00
YashRE42 d1aefd4207 stream_create: Set handler on retention dropdown to show days input.
The stream creation form currently does not setup its own handler for
displaying the "N:" input when ".stream_message_retention_setting" is
changed.

Prior to e793ef7f62d280300afeeab2f4a086e99858a5a9, this form would
sometimes work as intended because stream_edit would set the handler
on this dropdown, when it was opened. However, after that commit, this
would simply never work.

Hence, in this commit, we make changes so that stream_create correctly
sets the handler on its dropdown. This causes us to repeat ourselves a
little and as such is not the cleanest solution, but this might be the
best we can do due to the complications of stream_edit opening a
modal.
2021-11-23 14:10:49 -08:00
YashRE42 6b370fee8a stream_edit: Be more specific w/ ".stream_message_retention_setting".
The stream creation form also uses the same stream_types template as
the stream privacy modal, however, it currently does not setup its own
handler for displaying the "N:" input when
".stream_message_retention_setting" is changed.

Previously, if one opened the stream creation form, then opened the
stream edit modal, and then went back to the stream creation form, the
drop down would correctly also .show() the input, because the handler
here would also target that selector. This is incorrect since we can't
always expect the stream_edit modal to be opened first, stream_create
should set up its own handlers.

Hence, as a prep commit to fixing stream_creation, and to ensure we
don't add duplicate handlers, in this commit we change all selectors
that targeted ".stream_message_retention_setting" to
"#stream_privacy_modal .stream_message_retention_setting" in this
file.
2021-11-23 14:10:49 -08:00
Sahil Batra 5607712794 stream_settings: Disable stream-privacy choices according to org settings.
The public and private stream choices in stream creation form are disabled
according to create_public_stream_policy and create_private_stream_policy
settings. It is not needed to disable them in stream privacy modal since
only admins can change the privacy of stream and they are allowed to
create public and private streams always irrespective of the setting.
2021-11-23 13:48:58 -08:00
Sahil Batra 25ba96488d settings: Add frontend part for create_web_public_stream_policy.
This commit has the following changes -

- Adds dropdown for changing create_web_public_stream_policy and this
dropdown is visible only if settings.WEB_PUBLIC_STREAMS_ENABLED and
enable_spectator_access is set to True. This dropdown is live-udpated
on changing enable_spectator_access setting.

- The web-public stream option in stream creation form and stream privacy
modal is hidden if one of settings.WEB_PUBLIC_STREAMS_ENABLED or
enable_spectator_access is set to False except in stream privacy modal
when the stream is already web-public so that the user is not confused by
none of the options being selected.

- We disable the web-public stream option in stream creation form and
in stream-privacy modals of stream which are not already web-public
when the user is not allowed to create web-public streams as per
create_web_public_stream_policy setting.

- We use on_show parameter to hide or disable the options in stream-privacy
modal because we use the visible property of element to remove the bottom
border from last element in the stream-privacy choices and thus we have
to wait for the modal to be visible.

Fixes #20287.  Fixes #20296.
2021-11-23 13:48:43 -08:00
Sahil Batra 443d8b6a65 settings: Add user_can_create_web_public_streams function.
This commit adds user_can_create_web_public_streams function
in settings_data.js which will be used in further commits
to disable or hide the UI elements for creating web-public
streams.
2021-11-23 10:48:20 -08:00
Sahil Batra 828927b724 server_events_dispatch: Remove unnecessary 'realm_' prefix.
We do not have 'realm_' prefix to the settings used as keys
in realm_settings object, we directly use the setting name.

This commit removes the 'realm_' prefix from enable_spectator_access
setting.
2021-11-23 10:48:20 -08:00
Aman Agrawal 2b8aa5ce2d compose: Add formatting buttons to bottom of compose box.
This is a very frequently requested feature for organizations that are
new to Markdown, that brings Zulip's UI more in line with that of
competing projects and other markdown editors like the GitHub UI.
2021-11-22 18:44:31 -08:00
Aman Agrawal 29cdd99220 giphy: Use single element for tooltip and popover.
This works surprisingly unlike my previous attempts to do so.

WARN: This is a pseudo commit and should only be merged with upcoming
compose box bottom refactoring commit since the css changes required
for this change are missing here and are not required after that
commit.
2021-11-22 18:29:45 -08:00
Aman Agrawal 3423797efa compose: Remove drafts link.
Since we have the drafts button in top left corner and we need space
to insert formatting buttons in the bottom of compose box; removing
drafts link makes sense.
2021-11-22 18:29:45 -08:00
Aman Agrawal 9d0dded959 composebox_typeahead: Don't propagate after handling tab.
After we set focus manually to the send button, `tab` propagation
should be stopped.
2021-11-22 18:29:45 -08:00
Julia Bichler 32f206e1e5 popovers: Add sidebar menu to delete all drafts.
This provides a convenient interface to hide all drafts.

Fixes #19360.

However, we may want to continue to implement a button in the drafts
overlay as well for doing this operation.
2021-11-22 17:01:47 -08:00
Johan Ehinger 4207f0a299 settings: Add UI setting option for controlling invite expiration time.
Add a UI for controlling invititation expiration time, supported
options are 1 day, 3 days, 10 days and 30 days.

Fixes #19680.
2021-11-22 16:40:14 -08:00
Tim Abbott a7898ed305 stream_data: Rename id_is_subscribed to is_subscribed. 2021-11-22 15:44:30 -08:00
Tim Abbott 53d9797044 stream_data: Rename is_subscribed to is_subscribed_by_name.
Generally the stream_data module aims to do lookup by ID, not name,
wherever possible, so we should represent that in the function names.
2021-11-22 15:44:30 -08:00
Tim Abbott 043d83b434 unread: Lookup subscription status by ID.
We prefer to use IDs, not stream names, to do lookups wherever both
are available.
2021-11-22 15:39:58 -08:00
Tim Abbott 3f4d66109b stream_data: Rename get_invite_only helper method.
Since this library is intended to primarily work by user ID, we want
to name all methods that do lookups by stream name explicitly.
2021-11-22 15:32:14 -08:00
Aman Agrawal d9338a68d1 compose: Show globe icon for web public streams.
Fixes #20285.
2021-11-22 15:31:22 -08:00
Aman Agrawal a7b2c7f7ea recipient_row: Show globe icon for web public streams. 2021-11-22 15:26:21 -08:00
Aman Agrawal e8ec42bf8a stream_bar: Rename update_lock_icon_for_stream. 2021-11-22 15:26:21 -08:00
Ganesh Pawar 291aaf373f modal: Add support for modal event handlers. 2021-11-22 15:00:38 -08:00
Ganesh Pawar 8908ea99ec modal: Add support for linking the submit button to a form element. 2021-11-22 15:00:38 -08:00
Sahil Batra 1cdc7306c6 slash: Change description of /light command in typeahead. 2021-11-22 14:59:16 -08:00
YashRE42 717c4ae603 refactor: Remove duplication from reactions.add_clean_reaction.
In commit 3d86267041 we add logic to
`/shared/emoji.js` which duplicated some of the logic in this
function. Since this isn't desirable, we remove the duplicate logic
here and instead just call `emoji.get_emoji_details_for_rendering`.
2021-11-20 20:57:54 -08:00
YashRE42 71a4985ebc refactor: Remove duplication from reactions.view.insert_new_reaction.
In commit 3d86267041 we add logic to
`/shared/emoji.js` which duplicated some of the logic in this
function. Since this isn't desirable, we remove the duplicate logic
here and instead just call `emoji.get_emoji_details_for_rendering`.
2021-11-20 20:57:54 -08:00
YashRE42 263a79738f user_status: Fix status emoji handling of deactivated custom emoji.
Previously, if a user had a realm emoji set as their status emoji and
someone deleted the realm emoji, the app would fail to initialize,
because of the error we throw from `./shared/js/emoji.js`.

This commit fixes this by just displaying the deactivated emoji,
similar to how we do when realm_emoji used as reactions are deleted.

As part of the fix, we add a function get_emoji_details_for_rendering,
which duplicates some of the logic used in `reactions.js`, we can
refactor to remove the duplication in `reactions.js` in future
commits.

Note that the following behaviour is a part of our design:
If a user sets their emoji to a particular realm emoji, say for
example "octo-ninja", and "octo-ninja" was then deleted, and a new
emoji was added with the name "octo-ninja", the user's status emoji
would change to show the new emoji instead of the deleted emoji.

Also note that in the `user_status.js` node test, we were able to
change the name for the 991 realm_emoji because it had not been
previously used anywhere in the test (possibly added as just a copy
paste artifact?).

Fixes: #20274.

emoji: Use reaction_type parameter to analyze emoji.
2021-11-20 20:57:54 -08:00
Sahil Batra 14b91043d2 misc: Replace "Day mode" with "Light theme". 2021-11-19 11:49:59 -08:00
Sahil Batra b72035abfe misc: Replace "Light mode" with "Light theme". 2021-11-19 11:49:59 -08:00
Sahil Batra 89720c5d5a slash: Change description of /dark command in typeahead.
Fixes part of #20228.
2021-11-18 16:57:11 -08:00
Sahil Batra 5024ba98cd misc: Rename "dark mode" to "dark theme".
Fixes part of #20228.
2021-11-18 16:57:11 -08:00
Sahil Batra cf4f31291c misc: Rename "Night mode" to "Dark theme".
This commit renames "Night mode" to "Dark theme" in the
settings dropdown, help pages and api documentation.

Fixes part of #20228.
2021-11-18 16:55:35 -08:00
Sahil Batra 291f8e570d styles: Rename night_mode.css to dark_theme.css.
Fixes part of #20228.
2021-11-18 16:55:35 -08:00
Sahil Batra b61d48d94b settings: Rename "Automatic" option in color scheme dropdown.
This commit renames "Automatic" option in color scheme setting
dropdown to "Sync with compute". We do not change any variables
used in code just the text in the dropdown visible to user.

Fixes part of #20228.
2021-11-18 16:55:35 -08:00
Aman Agrawal 2a922409aa realm: Add option to enable/disable spectator login.
We restrict access of messages from web public streams if
anonymous login is disabled via `enable_spectator_access`.

Display of `Anonymous login` button is now controlled by
the value of `enable_spectator_access`.

Admins can toggle `enable_spectator_access` via org settings in UI.
2021-11-18 12:55:12 -08:00
Sahil Batra 16d35f5b4e streams: Hide fake emails in stream creation form.
We hide fake emails in "People to add" section of
stream creation form and instead show user id
along with specifying that email is hidden.
2021-11-18 12:49:10 -08:00
Ganesh Pawar e7b9173ef5 default_language: Migrate modal to dialog_widget. 2021-11-16 17:02:29 -08:00
Manan Rathi f3469ac3c8 todo_widget: Fix /todo checkboxes to match style used in menus.
Fixes #20212
2021-11-16 15:02:53 -08:00
Lauryn Menard 6046f94521 settings: Fix live `update_page` behavior for user settings.
Changes `update_page` to only update the modified user setting instead
of updating all of the user settings on the page. This is modeled on
the behavior for updates to the realm user default settings.

This is a follow up on feedback in #20070.
2021-11-10 13:03:20 -08:00
Wesley Aptekar-Cassels 151db3c9ef drafts: Increase the duration of "Saved as draft" tooltip.
Now that it's further away from the composebox, we probably want it to
be visible for longer. Doubling it from 1.5 seconds to 3 seconds seems
reasonable to start with, although we should tune it based on feedback.
2021-11-10 12:53:44 -08:00
Wesley Aptekar-Cassels fe89dee284 compose: Remove "Drafts" button.
Now that this is in the left sidebar, we can remove the now-redundant
compose area button for it.  This also changes where the "Saved as
draft" tooltip appears.
2021-11-10 12:53:44 -08:00
Wesley Aptekar-Cassels df8f0b2afe left_sidebar: Add "Drafts" item.
This currently shows the drafts as a popup. Eventually, we'll want to
migrate it to be a view in the center pane, as we did with Recent
Topics.

This uses the same style as starred messages in order to show the number
of drafts.

See CZO for more context:
https://chat.zulip.org/#narrow/stream/101-design/topic/drafts.20in.20sidebar
2021-11-10 12:53:44 -08:00
Aman Agrawal cfbed9a60c recent_topics: Re-select last selected topic.
Since the position of topic in recent topics can change, we
focus the last selected topic using the `topic_key` instead
of relying `row_focus` value which is incorrect.
2021-11-10 12:25:15 -08:00
Aman Agrawal 7f61997d09 recent_topics: Directly pass topic index instead of element.
Since the element may get re-rendered while we extract info from
it, we do it as fast as possible to avoid errors.
2021-11-10 12:25:15 -08:00
Aman Agrawal c6d74c4b67 recent_topics: Separate behaviour for scrolling and hotkeys.
When user is scrolling, we simply keep the center element in
focus.

When user is using hotkeys, we keep the focused element in
center.

When user is using keyboard, we need to always keep the
"focused" topic in visible scrolling area.

We determine if the topic row is above or below the visible
area and scroll half_height_of_visible_area so that the selected
topic is visible.

This gives a nice navigation experience for both the views.

Reduced height of recent topics table to account for
compose box so that focused element is not below compose box.
2021-11-10 12:25:15 -08:00
YashRE42 f21cee7caa upload: Return single elem for get_item(drag_drop_container) w/ edit.
Previously, opening multiple message_edits and then drag-dropping a
file into any one of them would cause all of them to upload ie you'd
get one uploaded file in each message_edit.

This bug was caused by returning multiple elements from
upload.get_item("drag_drop_container", config) when config.mode =
"edit".

This commit changes the selector to use the row provided (config.row),
and so ensures that the above bug doesn't happen.
2021-11-10 12:06:15 -08:00
Ganesh Pawar 7a505e3857 user_profile_modal: Migrate modal to Micromodal. 2021-11-10 11:04:38 -08:00
Tim Abbott f905171e78 stream_edit: Remove unused import.
This was introduced when rebasing
d62e44fcba on top of
8cc781f0c8, which removed the other use
of this module in this file.
2021-11-10 10:33:12 -08:00
Ganesh Pawar d62e44fcba stream_privacy_setting_modal: Migrate modal to dialog_widget. 2021-11-10 10:23:31 -08:00
Aman Agrawal 9af4d5a155 reminder: Don't ack server for reminder / scheduled messages. 2021-11-10 09:12:23 -08:00
Aman Agrawal 3237196687 reminder: Fix incorrect method applied on object.
The intention here is to apply `find` on the array of values
in the object.
2021-11-10 09:12:23 -08:00
Aman Agrawal 59a62573ed popover_menus: Simplify check for any active popovers. 2021-11-10 09:12:23 -08:00
isakhagg 7edbf673e4 poll: Handle duplicate poll options.
Fixes #20164.
2021-11-10 09:07:03 -08:00
Aman Agrawal a8c488bc56 compose: Use calendarContainer to check if flatpickr is open.
`calendarContainer` is defined for flatpickr instance if it is
open.

This also fixes a bug where the flatpickr doesn't open when
user tries to toggle it using the global time icon in compose.
2021-11-10 09:00:59 -08:00
Tim Abbott 4aedb129ea settings: Add comments for default settings update_page. 2021-11-09 10:05:08 -08:00
Sahil Batra f49980098d settings: Fix live update code for twenty_four_hour_time setting.
We need to handle live-update of twenty_four_hour_time setting
separately in update_page because the database value of this
setting is boolean but we use dropdown in the frontend for this
setting with option values as "true" and "false" strings.
2021-11-09 10:03:23 -08:00
Sahil Batra 4a1153b06c settings: Fix bug in "Default user settings" section.
There was no heading for "Time format" setting in the
"Default user settings" section and thus no save-discard
widget to update the setting. This commit fixes the bug
and changes the heading to be only "Time" since there is
no realm-level default of language setting.

This bug was introduced in adb612a0b4.
2021-11-09 10:03:23 -08:00
Ganesh Pawar 41ddf29e76 move_topic_to_stream: Migrate modal to dialog_widget. 2021-11-09 10:02:43 -08:00
Aman Agrawal 8c46fde342 flatpickr: Show the same picker on mobile as on desktop.
Flatpickr tries to show a different picker for mobile which
is not visible for some reason. We display the same picker
on mobile which we know works for our use case.

Docs: https://flatpickr.js.org/options/

```
Set disableMobile to true to always use the non-native picker.
By default, flatpickr utilizes native datetime widgets unless
certain options (e.g. disable) are used.
```
2021-11-09 09:40:52 -08:00
YashRE42 a150b9b0ae recent_topics: Don't rely on ":visible" to avoid forced reflow.
Previously, navigating from any stream to the recent topics view would
cause a forced reflow every time we checked `is_visible()` because it
would call `$("#recent_topics_view").is(":visible")`.

The reason for this is related to how browsers ship frames, the
process follows these steps:
JavaScript > style calculations > layout > paint > composite.
(The layout step is called Reflow in firefox.)

Typically, the browser will handle these steps in the most optimal
manner possible, delaying expensive operations until they're needed.

However, it is possible to cause the browser to perform a layout
earlier than necessary. An example of this is what we previously did:

When we call `top_left_corner.narrow_to_recent_topics()`, we ask to
add a class via `.addClass()`, this schedules a Style Recalculation,
then, when we call `message_view_header.make_message_view_header()` it
calls `recent_topics_util.is_visible()` which calls
`$("#recent_topics_view").is(":visible")`.

Before the browser can get this value, it realizes that our dom was
invalidated by `.addClass()` and so it must execute the scheduled
Style Recalculation and cause a layout.

This is called a forced synchronous layout.

This commit adds a JavaScript variable representing the visible state,
in order to prevent the above behavior.

This commit reduces the main thread run time of
`build_message_view_header` from 131.81 ms to 5.20 ms.

Unfortunately we still have the case where
`recent_topics_ui.revive_current_focus()` calls
`recent_topics_ui.set_table_focus()` which causes a reflow.

However, by eliminating this reflow we still save ~100ms.
(It's important to note that we only save this sometimes, as other
things can still cost us a reflow.)

Further reading: https://developers.google.com/web/fundamentals/
performance/rendering/avoid-large-complex-layouts-and-layout-thrashing
2021-11-08 18:30:44 -08:00
Sahil Batra e3aed119ec stream_settings: Add heading row in subscriber list. 2021-11-08 18:10:25 -08:00
Sahil Batra 2105b5eda8 settings: Add user-id column to bot list. 2021-11-08 18:10:25 -08:00
Sahil Batra 36c1a1f1ee settings: Add user-id column in active and deactivated users list. 2021-11-08 18:10:25 -08:00
Ganesh Pawar edf7c0fb5a edit_bot: Migrate modal to dialog_widget. 2021-11-08 17:34:42 -08:00
Ganesh Pawar 8cc781f0c8 change_stream_info_modal: Migrate modal to dialog_widget.
The CSS changes make the description input box a more likely size for
what currently makes sense for stream descriptions.
2021-11-08 17:27:27 -08:00
Ganesh Pawar 8c7d320422 message_edit_history: Migrate modal to dialog_widget. 2021-11-08 17:24:31 -08:00
Anders Kaseorg c732a63b2f upload_widget: Convert $e.get(0) to $e[0].
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-11-05 17:34:13 -07:00
Vishnu KS 6c06858e02 billing: Migrate to Stripe hosted checkout page. 2021-11-05 17:23:10 -07:00
Andrew McAfee 4f63378e7f settings: Add UI option for custom notification batching period.
PR #19576 added a settings option for selecting a notification batching
period. We want to extend that UI option with the ability to select
a custom period.

Tweaked by tabbott to have the natural model that picking a value
present in the dropdown live-updates to remove the custom input,
rather than only having the custom input disappear on reload.

Fixes #19713.
2021-11-05 12:21:55 -07:00
Andrew McAfee 8c7e144e47 settings: Refactor notifications update_page to use switch.
Changes suggested by timabbott: https://github.com/zulip/zulip/pull/19944#discussion_r727565978

Facilitates additional changes for issue #19713.
2021-11-05 11:49:30 -07:00
Aman Agrawal a40a5c0bdb user_info_popover: Show relevant info for spectators and hide buttons.
We add the date joined info to the popover and hide all the buttons
since none are relevant for a spectator.
2021-11-02 11:26:19 -07:00
Tim Abbott d76b4744bf popovers: Use user ID for computing medium avatar URLs. 2021-11-02 11:26:19 -07:00
Aman Agrawal eb396b6190 popovers: Don't try to fetch small avatar using email.
It's always better to use the user ID than the email for fetching data
about an object whose unique ID we have, which should be all of them.
And it's also cleaner code to use the standard people.js method; tabbott
checked that indeed all callers get their `user` objects from `people.js`.

Since we restrict spectators from having access to avatars using
email to avoid someone brute forcing a user's email, this removes
a 401 response from the server in spectator view when trying
to open user info popover.

Additionally, this fixes the cached-fetching behavior documented in
the comments we add about the way we construct URLs.
2021-11-02 11:26:19 -07:00
Aman Agrawal d6541c4724 message_fetch: For spectators, add web-public to narrow.
Without this, server will return a 401 error.
2021-11-02 11:26:19 -07:00
Sahil Batra e6106cb334 invites: Update error message when max limit for the day is reached.
This commit updates the error message returned when the maximum
invite limit for the day. We update the error returned by API to
only mention that the limit is reached and add the suggestion
to use multi-use link or contact support in the message shown
in webapp.
2021-11-01 16:36:26 -07:00
Kevin Scott 64f099d2f5 compose: Add compose box button to insert global times.
Fixes #20045.
2021-11-01 16:20:05 -07:00
Tim Abbott 862061fa53 lint: Fix JS style in last commit. 2021-11-01 11:07:01 -07:00
YashRE42 c696b78eec refactor: Extract "load_and_set_favicon" in favicon.js.
This is a prep commit to reduce duplication when implementing custom
favicons.
2021-11-01 10:54:56 -07:00
Lauryn Menard 73710e1cf0 user_settings: Add option to disable escape key navigation to default view.
Add `escape_navigates_to_default_view` as a bool setting in
UserBaseSettings model and implement it as a checkbox that toggles
the hotkey implementation of escape to the default view in the
advanced user display settings.

With /help/ documentation edits from Alya Abbott.

Fixes #20043.
2021-10-29 18:15:30 -07:00
Ganesh Pawar fce3261c30 deprecated_feature_notice: Migrate modal to dialog_widget. 2021-10-29 16:09:39 -07:00
YashRE42 47f81f6974 minor: Fix typo in narrow.js activate - "heading" was "headig". 2021-10-27 14:22:10 -07:00
Ganesh Pawar 14b07669cc dialog_widget: Add support for rendering a single footer button. 2021-10-26 18:20:17 -07:00
Ganesh Pawar c429c5d70e dialog_widget: Add support for having a custom id on the container element. 2021-10-26 18:20:17 -07:00
Ganesh Pawar 1e8bfa710e dialog_widget: Migrate modal to Micromodal.
Also removed the `danger_submit_button` config option
from the dialog_widget since it isn't needed in the new modals.
2021-10-26 18:20:17 -07:00
Ganesh Pawar 6a07a90499 dialog_widget: Remove the `fade` parameter.
A user wouldn't differentiate between a "normal" modal and a "settings"
modal. If one shows up instantly, one would expect all the others to do
the same. The difference between Bootstrap fade and non-fade is pretty
noticeable (300 ms for fading).

This is a prep commit for the Micromodal migration which will have 120ms
as the animation time which wouldn't feel slow.
2021-10-26 18:20:17 -07:00
Ganesh Pawar e6e601077f dialog_widget: Append dialog_widget to the body element.
We attach the DOM for the modal to the body element
to avoid style interference from other elements and having to choose
a separate parent element for every single dialog_widget.
2021-10-26 18:20:17 -07:00
YashRE42 0ddf319709 click_handlers: Do not close compose box when clicking inputs.
Previously, there existed a bug where clicking an open message edit
box when the compose box was open would not focus the message edit
contents, but would instead:

- focus the message edit content,
- close the compose box,
- and unfocus the message edit content.

That first bug was fixed in 4e1525d7c4
which eliminated the unfocus part of that problem, but closing the
compose box is undesirable here anyway, since often it can be useful
to have compose open while interacting with the sidebar filter widgets
or working on editing a message.
2021-10-26 18:15:30 -07:00
YashRE42 bf4945a1e2 click_handlers: Correct line reference made by comment.
Click_handler.js was created in commit
e5467d3268 by moving code from ui.js.

While making this change, some handlers were rearranged, but the part
of this comment saying "... code above" was never changed. This commit
changes that part of the comment to refer to the correct handler
(which is labeled by a comment as MAIN CLICK HANDLER).
2021-10-26 17:54:56 -07:00
Tim Abbott 4e1525d7c4 compose: Fix buggy refocusing of compose box on close.
The `make_compose_box_original_size` function is designed in such a
way that it should only be called when it actually needs to resize the
compose box. In 3 of the 4 places that called it, we checked whether
the compose was already the original size; this fixes the 4th to do
the same.
2021-10-26 17:54:56 -07:00
Ganesh Pawar 8730bd8b94 delete avatar: Improve accessibility by converting <span> to <button>.
Since it's a button, it doesn't need the "keydown" event. So,
removed it. This fixes the bug where pressing any key while the
avatar's delete_button was in focus would pop up the modal.
It was introduced in e5d0448505.
2021-10-26 17:51:38 -07:00
Ganesh Pawar fe7a1c0722 dialog_widget: Extract out `close_modal()`. 2021-10-22 16:08:26 -07:00
Ganesh Pawar e1070fe3d0 dialog_widget: Pass the event object to the `on_click` function. 2021-10-22 16:08:25 -07:00
Ganesh Pawar 3051b1afa3 dialog_widget: Use $t_html for html_heading. 2021-10-22 16:08:25 -07:00
isakhagg adb612a0b4 settings: Rearrange display settings.
This provides a cleaner organization for our display settings, to make
browsing them more intuitive for new users.

We still need to update the /help/ documentation following this migration.

Fixes #19960.
2021-10-21 15:23:19 -07:00
Jonny Tran ddf4053a73 composebox_typeahead: Remove redundant options from the `/` typeahead.
Removes the `/day` and `/night` options from the typeahead menu while
still allowing the commands to be used. Typing `/day` and `/night`
will now suggest `/light` and `/dark`, respectively. Also changes the
`Dark mode` and `Light mode` popups that appear after using the
corresponding command.

Fixes #18318.
2021-10-21 10:50:27 -07:00
rht bb8504d925 lint: Fix typos found by codespell. 2021-10-19 16:51:13 -07:00
Gaurav Pandey 1c1a1e2cad api: Remove encoding of string in update_user endpoint.
* Remove unnecessary json_validator for full_name parameter.
* Update frontend to pass the right parameter.
* Update documentation and note the change.

Fixes #18409.
2021-10-18 19:03:43 -07:00
Anders Kaseorg b36cecf33b fold_dict: Fix @typescript-eslint/member-ordering.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-10-17 07:15:09 -07:00
Pradyumna Sinha ec5ded3f2a message_edit: Reinit topic input box typeahead in message edit UI.
This fixes an issue where the auto-complete dropdown doesn't reflect
the changed stream in the message edit UI.

We add an unlisten method to the typeahead library to support this
reinitialization cleanly and in a way that can be readily reused in
the future.

Fixes #19874.
2021-10-15 17:17:09 -07:00
Anders Kaseorg cab0f9c219 people: Fix small avatar URL generation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-10-14 12:47:43 -07:00
Tim Abbott 5191c41799 message_list: Avoid losing place when sending messages.
It can be pretty annoying to lose your place when replying to an old
message, even though every other chat application does this. And it
doesn't really buy us much; the user can always scroll down if they
want to, we have a helpful notification about where their message is
(which could be improved), and then we don't need to add some sort of
new complicated logic to avoid marking messages as read unexpectedly,
which the existing logic for this block badly needed.

(It had existing logic of that form dating from the pre-unread counts
pointer era).

Fixes #11462.
2021-10-12 15:34:27 -07:00
Tim Abbott 53d9b5b307 message_list: Fix buggy failure to scroll after sending message.
The from_scroll=true setting has been present since essentially the
beginning of time (6ae117ea5f), and has
moved around a number of times since.  It's possible that it was
correct with the UI model as originally implemented, but the behavior
it creates now is that sending a message in the home view does not
move the cursor, and sending in a narrow does, without any intent
behind that behavior.

Further, the logic for controlling whether to display a "Scroll down"
notification clearly expects that this code path will actually trigger
a scroll to the current message, which would be the case without the
from_scroll setting.
2021-10-12 15:34:27 -07:00
Sahil Batra 38cf2d07a6 settings_display: Refactor code to use a single handler.
This commit refactors the display settings code to use
a single handler similar to what we do in notification
settings. We still keep default language and emojiset
setting as they are handled differently and they do
not call 'change_display_setting' directly on changing
input.

We refactor the 'change_display_setting' to directly
accept status element as parameter and not class as
a string. We also add a common class to the subsection
div such that we can get status element for each of
them easily.
2021-10-08 13:46:22 -07:00
Sahil Batra 78da9d21f3 settings: Remove unnecessary check of for_realm_settings.
We do not need to check for_realm_settings variable for
left_side_userlist handler since realm-level defaults
now uses save-discard widget and we return early in
that case and thus for_realm_settings will always be
false at this point.
2021-10-08 13:46:22 -07:00
Sahil Batra 6aa5b3be51 settings: Fix streams incorrectly appearing in notification settings.
There is a bug when a newly created stream appears in the notification
settings table if user changes any setting in 'Streams' row of the
table even though user has not changed the notification setting of
the stream and thus the stream should follow the global-level values.

The stream is correctly not added to the table if user changes the
setting after reloading once after creating the stream.

The bug is due to the notification settings of the new-stream being
set to the user's global settings at time of stream creation which
are not overridden since the stream-creation event contains only
stream fields and not subscription fields. And the newly created
stream is not present in the table after reload because during
initialization of the client-level data structures the notification
setting values are overridden by the values stored in server.

This commit fixes create_sub_from_server_data code to initially have
the notification settings set as null in the sub object which are
overridden by the correct value during initialization. This keeps
the notification setting values as null just after stream creation.

Fixes #19933.
2021-10-08 10:31:20 -07:00
Tim Abbott ed5d345aed drafts: Fix buggy "Saved as draft" notice flashing on send.
This fixes a bug introduced in
459ce92109, where "Saved as draft" would
flicker every time you send a message that was locally echoed.
2021-10-08 09:28:05 -07:00
Dinesh e2df0d171f user_settings: Add send_read_receipts setting.
This will be useful to let users enable/disable
sharing read receipts once we add that feature.

Note: Added "I've" to IGNORED_PHRASES in
tools/lib/capitalization.py to avoid capitalization
errors for the label text of this setting.
2021-10-07 17:46:05 -07:00
Dinesh b41918e74e typing_notifications: Send requests only if send_private_typing_notifications. 2021-10-07 17:40:32 -07:00
Dinesh 6d2b8f5ca9 user_settings: Add settings to configure sending typing notifications.
Note: These are not functional in enabling/disabling sending of
typing notifications with this commit.

Refactored the privacy settings update to keep the code less
duplicated along with making the addition of new settings easier.
2021-10-07 17:39:21 -07:00
Dinesh bb3953e02c Remove `$("#user_presence_enabled").val(page_params.presence_enabled);`.
This isn't necessary as `settings_checkbox.hbs` template used
for presence enabled setting in `account_settings.hbs` takes
care of checking/unchecking this checkbox.
2021-10-07 16:39:51 -07:00
Dinesh 9d3dc7426d typing_notifications: Show several users are typing if num of typists > 3.
I believe we intended to show 'several users are typing...' only
if number of typists are more than 3 but not 2.

The variable name MAX_USERS_TO_DISPLAY_NAME and commit message of
dba21d201c which added this also
suggests the same.
2021-10-07 16:32:08 -07:00
Sahil Batra 98415808ba settings: Remove patch_url from user_settings_panel.
We remove patch_url from settings_notifications.user_settings_panel
since realm-level defaults section uses save-discard widget and its
code is separate from user notification settings and we can directly
use "/json/settings" as url in user settings code.
2021-10-07 14:23:24 -07:00
Sahil Batra b626513a15 settings: Remove patch_url from realm_default_settings_panel.
We do not need patch_url field in realm_default_settings_panel
because we use save-discard widget in realm-level defaults section
which is handled separately from user display settings.
2021-10-07 14:23:24 -07:00
Sahil Batra 30766ec482 settings: Remove patch_url from user_settings_panel.
We remove patch_url from settings_display.user_settings_panel
since realm-level defaults section uses save-discard widget
and its code is separate from user display settings and we
can directly use "/json/settings" as url in user settings code.
2021-10-07 14:23:24 -07:00
Sahil Batra d9034dfda2 settings: Do not pass settings_panel parameter to change_display_setting.
We don't need container element and patch_url in change_display_setting
since this function is only used for user-display settings and not for
realm-level settings which now uses save-discard widget. So we do not
pass settings_panel as parameter to change_display_setting.
2021-10-07 14:23:24 -07:00
Sahil Batra 9bc2813138 settings: Remove language_modal_elem from user_settings_panel.
We added language_modal_elem to settings_display.user_settings_panel
object considering there would be realm-level default_language
setting and we would need to access the modal element using a
variable to avoid code duplication. But now we have decided that
we do not want the setting and we would instead use browser's
language to set the language for new user, so now we do not need
this variable and we can instead use id of the modal directly.
2021-10-07 14:23:24 -07:00
Johan Ehinger bac64070c1 invitations: Display expiration times in settings > invitations.
Fixes #19680.
2021-10-07 11:58:47 -07:00
YashRE42 f3b31fa972 message_view_header: Fix hover effect related to links in description.
This handler was broken during refactor
78d511fd03, as we can see from the
original implementation in 30065b4ee8,
the intent is that hovering over any link within the
narrow_description should not cause the search_icon to change color ie
the hover effect should not be used. This is so because it aligns
with the fact that clicking the links would not open the search bar.

However, during the refactor this was incorrectly switched to forcing
the effect to be applied when we hover over links in the
narrow_description.

This commit reverts to the original and intended behaviour, and also
switches to using opacity rather than color, in accordance with the
changes from the previous commit
(316d499ac74c2caddb57c98a43d9b776b1b32d98).
2021-10-07 10:29:08 -07:00
YashRE42 4afcd15baa message_view_header: Remove usage of nth-last-child selector.
This commit aims to remove all usage of the nth-last-child selector
related to the message_view_header, continuing the change from
65acbfa4c4.
2021-10-07 10:29:08 -07:00
Sahil Batra 89be686d9e settings: Remove unnecessary if condtions checking for_realm_settings.
This commit removes unnecessary if condtions which are checking
for_realm_settings value which are basically present to handle
the code which is only for user-level settings, but since we
now return early for the realm-level defaults code we do not
need these conditions.

This is done in a separate commit just to make the original commit
adding save/discard widget easy to review.
2021-10-07 10:16:28 -07:00
Sahil Batra 8528914131 settings: Fix live update code for realm-level user defaults section.
Previously, on receiving udpate event of realm-level default setting,
we updated the whole page, but this might be problematic now in case
where user has edited settings in two subsections with save/discard
button still present and if user clicks on save button of one
subsection then the setting in other subsection also resets to its
original value as whole page is updated.

So, this commit changes the behavior to only update the changed
setting and not affecting other settings similar to what we do
in 'Organization settings' and 'Organization permissions' sections.

We also do not call 'settings_display.report_emojiset_change' when
realm-level default of emojiset setting is updated because we now
uses save/discard widget.
2021-10-07 10:16:28 -07:00
Sahil Batra eed0a14ab0 settings: Use save-discard widget in realm-level defaults section.
This commit adds save-discard widget in the realm-level defaults
section. We use most of the functions used in settings_org.js
by passing for_realm_default_settings and add conditionals
according to it.

Some of the major changes wrt to the organzation settings code
are -

- We use element name attribute here to get the setting name from
element instead of id. We can add id for the elements here but
there is a problem doing so for the emojiset setting as for the
radio buttons we use four different input elements and all being
for the same setting.

- Added separate cases in discard_property_element_changes and
get_input_element_value to handle the radio buttons.

- We do not need get_complete_data_for_subsection here because
all settings are controlled by single field in DB and single
element in UI and thus we can simply get changed setting values
from populate_data_for_request.

- Added org-subsection-parent to the subsection container and
prop-element to the input and select elements so that we can
use the existing code.

- Modified get_subsection_property_elements to just return the
input element which is selected for emoji-settings subsection and
not all the input elements because we only need the selected value
of emojiset. We need other elements also when discarding the changes
but we handle it separately.
2021-10-07 10:16:27 -07:00
Sahil Batra 87a759c32d settings_org: Move save-discard widget click handlers to a function.
This commit moves all the click handlers used for controlling the
behavior of save/discard widgets to a separate function such that
it can be used for realm-level default section also. This function
has container and patch_url as parameters.
2021-10-07 10:12:10 -07:00
Sahil Batra 71ba76d05e settings: Adjust sequence of click handlers in notification settings.
This commit reorders the click handlers in notification settings,
such that we can easily move the click handlers for realm-default
settings to settings_realm_user_settings_defaults.js by returning
early.
2021-10-07 10:12:10 -07:00
Sahil Batra a7b14756ec settings_org: Use admin-realm-form class in save-discard click handlers.
We use 'admin-realm-form' class as selector in save-discard click
handlers instead of 'organization' which includes all the organization
settings sections, but save/discard widget is used only for some
sections and all of them are inside the form with class 'admin-realm-form'.

This will also help us to avoid code duplication when changing the realm
level defaults section to use save-discard widget.
2021-10-07 10:12:10 -07:00
Sahil Batra 774026396b settings_org: Add patch_url parameter to save_organization_settings.
This commit adds patch_url parameter to save_organization_settings
function such that we can use the same function for realm-level
defaults section also as those settings are updated using different
endpoint.
2021-10-07 10:12:10 -07:00
Sahil Batra 4e901d56ae settings: Do not initialize save_organization_settings in build_page.
We directly declare the save_organization_settings function instead
of first declaring a variable and then setting it in the build_page
function. This is a prep commit for using save/discard widget in
realm-level defaults section.
2021-10-07 10:12:10 -07:00
AnshVM f30e439ee3
message_edit: Hide recipient bar resolve topic if user lacks permission.
Previously, the "resolve/unresolve topic" checkmark option was displayed in recipient bars 
was presented to users regardless of whether they had permission to resolve topics in that
stream, which was confusing.

Fixes #19880.
2021-10-05 16:46:58 -07:00
Aman Agrawal cc8cb5432e channel: Simplify password change tracking.
Move the password tracking variables from setup to channel module.
Track password_change requests in channel.
Directly use xhr object to store `password_changes` information.
Tests modified to accomodote this change by converting strings to
objects.
2021-10-05 10:23:43 -07:00
Aman Agrawal 8433ce90dc channel: Ask spectator to login for unauthenticated requests.
Get complete coverage for channel.
2021-10-05 10:23:43 -07:00
Aman Agrawal 50812ead0f setup: Move 401 error check to channel.
Channel already handles all the requests and general errors related to
them; so, channels seems the right place for this check.
2021-10-05 10:11:10 -07:00
Tim Abbott 387237f263 stream settings: Fix exception for users who cannot create streams.
The previous logic, introduced in
fa928d5cd1, crashed when visiting
"manage streams" in the case that the user didn't have permission to
create any streams at all.

We remove the more complex logic.

This isn't the right long term fix, because it means users who can
only create public streams just get a vague "Insufficient permission"
error when trying to create a private stream (and vice versa), but is
sufficient to fix the critical bug of "manage streams" failing to load.

Fixes #19895.
2021-10-04 22:01:04 -07:00
Aman Agrawal c750d0e404 compose: Trim selected text before formatting.
We remove new line and space characters around the selected
text and then apply the requested formatting.
2021-10-01 16:45:51 -07:00
Aman Agrawal 58172fe21a compose: Allow user to undo formatting.
For text that already has the formatting that the user is
trying to apply, we undo the formatting. This gives a nice
experience of applying and removing the formatting from text
on the same button press.
2021-10-01 16:45:50 -07:00
Ganesh Pawar fa928d5cd1 streams: Split setting for stream creation policy.
Users wanted a feature where they could specify
which users can create public streams and which users can
create private streams.

This splits stream creation code into two parts,
public and private stream creation.

Fixes #17009.
2021-10-01 10:26:42 -07:00
Aman Agrawal 0df7c6f1b0 copy_code_button: Attach tooltip to body to avoid overlap with parent.
Having tooltip `appendTo` to parent causes it to be trimmed by
the size of parent container if the parent doesn't have enough
size to include the tooltip. To fix this, we append tooltip
to `document.body`.
2021-10-01 10:04:17 -07:00
Tim Abbott 171703e480 Revert "settings_data: Check for invalid policy values."
This change doesn't have proper test coverage and also doesn't work as
intended, since due to the structure of the function, we'll only
complain about invalid policy values for members in unlikely situations.

This reverts commit c69a968ffe.
2021-09-30 15:08:55 -07:00
Tim Abbott c69a968ffe settings_data: Check for invalid policy values. 2021-09-30 14:59:31 -07:00
sahil839 1e1f08fa4e settings: Add moderators and members option to msg-delete dropdown.
This commit adds moderators, full members and members options to
the delete_own_message_policy dropdown.
2021-09-30 14:59:31 -07:00
sahil839 909a3cde76 realm: Replace allow_message_deleting with delete_own_message_policy.
This commit replaces 'allow_message_deleting' boolean setting
with an integer setting 'delete_own_message_policy'. We have a
separate dropdown now for deciding which user-roles can delete
messages sent by themselves and the time-limit setting droddown
is different.

This new setting has two options - everyone and admins only. Other
options including moderators will be added further.

We also remove the "Never" option from the original time-limit
dropdown, as admins are always allowed to delete message. This
never option resembled the case of only admins being allowed to
delete but this state is now resembled by setting the dropdown
to "admins only" and we also disable the time-limit dropdown in
this case as admins are allowed to delete irrespective of limit.

Note, this setting is only for deleting messages sent by the
deleting user themselves, and only admins are allowed to delete
messages sent by others as before.
2021-09-30 14:59:31 -07:00
sahil839 b13bfa09c5 message: Make zero invalid value for message_content_delete_limit_seconds.
We make zero invalid value for message_content_delete_limit_seconds and
for handling the case of "Allow to delete message any time", the API-level
value of message_content_delete_limit_seconds is "anytime" and "None"
as the DB-level value. We also use these values for message retention
setting, so it helps maintain consistency.
2021-09-30 14:45:39 -07:00
Tim Abbott 4368b9d186 ui: Change 'Edit topic' label to 'Move message'. 2021-09-30 13:35:31 -07:00
Sahil Batra 42bd2a85f9 settings: Fix bug of empty subsection heading being visible.
We should also hide the 'Other emails' heading in realm-level
defaults section when digest emails organization setting is
disabled because there is no other setting in this subsection
after we removed the enable_login_emails setting in d1732fb.
2021-09-30 11:15:10 -07:00
Sahil Batra d1732fb9da settings: Remove realm-level default of enable_login_emails setting.
This commit does not remove the 'enable_login_emails' field from
RealmUserDefault table but it is just not used and cannot be
changed from UI or API similar to 'enable_marketing_emails' setting.
2021-09-28 12:41:09 -07:00
Sahil Batra e67b4cf499 settings: Show message to reload only for user settings.
We incorrectly show message to reload in the savings indicator
for realm-level default of left_side_userlist setting. It should
be shown only for user-level setting since no change will take
place for the user changing realm-level default.
2021-09-28 12:40:09 -07:00
Priyansh Garg da2bdec4ad compose: Collapse compose-box after sending message.
Previously, after sending a message from the full-sized compose-box,
the compose-box remained in expanded state covering the entire middle
part. Instead, it should return to the original state after the
message is sent.

There's a subtle race that would cause the "Scroll down to see your
message" compose notification to appear incorrectly, because the
full-size compose box occluded the entire message feed at the time the
message was locally echoed, even though it would no longer do so after
collapsing.

We address that by shrinking the compose box immediately before doing
a local echo, in addition to the primary code path in
`clear_compose_box`.  Care is taken to ensure that we avoid shrinking
the compose box when sending a message that cannot be locally echoed
and gets an error from the server.

Tested on my Ubuntu development environment, by sending empty message,
valid message and slash commands. The compose-box only shrunk on
sending valid messages.

Fixes part of #19353.
2021-09-28 11:36:51 -07:00
Aman Agrawal bed7c672ce stream_create: Allow web public stream creation. 2021-09-27 14:46:24 -07:00