Commit Graph

9096 Commits

Author SHA1 Message Date
Aman Agrawal 0a614fe985 bookend: Move conditional bookend content inside the template.
We move the stream subscribed/unsubscribed bookend info from
js files to bookend handlebar.

Tweaked by tabbott to override the check-templates indentation logic.
2022-01-31 16:32:09 -08:00
Tim Abbott c0d4f8ec79 compose: Fix compose box initialization order.
This effectively reverts part of
70d444a8eb.  While it's correct that we
want to render this bit of Handlebars template early, it was not
correct to move all compose box initialization earlier.

Do the same thing we do with the left/right sidebar container
templates, which is to render them directly in `ui_init.js`.

Fixes #20778.
2022-01-31 10:12:45 -08:00
Anders Kaseorg 90e202cd38 docs: Consistently hyphenate “web-public”.
In English, compound adjectives should essentially always be
hyphenated.  This makes them easier to parse, especially for users who
might not recognize that the words “web public” go together as a
phrase.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-28 17:45:45 -08:00
strifel 9ae72fd48c compose_closed: Extract get recipient label helper.
This makes it possible to reuse this logic.
2022-01-28 14:54:22 -08:00
Tim Abbott b3df4ef23f lint: Fix missing newline at EOF.
Introduced in 98fa5c9ae2.
2022-01-28 11:51:29 -08:00
Aman Agrawal 98fa5c9ae2 flatpickr: Move `show_flatpickr` function in a new module.
This would avoid cyclic imports to access `show_flatpickr`
function.
2022-01-28 11:43:07 -08:00
Sahil Batra 78a81ab21a stream-settings: Add code to live update right panel title on changing privacy. 2022-01-28 11:39:15 -08:00
Sahil Batra 2280777168 stream-settings: Add code to live update right panel title on stream rename. 2022-01-28 11:39:15 -08:00
Sahil Batra 74294ae602 stream_settings: Extract function to set title in right column.
This is a prep commit such that we can use this function to
live-update the title.
2022-01-28 11:39:15 -08:00
Sahil Batra 12efde8a51 stream-settings: Refactor code to pass sub object to title template.
This commit refactors the code to directly pass sub object to
selected_stream_title template instead of passing name, is_web_public
and invite_only as different parameters.
2022-01-28 11:39:15 -08:00
Aman Agrawal 5688d8b0df scroll_bar: Remove unnessary adjustment of keyboard icon.
Since the keyboard icon is not associated with scrollbar, we
can just have a fixed margin-right for it.
2022-01-28 09:50:27 -08:00
Aman Agrawal b0dd063bb8 scroll_bar: Simplify module.
The content which is scrollable is moved left by the width of the
scrollbar when scrollbar is visible. The navbar, floating recipient bar
and composebox doesn't move. We reduce their width by scrollbar width
to adjust for the reduced width of the scrollable content.

Since floating recipient bar is center aligned (with margin: 0 auto)
we also have to move left by half the scrollbar width.

Group css classes having the same value being assigned together. This
makes the code easier to understand.
2022-01-28 09:50:27 -08:00
Steve Howell 576b966edc search suggestions: Add comment about server history. 2022-01-27 10:19:07 -08:00
Steve Howell eb2bf77212 search suggestions: Find older topics.
We no longer limit our list of candidate topics
to 300.

We continue to limit the topic results to 10, since
we don't want to overwhelm users or crowd out
non-topic-related suggestions.

We try to handle this is an efficient manner.
2022-01-27 10:19:07 -08:00
Sahil Batra 7265a76fc6 stream-settings: Show icon according to in the right column title.
We were showing # for all types of streams in the title at the top
in the right column of stream settings overlay. This commit fixes
it to show globe icon for web-public streams and lock icon for
private streams.
2022-01-26 12:50:05 -08:00
Sahil Batra e26de17ee1 stream-settings: Add space between # and stream name in title.
This commit adds space between # and the stream name appearing
at the top in right column in stream settings overlay.
2022-01-26 12:50:05 -08:00
N-Shar-ma 048c9b99e3 compose: Add format hinting for polls.
Added a placeholder key to the polls slash command object. This is
selected and highlighted after being typed ahead in the compose box.
For slash commands without placeholder, everything works as before.

Formatting hints can easily be added for other slash commands too,
by adding a placeholder key to their object.

Fixes part of #20868
2022-01-25 18:12:42 -08:00
Aman Agrawal ec86290e2a tippy: Fix persistent message action tooltips on icons after blur.
When users tabs through the message action icons, they used to
persist even when the focus is not on them. We manually
destroy them on blur event since tippy has some issue with
handling elements with opacity hiding effect.
2022-01-25 11:15:30 -08:00
N-Shar-ma a003fe0246 compose: Fix bug where stream color didn't update on mouse selection.
Called the `decorate` function to update stream color in the compose
box on `change` instead of `blur`.

On clicking on a stream option, the input box for the stream name
remained in focus, hence decorate wasn't triggered on blur. Using
the change event instead, ensures that decorate will be called
anytime the stream is changed.

Fixes: #20871
2022-01-24 17:14:47 -08:00
Anders Kaseorg 44f9aaec32 eslint: Fix unicorn/prefer-dom-node-dataset.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-24 15:55:38 -08:00
Anders Kaseorg 392676d4da js: Avoid _.get.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-24 15:54:21 -08:00
Anders Kaseorg cc40352541 js: Avoid _.first, _.last, _.initial, _.tail.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2022-01-24 15:54:21 -08:00
Anders Kaseorg 42931e69e6 js: Convert _.isFunction to typeof.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-24 15:54:21 -08:00
Anders Kaseorg 57cc5cb25a js: Convert _.without to filter or other logic.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2022-01-24 15:54:21 -08:00
Anders Kaseorg e2290ef0de js: Convert _.uniq(a) to Array.from(new Set(a)).
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2022-01-24 15:54:21 -08:00
N-Shar-ma 6d2de28bf0 todo_widget: Fix bug where new todos sometimes replaced old todos.
Initialised `this.me` for the TaskData using a constructor to the
current user id.

The bug was caused due to `this.me` never being initialised, and hence
`idx` wasn't incremented on page reload, which resulted in duplicate
`data-key` attributes and hence new todos overwriting older todos with
the same `data-key`

Fixes: #20698
2022-01-24 11:25:32 -08:00
Anders Kaseorg c6b372b471 js: Simplify indexing arrays from the end with Array#at.
https://github.com/tc39/proposal-relative-indexing-method

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-24 09:58:54 -08:00
Anders Kaseorg 0b03628324 js: Shorten Object.prototype.hasOwnProperty.call to Object.hasOwn.
https://github.com/tc39/proposal-accessible-object-hasownproperty

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-24 09:57:09 -08:00
Aman Agrawal c4efc97d5a compose: Extend empty compose navigation logic to recipient boxes.
Navigation key presses like `Up` and `PageUp` with an empty recipient
boxes will now close the compose and propagate the keypress to the message
list or recent topics, depending upon the active view.

This extends behavior we've had for a long time with focus in the
compose box itself.
2022-01-21 16:40:13 -08:00
Ganesh Pawar 49e9cf10de user_status: Migrate modal to dialog_widget. 2022-01-21 16:17:25 -08:00
Ganesh Pawar f43d3b9986 change_email: Migrate modal to dialog_widget. 2022-01-21 16:12:34 -08:00
Ganesh Pawar 79bdd8bdb6 api_key_modal: Update the modal config for `on_show`.
This is needed since 291aaf373f changed
the interface for modal event handlers.
2022-01-21 16:12:34 -08:00
Eeshan Garg f2e7b92b02 team_page: Display count of contributors with >=100 commits. 2022-01-19 17:37:09 -08:00
Eeshan Garg 1e8a7bc977 team_page: Exclude dependabot from contributors.
Dependabot has a history of merging some PRs and that makes GitHub
think that it is a contributor.
2022-01-19 17:37:09 -08:00
Eeshan Garg 94c89c80d1 team page: Display contributor count per repo.
Fixes #20725.
2022-01-19 17:37:09 -08:00
Aman Agrawal d4c70319eb topic_list: Fix search box not focused in expanded state.
We only check `topic_search_focused_before_build` if the
search box is visible.
2022-01-18 16:53:25 -08:00
Priyank Patel 039910a159 ts: Convert lazy_set module to typescript. 2022-01-18 13:24:02 -08:00
Priyank Patel d0c339e772 lazy_set: Return set from the _make_set method.
This is done to avoid adding typescript type error checks when this
is converted to typescript.
2022-01-18 13:24:02 -08:00
Priyank Patel 84958bf7eb lazy_set: Move the size getter above other methods.
This is to avoid @typescript-eslint/member-ordering error when this
module is converted to typescript.
2022-01-18 13:24:02 -08:00
Priyank Patel 16a3d444fd lazy_set: Move set and array properties to the data field.
The data field will be a union type when it is converted to typescript.
This approach allows us to avoid introducing additional type check for
both of the properties.
2022-01-18 13:24:02 -08:00
My-Name-Is-Nabil 20d0fc9733 compose: Prevent upload files tooltip from hiding behind left sidebar.
Resolves the issue by appending tooltip to document body.

Fixes: #20639.
2022-01-11 16:30:55 -08:00
Sahil Batra df58a0740a settings: Show user name in heading of deactivation modal.
We show user name in heading of the deactivation confirmation
modal instead of email, since there can be a case when admin
does not have access to real email and we already show email,
if accessible, in the content of the modal.
2022-01-11 15:42:51 -08:00
Ganesh Pawar c1f639d115 org edit_bot_modal: Fix dropdown styling issue.
This makes use of the existing CSS present for the personal
edit_bot_modal.
2022-01-11 09:15:06 -08:00
Eeshan Garg c30458e174 streams: Add notifications for posting policy changes.
An explanatory note on the changes in zulip.yaml and
curl_param_value_generators is warranted here. In our automated
tests for our curl examples, the test for the API endpoint that
changes the posting permissions of a stream comes before our
existing curl test for adding message reactions.

Since there is an extra notification message due to the change in
posting permissions, the message IDs used in tests that come after
need to be incremented by 1.

This is a part of #20289.
2022-01-10 18:29:04 -08:00
Aman Agrawal c23f5a114e topic_list: Don't restore focus to search if it wasn't focused.
After topic list is updated, only restore focus to it, if it was
focused before. This avoids jumping focus from say compose box
to topic search unexpectedly when the topic list is updated.
2022-01-07 14:39:16 -08:00
Priyam Seth 9aa5082d63 message edit: Move with_first_message_id to message edit.js.
Prep commit so that the function first_message_id can be used
as an exported function for marking resolved topic as unresolved.

Related to #20584.
2022-01-05 17:55:00 -08:00
Aman Agrawal b3886af651 click_handler: Use a variable for target's jquery instance. 2022-01-05 16:15:40 -08:00
Aman Agrawal bf7224d04d reminder: Simplify logic and improve error text. 2022-01-05 16:15:40 -08:00
Aman Agrawal fa4311e7d0 popovers: Don't trigger remind handler on every flatpickr confirm.
This is part of remind popover and hence should be handled
separately.
2022-01-05 16:15:40 -08:00
Aman Agrawal db09639f6c compose: Change UI which toggles `enter_sends` setting.
Use a popover which displays both the options instead of long text.
We only use a small text indicating the current state which user
can click on to trigger the popover.
2022-01-05 16:03:53 -08:00
Eeshan Garg 7196b5ac84 header: Fix unresponsive dropdown pill on /help pages.
My PR #18974 introduced a bug where the logged-in dropdown pill on
the /help pages stopped working and has been unresponsive ever
since. This was caused by the incorrect assumption that each
`.dropdown` would be inside an unordered list `ul`. However, that
isn't the case for the dropdown pill on the /help pages. This commit
simply removes said assumption, by widening the scope of the relevant
CSS selectors.
2022-01-05 15:18:24 -08:00
Sahil Batra 98ec1acb35 settings: Make banner asking to confirm new email sticky.
We make the banner, mentioning the user to confirm new email
after changing the email through settings, sticky and it
disappears either on reload or after confirming the new email.

Fixes #20686.
2022-01-05 14:42:23 -08:00
YashRE42 e17c96d86d composebox_typeahead: Fix bug in global time backspace & delete cases.
In the previous commit (bea41e975d) we
introduced a bug by using `hotkey` instead of `hotkey.name`, further
debugging revealed that the conditional was unnecessary and as such
has been removed in this commit, the comment for the is_numeric
conditional has also been changed to explain its actual purpose.

Some other inline comments have also been moved to be on their own
lines.
2022-01-04 18:10:21 -08:00
YashRE42 bea41e975d compose: Fix numeric typing regression related to global time widget.
In commit 1d54b383bd we introduced some
changes to add better support for keyboard navigation with the global
time widget. Unfortunately, as a result of the fact that
get_keydown_hotkey returns undefined for numeric keys, we caused a
regression that prevented users from typing into the time picker.
Additionally, we also lost support for the backspace and delete keys.

Hence, this commit fixes the above bug by early returning in two
places if the key pressed is backspace, or delete or a numeric key.
2022-01-04 17:06:47 -08:00
Sahil Batra 2eb1f0195d settings: Show only real email in user deactivation modal.
We show email of the user being deactivated only if real email is
accessible and not the fake email generated using user id.
2022-01-04 14:42:19 -08:00
YashRE42 d82653c3de condense: Do not cache message_content height of 0 from recent_topics.
Previously, we suffered a bug where we would not properly condense
messages on first load of CZO (ie after login).

This bug was an unintended consequence of setting recent topics as the
default view, because since the page loads to recent_topics the
message_list is hidden but still gets rendered into the DOM and when
condense_and_collapse runs, it causes get_message_height to cache a
message height of 0, which results in the message not being collapsed.
There may be other ways to trigger the same broken mechanism.

This commit changes the function so we only return 0 but don't cache
the result.

Fixes: #20666.
2022-01-02 12:12:36 -08:00
Steve Howell c6d9029dfc dom: Remove outer subscriptions div. 2021-12-30 11:36:52 -08:00
Steve Howell 7ff89e4cae dom: Rename div to #manage_streams_container.
The old name was confusing, since the contents
of the div aren't just a table, and we have
smaller elements that actually do list a bunch
of subscriptions in tabular format.
2021-12-30 11:36:52 -08:00
Steve Howell 507da749b7 stream edit: Tighten up selectors for handlers.
Even though we intend to shortly share lots of code
for editing stream subscribers with the create-stream
UI, we don't want to confuse click handlers and
containers too much.
2021-12-30 11:36:52 -08:00
Steve Howell 36378477ff stream edit: Extract make_list_widget. 2021-12-30 11:36:52 -08:00
Steve Howell f55d9c2f35 stream edit: Simplify how we find the search input. 2021-12-30 11:36:52 -08:00
Steve Howell 5e86c72f8e stream edit: Extract set_up_pill_typeahead. 2021-12-30 11:36:52 -08:00
Steve Howell 5a89672ac5 refactor: Extract update_subscribers_list_widget. 2021-12-30 11:36:52 -08:00
Steve Howell fb003d757b performance: Use a single ListWidget for subscribers.
It's kind of silly to cache ListWidgets for subscriber
lists when we only ever update the most recent one.

This will save memory if you are managing a whole bunch
of streams, although I suspect the savings here is
mostly negligible unless you were doing something
crazy.

The main motivation here is just that it simplifies the
code.
2021-12-30 11:36:52 -08:00
Steve Howell afd1d12405 refactor: Remove is_sub_settings_active. 2021-12-30 11:36:52 -08:00
Steve Howell 2a19468432 subscribers: Use current_stream_id to track current stream. 2021-12-30 11:36:52 -08:00
Steve Howell 1c54d44f97 hash_util: Add is_editing_stream helper.
This is a bit more robust than active_stream().

We don't do the typeof check for parseFloat,
since even NaN is a number type.
2021-12-30 11:36:52 -08:00
Steve Howell 208cec2848 refactor: Move update_subscribers_list.
We should be able to solve the import back
to stream_edit in an upcoming commit.
2021-12-30 11:36:52 -08:00
Steve Howell 49a1d5a9a3 refactor: Reduce scope of message var. 2021-12-30 11:36:52 -08:00
Steve Howell d7f90acbf6 refactor: Extract remove_subscriber. 2021-12-30 11:36:52 -08:00
Steve Howell e742ebb8e8 refactor: Limit scope of e.target.
Now our click handlers get stream_id directly from
e.target, and then downstream code is no longer
coupled to the event semantics.

Note that we'll probably just know the stream_id
more directly after future commits.

We also remove a little bit of redundant error
handling.
2021-12-30 11:36:52 -08:00
Steve Howell 0777cd73bb stream edit: Extract stream_subscribers_ui.js.
This is a fairly straightforward extraction.

It's good to test this with Iago, and then go into
Manage Streams and add/remove subscribers for a stream
like devel.

I copy/pasted two small functions that will soon
diverge from stream_edit. The get_stream_id function
will either use a module variable (since we're
generally only editing subscribers for one stream, and
we already have the singleton assumption with
`input_pill`) or a more strict CSS selector.  And then
get_sub_for_target depends on get_stream_id. We may not
always need full subs, anyway, and when we adapt some
of this code for creating streams, things are likely to
change.

I stopped exporting a couple functions that have no
callers outside of this module.

The main entry point for the module is
enable_subscriber_management.

We continue to export invite_user_to_stream and
remove_user_from_stream, which should possibly be just
pulled into their own module to lessen some
dependencies, but they don't have too much baggage,
since they just wrap channel calls.
2021-12-30 11:36:52 -08:00
Steve Howell d938f73d05 refactor: Move code for can't-subscribe popover. 2021-12-30 11:36:52 -08:00
Biki-das b3c2f88b7b typeahead: Remove unnecessary topic_names variable.
Also fix a comment typo in the same file.
2021-12-30 06:56:29 -08:00
Tim Abbott 877c275380 typeahead: Use early return pattern for enter logic.
This makes this code more readable.
2021-12-30 06:55:57 -08:00
Julia Bichler b673e966ca spectators: Prevent toggling TODO checkboxes.
Checkboxes now don't change if a user who is not logged in
clicks on them.

Fixes #20300.
2021-12-29 17:10:21 -08:00
Sahil Batra a59d429045 settings: Fix code for special case of theme settings subsection.
We handle "Theme settings" subsection separately in
get_subsection_property_elements as it contains unique
radio-button structure for emojiset setting.

This should have been fixed while reorganizing the section
to have color scheme and emoji related settings under same
subsection in adb612a0b4.

Fixes #20644.
2021-12-29 16:32:12 -08:00
YashRE42 5e194afda3 reactions: Destructure during make..reaction call from set..reaction.
This is a pure code refactor for readability.
2021-12-28 11:12:02 -08:00
YashRE42 6fa92cce7e reactions: Use parameter destructuring in make_clean_reactions.
This is a pure code refactor for readability.
2021-12-28 11:11:57 -08:00
YashRE42 06d8e6dfd5 reactions: Refactor add_clean_reactions to make_clear_reaction.
This is a pure code refactor for readability.

Previously, we were relying on there being a side effect to
add_clean_reaction which was necessitated by the presence of an output
parameter, `message` (or more specifically `message.clean_reaction`).
Output parameters are confusing.
Hence, this commit changes to have a make_clean_reaction function that
returns a reaction.
2021-12-28 11:11:51 -08:00
YashRE42 0b0637de78 reactions: Remove `export` from add_clean_reaction() function.
This function is not called by any external files or tests.
2021-12-28 11:11:43 -08:00
YashRE42 1dffad98fa reactions: Use parameter destructuring in insert_new_reaction.
This is a pure code refactor for readability.
2021-12-28 11:11:39 -08:00
YashRE42 0438ed5777 reactions: Use parameter destructuring in update_existing_reaction.
This is a pure code refactor for readability.
2021-12-28 11:11:37 -08:00
YashRE42 0991ed4526 reactions: Use parameter destructuring in view.remove_reaction.
This is a pure code refactor for readability.
2021-12-28 11:11:31 -08:00
Steve Howell 7f8ea5b9f2 stream edit: Find stuff within parent_container.
This will facilitate code reuse.
2021-12-16 15:28:11 -08:00
Steve Howell 2194a51b97 refactor: Extract people.get_users_from_ids. 2021-12-16 15:28:11 -08:00
Steve Howell 6c9427340a refactor: Move user-sorting code to people.js.
We also remove the blueslip check, since it is
pretty easy to audit the callers here.
2021-12-16 15:28:11 -08:00
Steve Howell ab8b550cda stream settings: Extract enable_subscriber_management.
The name here is accounting for future plans where
we will share code for both of these use cases:

    * editing subscribers on current stream (now)
    * editing subscribers on new stream (upcoming)
2021-12-16 15:28:11 -08:00
Steve Howell 931a8f28a0 stream settings: Simpify code to find input pill.
We also future-proof against having multiple input
tags in the stream-edit container.
2021-12-16 15:28:11 -08:00
Steve Howell 585ca1bc26 stream settings: Extract stream_settings_containers.js.
This has two long-term goals:

    - avoid circular dependencies between
      stream_ui_updates and stream_edit

    - facilitate code reuse for adding subscribers
      to a new stream (i.e. using same widget for
      when you edit subscribers)
2021-12-16 15:28:11 -08:00
Archit Hadge 25ccd4a7db settings: Change "N minutes" options to Custom.
We change the various "Up to N minutes" settings option labels to
"Custom", since the N is a little too mathy for some users.

Since the new prompts for the value of N are longer, we need to move
those prompts to the next line. Mainly this means switching from
`dependent-inline-block` to `dependent-block`, but we also need to
move the block out of the containing input-group for the CSS to be
happy.

Substantially rewritten by tabbott to use CSS for positioning and
change the message deleting copy of this issue.

Fixes #20177.
2021-12-09 11:52:27 -08:00
Swati Bhageria 2d766f3e78 message list: Display MOVED for messages with only topic edits.
This avoids the somewhat confusing visuals of showing messages as
EDITED where the content had not been changed, which also obscured
situations where a message had both been edited and moved.

It's possible we could do better with some sort of fancier block-move
visual styling, but it's a bit tricky to do well given that we support
moving multiple messages at once.

Fixes #20451.
2021-12-09 10:50:01 -08:00
Kevin 1d54b383bd compose: Fix keyboard UI with new global time widget.
Fixes #20130
2021-12-09 09:00:33 -08:00
Tim Abbott 36f03ccd5c message_events: Fix edit history live update when moving topics.
As noted in the TODO that we delete with this commit, we never
implemented live-updated for edit history when moving a message to
another topic.

Implementing this involves somewhat ugly copy-paste of the logic for a
content edit, but structurally is pretty simple.

It also makes #20451 much more visible.
2021-12-08 21:35:44 -08:00
Nikhil Maske 091772b534 hotspots: Remove intro_reply hotspot.
Zulip shows two guides on How to reply, first one by
the welcome bot and second one is intro_reply hotspot.
To simply and avoid redundancy, intro_reply hotspot is
removed.

Fixes #20482.
2021-12-07 21:55:59 -08:00
Sahil Batra 116a0f6f9d stream_settings: Sort subscriber list by name always.
This commit changes the behavior of subscriber list to
always be sorted by name instead of sorting them by email
when emails are accessible.

This change is fine because we will be using user-level
email address visibility and in that case the email of
some users will be visible and email of some will be not.
2021-12-07 21:44:40 -08:00
Sahil Batra 1ce869f16c settings_users: Fix comment in bot_info function. 2021-12-07 21:42:24 -08:00
Sahil Batra a1a5a1643f settings: Remove unused show_email parameter.
We show "Email" column heading always in users list and
subscriber list irrespective of the email-address visibility
setting after 46660e5, so we do need to pass show_email
parameter to render_admin_tab and render_stream_settings.
2021-12-07 21:42:23 -08:00
S-Abhishek 186d1a83e9 narrow_banner: Move empty narrow messages to handlebar templates.
Removed existing empty narrow divs from app/home.html and created
a new javascript module to dynamically load empty narrow messages
using handlebar template.

Fixes #18797
2021-12-07 13:38:48 -08:00
Sahil Batra 9bb506c6f7 streams: Fix live-update bug of disabling web-public option instead of hiding.
The web-public option was disabled instead of being hidden in stream creation
form during live update triggerred from setting enable_spectator_access to
False. It was not being hidden since we have made web-public as the first
option and it is selected by default.

This commit fixes the bug to hide the option and also makes the code more
readable.
2021-12-07 11:44:45 -08:00
Sahil Batra 265a587470 streams: Consider only visible choices while selecting default choice.
We should only consider visible choices while selecting the default
stream-privacy choice in stream creation form. Previously, we were
only checking whether the option is disabled, but this resulted in
a case where no option was selected when the realm-level setting
was set to not allow web-public streams as the choice was only
hidden and not disabled.
2021-12-07 11:44:45 -08:00
Sahil Batra 1049867485 streams: Reorder stream-privacy choices in UI.
This commit moves 'Web public' option to top in
the stream privacy choices in stream creation
form and changing privacy modal.
2021-12-07 11:44:45 -08:00
Aman Agrawal a23cc709e8 resize: Hide popover on width change on mobile devices.
It is possible for user to change the width by using
screen rotation after the page has been loaded on mobile.

If only height has changed, it is most likely due to a
virtual keyboard, we don't hide popover in that case.

Fixes #20439
2021-12-06 10:36:20 -08:00
Aman Agrawal ec48f29daf compose: Check if compose control btn popover has the clicked element.
This is necessary to avoid a poptention bug where the popover
is open but the button is clicked somewhere else.
2021-12-04 06:52:18 -08:00
Aman Agrawal d749438551 compose_ui: Use white spinner on both dark and light theme.
Fixed alignment slightly.
2021-12-04 06:52:18 -08:00
Yash Rathore 345616ad02
user_sidebar: Set personal presence dot based on the user's settings. (#20376)
If a user chooses to not broadcast their presence status to others, we
still show the user as available in their own user sidebar. Instead, one's
own availability should appear the same as it does for other users.

With tweaks from YashRE42: rebasing to use user_settings instead of
page_params, as introduced in the series of commits ending with
8755a76cf6, adding code comments and
moving the redraw call to `server_events_dispatch.js`.

Fixes part of #18846.  Further work is required to display the user's own idle
status properly to complete #18846.

Co-authored-by: YashRE42 <33805964+YashRE42@users.noreply.github.com>

Co-authored-by: Ganeshprasad Biradar <biradarganesh25@gmail.com>
2021-12-03 16:20:20 -08:00
Sahil Batra c648982996 settings: Fix behavior of realm-level notification batching settings UI.
Changing realm-level notification batching period setting from UI
was broken after adding the "Custom" option in 4f63378e7f because it
handled only user-level setting code and not realm-level setting.
This commit fixes it.
2021-12-03 16:03:02 -08:00
Sahil Batra 08038ef140 settings: Refactor set_notification_batching_ui function.
This commit refactors the set_notification_batching_ui to
use settings_org.change_element_block_display_property function
for toggling the visibility of custom input.

We add id to the email_notification_batching_period_edit_minutes
element such that we can use change_element_block_display_property
function because it requires id of element as an argument.

This commit also removes the value attribute of the custom
input since its value was set undefined in the template
and then was set in set_notification_batching_ui, so there
is no use of keeping the value attribute in templates.

This is a prep commit for fixing the behavior of this element
in realm-level default settings.
2021-12-03 16:03:02 -08:00
Aman Agrawal c894f50f3c recent_topics: Extend persistent focus bug to all RT elements.
The bug fix for RT search, also needs to be applied to other
elements.

Fixes #19458.
2021-12-03 14:39:48 -08:00
Anders Kaseorg 951b81e2bd eslint: Fix unicorn/prefer-code-point.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-12-03 14:33:53 -08:00
Aman Agrawal b4c2c97ffd compose: Extract method to get compose click target. 2021-12-03 14:29:26 -08:00
Aman Agrawal 9d330365fc compose: Stop propagating clicks for compose control buttons. 2021-12-03 14:29:26 -08:00
Aman Agrawal 7af573fa45 compose: Remove unused code.
Since we don't use video button in compose control buttons
popover, this will never be reached. We can add this code again
when we add video button to the popvoer.
2021-12-03 14:29:26 -08:00
Aman Agrawal ffd9d18577 compose: Enclose hotkeys in `kbd` tag.
We change how `kdb` is displayed in dark-theme for
compose so that they don't take too much user attention
when composing.
2021-12-02 15:11:15 -08:00
Aman Agrawal 4ed6b441c7 flatpickr: Improve look of `Confirm` button.
Change text from OK to Confirm.
Remove icon.
2021-12-02 15:11:15 -08:00
Aman Agrawal aaa7150b8a compose: Move overflowing buttons to a popover.
We don't hide popover on click for formatting buttons, emoji picker and time
picker.
Emoji and time picker popovers need a reference to be displayed,
hence we don't hide them.
Not hiding formatting buttons is based on past discussion.

The current instance of compose popover is stored locally
so that we can access it across different modules.

The basic approach for hiding / displaying a button is based on
width and is executed at `sm` breakpoint as per our
`css_variables.js`.
Used handlebars and `hide/show-sm` css class to make this
work. This avoids using too much JS to hide/display elements.
2021-12-02 15:11:15 -08:00
Aman Agrawal b5f662c646 popover_menus: Extract common onShow methods. 2021-12-02 15:11:15 -08:00
Aman Agrawal a64f6edc2a compose: Use loading spinner as loading indicator. 2021-12-02 15:11:15 -08:00
Aman Agrawal 25ee6a795e compose: Never hide send button.
`Press Enter to send` used to hide `Send` button, we remove that
behaviour.

We show the current state of `Enter` hotkey action via text below
`Send` button which can toggle behaviour on click.
2021-12-02 15:11:15 -08:00
somesh202 219ecea659 people: Extract helper functions for medium avatar urls.
The new is obviously parallel with the small avatar URL construction,
and allows us to deduplicate this construction between the popovers
and full user profile logic for getting a medium avatar URL.

Fixes #20140.
2021-12-02 14:56:34 -08:00
Aini-Alem Robertson e9d80390cc stats: Remove complex regex badly implementing toLocaleString.
This regular expression to add commas to a large number is hard to
read and produces less useful output than using the standard browser
API for doing this.

Fixes #20416.
2021-12-02 14:35:56 -08:00
Sahil Batra fc8db93f36 settings: Disable spectator access setting when server setting is False.
We disable the enable_spectator_access setting when the server level
setting, WEB_PUBLIC_STREAMS_ENABLED setting is set to False.

This commit adds a new argument is_disabled to settings_checkbox which
is used to disable the checkbox and set the color of label accordingly.

This commit also adds a help-link besides the label pointing to
"/help/web-public-streams" which is shown irrespective of the
setting being enabled or disabled.

Fixes #20417.
2021-12-02 14:33:51 -08:00
alguimo 8ae6e1b718 settings: Remove Unset and Disable buttons when no permissions.
This makes the UI for users browsing organization permissions a bit
less confusing; if they can't edit anything, they shouldn't have these
extra little buttons.

Fixes #20002.
2021-12-02 14:32:01 -08:00
Ganesh Pawar 19c4a63d51 move_topic_modal: Use `dialog_error` to display error.
Fixes #20210
2021-12-02 14:02:27 -08:00
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