Commit Graph

10283 Commits

Author SHA1 Message Date
Steve Howell 5890a50c71 emoji picker: Use closest() to find map for mouseenter.
If we have two emoji pickers open for some reason,
we will now no longer be buggy for the mouseenter
event.
2020-06-18 13:18:50 -07:00
Steve Howell 453e6d7b09 refactor: Pass $emoji_map to maybe_change_focused_emoji.
We'll let the callers tell us which map to update,
which will let us eventually handle multiple pickers
better.
2020-06-18 13:18:50 -07:00
Steve Howell c278a8d9ec minor: Rename may_be to maybe. 2020-06-18 13:18:50 -07:00
Dinesh 9801692a2d css: Fix size of GitLab icon in login and signup buttons. 2020-06-18 13:06:10 -07:00
Dinesh 0445311430 auth: Make apple log in and sign up buttons consistent with others. 2020-06-18 13:06:10 -07:00
Tim Abbott 3dac8d7d97 message_fetch: Rename constants for clarity.
The "pointer" is no longer a concept; what we mean to refer to here is
the anchor.
2020-06-18 12:55:59 -07:00
Tim Abbott ba1f2dfdfa pointer: Merge pointer.js into message_scroll.js.
Ths remaining code here is naturally message scrolling logic, and fits
well into the existing file for handling that.
2020-06-18 12:55:59 -07:00
Tim Abbott 5321e8792d pointer: Move planned scroll logic to navigate.js.
Like the last commit, this is clearly a better home for this state,
since all reads to the data object are in navigate.js already.
2020-06-18 12:55:59 -07:00
Tim Abbott 052dbb0716 pointer: Move scroll suppression to message_scroll.js.
This is clearly a better home for it, since message_scroll.js is the
only place that reads it, and also lets us provide a clearer name for
the functionality.
2020-06-18 12:55:59 -07:00
Tim Abbott 94e6cb9abd pointer: Remove frontend logic tracking furthest_read.
Since we are no longer using the "pointer" value sent in
page_params.pointer for anything, there's no value in continuing to
send it from the server to the client.

The remaining code in pointer.js is logic managing state for the
currently selected message.
2020-06-18 12:55:59 -07:00
Tim Abbott 8516dde8f4 pointer: Stop sending bankruptcy pointer updates.
Since the pointer is no longer used to set the browser's position, we
no longer need this complex code to send updates to the server during
the bankruptcy flow.
2020-06-18 12:55:59 -07:00
Tim Abbott b840ec9491 notifications: Check whether addEventListener is a function.
It's crazy that we need to do this; one would think that Electron apps
whose sole purpose is to be used with multiple team chat tools would
at least implement the standard desktop notification API correctly.

But it seems worth making this tactical change to prevent every
desktop notification throwing a traceback on those platforms, which if
nothing else results in a lot of error spam.

Fixes #15103.
2020-06-18 12:47:02 -07:00
Tim Abbott d32e8276d2 message_scroll: Fix broken call to hide_empty_narrow_message.
This was broken when moving the code being called to another file.

This exception caused a pretty weird/nasty bug by interrupting the
message_fetch response handler before it finished updating the
fetch_status data strutures.  The end result was that in views where
the "history limited notice" was displayed, local echo would be broken
a confusing notice would be displayed.
2020-06-18 12:35:08 -07:00
Steve Howell d4fc28cf42 list_cursor: Avoid tracebacks.
In rare situations we would get tracebacks from
list_cursor on the line that I changed here.  We
went the entire month of May without a traceback
here, and I can't reproduce the problem.

This is a pretty clear fix, though, and it will
hopefully lead to a more enlightening symptom.

The likely scenario here is that you use `q` to
navigate the stream list and then unsubscribe.
I tested that and couldn't get a traceback,
but I do think the traceback indicates some
possible issues.

The behavior I saw when I did this
appeared to be mostly harmless.
When I deleted a row (by unsubscribing), the code
seemed to effectively disable the cursor.  It's
possible we should go to the next row or fully disable
the search.

I opened #15439 to follow up on this and other
cursor-related issues.
2020-06-18 09:08:46 -07:00
Steve Howell 9fdd98cf88 refactor: Clean up add/remove_sidebar_row.
The stream_events tests were kinda messy, but
I mostly just consolidated a few sections of
code so that we didn't have to keep
re-stubbing the same functions.

For the actual code, I extracted add_sidebar_row
and then removed the unnecessarily complicated
jQuery trigger mechanisms.
2020-06-18 09:08:46 -07:00
Ryan Rehman 69f9c72edc search suggestions: De-duplicate legacy search codepath.
This merges the `exports.get_search_result_legacy` and
`exports.get_search_result` function.

The key differences between the two code paths are as follows:

* We only want to generate suggestions for the queries which
  the user is typing or can edit.
  For the legacy version, suggestions are displayed for the
  entire search string in the searchbox. (`all_operators`)
  For the pills enabled version, suggestions are displayed
  only for the input which hasn't been converted to pills.
  (`query_operators`)
  `all_operators` = `base_query_operators` + " " +  `query_operators`.
  trim is added at the end just to handle the legacy case
  where we pass the `base_query` as ''.

* It is not possible to detect whether the user wants to
  continue typing in the legacy version. However if the
  the searchbox is still focused even after pill creation
  we can assume the user still wants to continue typing.
  To handle this we push an empty term as the `last` operator.
  This is possible since the previous queries have been
  completely entered as evident from it's generated pill.

* When using the legacy version, `search_operators` are
  the same as `all_operators`, as mentioned in point 1.
  In the pills enabled version we perform most of the
  computations from the `query_operators`, but we do
  require all `all_operators`, only for filtering the last
  query's suggestion.

* And there is just one block unique to the legacy search
  system. More details are mentioned in the comments of that
  block.

We also refactor both the search suggestions node tests,
mainly to make them similar and easier to detect differences
when we switch over to the new version.
2020-06-18 01:44:15 -07:00
Ryan Rehman a7dc0ed816 search: Deactivate narrow on deleting the last search pill.
This is the only case where we change narrow
using the search box besides pressing enter.
2020-06-18 01:36:49 -07:00
Ryan Rehman 531a803bfc typeahead: Allow automated selection for `contenteditable` elements.
This adds the support of our auto completion behaviour of the legacy
search code into the search pills version.
2020-06-18 01:35:19 -07:00
Ryan Rehman 4ed4aa7b6f search: Do not narrow on updation of search pills.
Previously we narrowed every time a search pill was created or deleted.
This commit allows the user to be able to continue typing without the
lag of narrowing.
This behaviour matches with the legacy version, whose code path remains
unchanged.
2020-06-18 01:33:56 -07:00
Ryan Rehman 6ce43f3ede search: Be able to continue typing after adding pills.
Under the search pills paradigm it is more natural for the
user to add pills and still continue typing.
Previously everytime a pills gets added the narrow activates
(this is still the case) and then the user had to refocus the
searchbox the continue typing the remaining search query.
2020-06-18 01:32:11 -07:00
Ryan Rehman dd4460009b search: Remove redundant actions on `focus` events.
The 2 function calls of `open_search_bar_and_close_narrow_description`
was removed from the 2 event handlers since it was called again, from
the `search.initiate_search`.

The "focusin" event was redundant since there are multiple other event
handlers (like the `tab_bar` or `hotkeys`) for this purpose, and all
of them call the `search.initiate_search` function.
2020-06-18 01:32:11 -07:00
Ryan Rehman 0e158f2c90 search suggestions: Refactor `get_search_result_legacy` code path.
The only change made here is the renaming of `operators` variable
to `search_operators`.

That is mostly evident from the fact that we do not need to
make any changes to `node_tests/search_suggestion_legacy.js`.

As mentioned in the previous commit, we make this change
to get a minimal diff between the legacy and search pills
enabled version.
2020-06-18 01:27:10 -07:00
Ryan Rehman 8d40a508fb search suggestions: Refactor `get_search_result` code path.
The only changes made here is the renaming of `query_operators`
variable to `search_operators`.

That is mostly evident from the fact that we do not need to
make any changes to `node_tests/search_suggestion.js`.

This will be helpful when we combine this function with it's
legacy function. As most of the logical decisions to generate
the result is based on the `query_operators` variable for the
search pills enabled version and the `operators` variable for
the legacy search version.
2020-06-18 01:27:10 -07:00
sahil839 8bd1429f4c css: Move css of upgrade-tip class to app_components.scss.
This commits moves the css of upgrade-tip class from settings.scss
to app_components.scss as this class will also be used in stream
settings page for message-retention-days setting in further commits.

tip class in settings.scss is also moved as it has the same styles as
upgrade-tip class.
2020-06-18 01:17:58 -07:00
Aman Agrawal 42436cedbe stream_popover: Allow editing topic without stream change.
* User can now edit the topic without changing stream.
* An alert is displayed if neither stream or topic changed.
2020-06-18 01:01:47 -07:00
Aman Agrawal baf01795a9 stream_popover: Extract method to show error message in topic edit. 2020-06-18 01:01:44 -07:00
SiddharthVarshney 20f7e6a393 left-sidebar: Update comment.
Since chevron is replaced with ellipsis this
commit will update the comment.
2020-06-18 00:54:18 -07:00
Tim Abbott f28b38bd8c message_fetch: Use first unread anchor for home view.
This fixes one of our oldest important user experience issues, namely
that if you never visit the home view, the Zulip webapp would often
load "deep in the past" because the pointer had not advanced.

Fixes #1529.
2020-06-17 18:08:48 -07:00
Aman Agrawal 77bbbf7ae0 message_fetch: Raise fatal error in an impossible case.
When fetching older/new messages, we used to resort to the pointer
to act as anchor when message list was empty.

This appears to be an impossible case, as
`fetch_status.can_load_newer_messages`
should be false in this case and user cannot be scrolling an
empty message_list in the first case.

Hence, we raise a fatal error to inform user of the same.
2020-06-17 18:08:48 -07:00
jagansivam28 872d43713a settings org: Fix i18n in image_upload_widget.hbs.
Since our translation functions don't support passing a variable into
them and still being found by manage.py makemessages, we need to use
translation function before passing as variable into
image_upload_widget.hbs file.
2020-06-17 17:56:57 -07:00
jagansivam28 3cef5abaf0 settings org: Delete realm-logo-widget.hbs file.
Since we use common HTML template  'image_upload_widget.hbs' for
user avatar, realm icon and realm day/night logo `realm-logo-widget.hbs`
file is replaced by  'image_upload_widget.hbs' therefore
we can delete `realm-logo-widget.hbs` file.
2020-06-17 17:56:57 -07:00
jagansivam28 97b992323c settings org: Deduplicate `upload_realm_logo_or_icon`.
Now that we have arranged our HTML and CSS classes in a similar
fashion for each of the cases, we can remove the duplicated lists of
objects.
2020-06-17 17:56:25 -07:00
jagansivam28 548107632c settings org: Use `image_upload_widget.hbs` for realm day/night logo.
Now we can use common HTML image upload widget template
`image_upload_widget.hbs` for realm day/night logo and
we should access those day/night logo elements using
e.g., "#realm-day/night-logo-upload-widget .realm-logo-elements".
since we use image_upload_widget.hbs for realm day/night logo upload
widget we need to extract CSS for realm day/night logo and
place them separately under `#realm-day-logo-upload-widget`
and `#realm-day-logo-upload-widget` css id.
2020-06-17 17:47:49 -07:00
jagansivam28 e132db3480 settings org: Use `image_upload_widget.hbs` for realm icon.
Now we can use common HTML image upload widget template
`image_upload_widget.hbs` for realm icon. we can access icon
element using "#realm-icon-upload-widget .realm-icon-elements".
also we need to extract CSS for realm icon and place them
separately under `#realm-icon-upload-widget` css id.
2020-06-17 17:47:49 -07:00
Aman Agrawal 3d8181455b unread_ops: Don't read messages when any overlay is open.
Messages are automatically marked read when all the messages in
the current narrow are visible. While this is handy, this is
should not happen when any of the overlays are open.
2020-06-17 13:08:56 -07:00
Tim Abbott a2767e8c50 CVE-2020-14194: Use noopener/noreferrer for external links.
We fixed the main issue of this form in CVE-2020-9444, but the audit
done at that time only included links found in rendered_markdown; this
change completes our audit for links with target=_blank anywhere in
the codebase.
2020-06-16 23:35:39 -07:00
Tim Abbott 4fff858aa2 templates: Fix missing quoting of attributes in HTML templates.
This fixes a bundle of issues where we were missing "" around
attributes coming from variables.  In most cases, the variables were
integers or fixed constants from the Zulip codebase (E.g. the name of
an installed integration), but in at least one case it was
user-provided data that could potentially have security impact.
2020-06-16 23:35:39 -07:00
YashRE42 a0a7170f48 navbar: Use `filter._sub` instead of calling `stream_data`.
Previously, in `make_tab_data()` we were using the stream name,
which we got from the filter, to call `stream_data.get_sub_by_name()`.

This commit switches to just using `filter._sub`, which is simpler and
better.
2020-06-16 18:07:50 -07:00
YashRE42 ab2e7e097a navbar: Switch make_tab_bar conditionals to using filter/sub values.
Previously, this function relied on the return value of
`filter.get_icon()` which made it brittle.
Directly using the properties of the filter and sub object makes this
more explicit about the intentions and robust.
2020-06-16 18:07:50 -07:00
YashRE42 7ea60ea1ab filter: Store reference to `_sub` instead of `_stream_params`.
In commit 4f6377d493 we added
`_stream_params` as a way of storing attributes such as stream name
and stream privacy, this involved adding a few calls within functions
that updated these values (in order to maintain consistency).

This commit replaces `_stream_params` with an always consistent `_sub`
object and removes unnecessary `_stream_params` related code. Once the
`_sub` object is available, calls to `stream_data` may be considered
suspicious as they can often be avoided by just picking the desired
attribute off of the `_sub` object.
2020-06-16 18:07:50 -07:00
YashRE42 b0b53c8543 navbar: Use a more semantic selector in colorize_tab_bar().
Previously, this bit of code was looking for specific icons on the
navbar, but it's more semantic to just look for the `.fa` which is a
direct child of `.stream`. It also makes the code cleaner, to have a
single call here.
2020-06-16 18:07:50 -07:00
YashRE42 6766b0ab43 navbar: Just use stored stream color in `colorize_tab_bar()`.
This commit removes a redundant line of code which was converting from
hex to RGB rounding off and then converting from RGB to hex again.

This line was (mistakenly) introduced in
eb4a2b9d4e while removing a hover effect
that had become irrelevant.
2020-06-16 18:07:50 -07:00
Tim Abbott 5c0a52585c typeahead: Fix buggy code block language notice.
This was incorrectly checking for the empty string, not null.
2020-06-16 17:57:02 -07:00
YashRE42 c3d322f1a7 navbar: Improve spacing between stream name and sub_count. 2020-06-16 17:26:55 -07:00
YashRE42 63f69c48a5 navbar: Fix clickable area between sub_count and narrow_description.
Previously, there was a small dead spot in the click area between the
sub_count and narrow_description, such that the mouse cursor would
switch from pointer to the default.

This commit corrects the dead spot by adjusting the margins and styles
on navbar elements.

This should be workable, but there is scope for improvement especially
given that the current margins and paddings are messy and not very
semantic.

The end result is that the entire navbar becomes a smooth, clickable
region.
2020-06-16 17:26:55 -07:00
YashRE42 71e393575b navbar: Improve click area around stream name.
Previously the click area to open the settings modal was limited to
just the stream name (just the text). This, inconveniently, created a
lot of empty, unclickable space around the stream name.

This commit resolves the problem by:
  * Extracting the title and icon into a separate template as
    `navbar_title_and_icon.hbs` and calls this partial in
    `tab_bar.hbs`.
  * Calling the partial within an <a> tag for stream based narrows
    and in a <span> tag for non-stream narrows.
  * Making some CSS changes so that everything still renders correctly
    (visually).

This commit also:
  * Leads us to "piggy back" all stream based narrow elements on the
    `stream_settings_link` conditional. (Previously the only "piggy
    backing" was by `narrow_description` on `sub_count`, which was
    necessary for the rendering of the `(no description)` string.)

The end goal here is that the entire navbar is clickable. This is a
step towards that goal, but some of the margins on the sub count and
its ::before and ::after pseudo-elements still need to be fixed.
2020-06-16 17:26:55 -07:00
YashRE42 846383f4a0 navbar: Set user count region as click target to open settings modal.
Previously the click area to open the settings modal was limited to
just the stream name (just the text).

A nice goal to strive for here is to make the entire navbar a
continuous clickable region.

This adds the same click action as `stream_name` to the `sub_count`.

There's still scope for improvement after this change because of the
margins on `sub_count::before` and `sub_count::after` as well as
because only the text in `stream_name` is clickable.
2020-06-16 17:26:55 -07:00
YashRE42 94746977ad refactor: Extract pseudoclass based tags out of span in tab_bar.
Currently the styles for the navbar are in a confusing and ugly state.

One of the problems is that we have several styles within the `span`
including some nested pseudotag selectors within the `span`.
This is bad because it gives semantic meaning to the `span` element
which we do not intend. We should remove as many styles which intend
to target "direct children" instead of "direct children that are
spans" and (iff there are styles for the later) then substitute the
"span" for a semantically meaningful class name.

Another problem here is that these pseudotag based selectors aren't
very clear and readable, which is something we can look into
correcting now that they are separate from the `span` tag.

This is a prep commit that aims to set us on the path for further
improvements. It also enables us to switch some tags around and allows
us to use the styles in the `span` block with other selectors via `,`.
This should make no visual or behavioral changes.
2020-06-16 17:26:55 -07:00
Clara Dantas ddbde66af5 realm: Remove Google Hangouts integration.
Google  has removed the Google Hangouts brand, thus we are removing
them as video chat provider option.
This commit removes Google Hangouts integration and make a migration
that sets all realms that are using Hangouts as their video chat
provider to the default, jitsi.

With changes by tabbott to improve the overall video call documentation.

Fixes: #15298.
2020-06-16 17:02:27 -07:00
Sara Gulotta 1cb040647b markdown: Add support for spoilers.
This adds support for a "spoiler" syntax in Zulip's markdown, which
can be used to hide content that one doesn't want to be immediately
visible without a click.

We use our own spoiler block syntax inspired by Zulip's existing quote
and math block markdown extensions, rather than requiring a token on
every line, as is present in some other markdown spoiler
implementations.

Fixes #5802.

Co-authored-by: Dylan Nugent <dylnuge@gmail.com>
2020-06-16 16:14:10 -07:00
jagansivam28 4576742b2f user avatar: Remove `user_avatar_file_input_error` id.
Now we can remove `user_avatar_file_input_error` id and added new class
`image_file_input_error`.we can access this class using
`#user-avatar-upload-widget .image_file_input` so that we can
have only one id at top-level and 'image_upload_widget.hbs`
can be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 c141daa624 user avatar: Remove `user_avatar_file_input` id.
Now we can remove `user-avatar-block` id and added new class
'image_file_input'.we can access this class using
`#user-avatar-upload-widget .image_file_input` so that we can have
only one id at top-level and 'image_upload_widget.hbs`
can be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 4fe066c437 user avatar: Remove `image-block` id.
Now we can remove `user-avatar-block` id and add common class `image_block`.
we can access this class using `#user-avatar-upload-widget .image_block`
so that we can have only one id at top-level and 'image_upload_widget.hbs`
can be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 9fde085536 user avatar: Remove `avatar-spinner-background` id.
Now we can remove the id `avatar-spinner-background` and access spinner
element from `#user-avatar-upload-widget .image_upload_spinner` so
that we can have only one id at top-level and 'image_upload_widget.hbs` can
be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 f609f675ae user avatar: Remove `avatar-spinner-background` id.
Now we can remove the id `avatar-spinner-background` and access spinner
element from `#user-avatar-upload-widget .settings-page-upload-text` so
that we can have only one id at top-level and 'image_upload_widget.hbs` can
be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 0e5c6fa578 user avatar: Remove `user_avatar_upload_button` id.
The upload text element is wrongly named as id=user_avatar_upload_button.
now  we can remove that id and access upload text element from
`#user-avatar-upload-widget .settings-page-upload-text` so that we
can have only one id at top-level  and 'image_upload_widget.hbs` can
be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 df4c8ab1a2 user avatar: Remove `user_avatar_delete` id.
We can remove id="user_avatar_delete" and access delete-text from
`#user-avatar-upload-widget .settings-page-delete-text` so that
we can have only one id at top-level  and 'image_upload_widget.hbs`
can be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 b3fca96254 user avatar: Remove user_avatar_delete_button id.
we can remove `user_avatar_delete_button` id and access delete button
from `#user-avatar-upload-widget .settings-page-delete-button` so that
we can have only one id at top level and 'image_upload_widget.hbs`
can be more dynamic so we can use for other similar widgets also.
2020-06-16 12:12:21 -07:00
jagansivam28 95de217326 user avatar: Rename and convert "#user-settings-avatar".
Renaming "user-settings-avatar" to "image_upload_button" since the
`user-settings-avatar` name is irrelevant/confusing for the upload
button, and converting the id into a class so that we could just have
only one outer id.
2020-06-16 12:12:21 -07:00
jagansivam28 14a77c8b9a settings: Refactor `image_upload_widget.hbs`.
We can check for the `is_editable_by_current_user` condition once in
the upper level instead of checking twice in middle for the same
conditions and to match the implementation of style realm icon and
realm logo since similar implementation between avatar, logo, the icon
will help us to use `image_upload_widget.hbs` for logo and icon
widgets also.

This likely fixes a bug with the delete text being shown incorrectly
for non-administrator users.
2020-06-16 12:12:21 -07:00
jagansivam28 20740de700 settings: Extract image_upload_widget.hbs from avatar upload widget.
We extract image_upload_widget.hbs from user avatar upload widget.
The plan is to the same HTML template for all 4 widgets (user avatar,
icon, day logo, night logo) across the two settings UIs and different
image upload widgets as possible in future.

This breaks i18n; we'll fix it in follow-up work.
2020-06-16 12:12:04 -07:00
jagansivam28 19490fe8b0 settings: Change user avatar image display HTML.
This changes the user avatar image display implementation to more
closely match how the realm icon and realm logo image features are
structured.  This is early preparatory work towards sharing this code
between the various widgets.
2020-06-16 12:03:50 -07:00
Ryan Rehman 62aab0d9ee message view: Fetch again when "newest" is discarded.
The previous commit introduced a bug where it was not intuitive
for the user to scroll again.
For the current narrow, new messages were fetched again only when
scrolled to the bottom as usually there are many messages displayed.

However when the edge case mentioned in the previous commit
occured, it was not very obvious that a scroll should be done
or we could already be at the bottom and could not scroll again
to trigger a fetch.
`message_viewport.at_bottom` has a relevant comment explaining
this behaviour.

The previous commit handled the rare race condition. However,
there is a possibility that the rare race condition might occur
again while we are handling the previous condition.

This commit resolves these 2 problems by performing a re-fetch
while also resetting the `expected_max_message_id` and this
approach has two benefits:

1. The reset prevents an infinite loop, if somehow the expected
   max message's id gets corrupted resulting in a situation
   where the server can never send an id greater than that even
   after fetching.

2. Even though we stop after just one re-fetch the race condition
   might recursively occur while we handle the previous race
   condition. And even though the reset prevents multiple re-fetches,
   we don't have the missing message problem.

   This is because we treat the next race condition as a new race
   condition instead of it being a continuation of the previous.

   The `expected_max_message_id` gets updated again, on receiving
   a new message. Thus it can again enter the `fetch_status` block
   as the reset value is updated again.
2020-06-16 11:11:16 -07:00
Ryan Rehman 6637f2dbb7 message list: Render new messages only after "newest" is found.
If a user sends a message while the latest batch of
messages are being fetched, the new message recieved
from `server_events` gets displayed temporarily out of
order (just after the the current batch of messages)
for the current narrow.

We could just discard the new message events if we havent
recieved the last message i.e. when `found_newest` = False,
since we would recieve them on furthur fetching of that
narrow.
But this would create another bug where the new messages
sent while fetching the last batch of messages would not
get rendered. Because, `found_newest` = True and we would
no longer fetch messages for that narrow, thus the new
messages would not get fetched and are also discarded from
the events codepath.

Thus to resolve both these bugs we use the following approach:

* We do not add the new batch of messages for the current narrow
  while `has_found_newest` = False.
* We store the latest message id which should be displayed at the
  bottom of the narrow in `fetch_status`.
* Ideally `expected_max_message_id`'s value should be equal to the
  last item's id in `MessageListData`.
* So the messages received while `has_found_newest` = False,
  will be fetched later and also the `expected_max_message_id`
  value gets updated.
* And after fetching the last batch where `has_found_newest` = True,
  we would again fetch messages if the `expected_max_message_id` is
  greater than the last message's id found on fetching by refusing to
  update the server provided `has_found_newest` = True in `fetch_status`.

Another benefit of not discarding the events is that the
message gets processed not rendered i.e. we still get desktop
notifications and unread count updates.

Fixes #14017
2020-06-16 10:47:52 -07:00
sahil839 791e5de5de api: Remove is_old_stream property from the stream objects.
This commit removes is_old_stream property from the stream objects
returned by the API. This property was unnecessary and is essentially
equivalent to 'stream_weekly_traffic != null'.

We compute sub.is_old_stream in stream_data.update_calculated_fields
in frontend code and it is used to check whether we have a non-null
stream_weekly_traffic or not.

Fixes #15181.
2020-06-16 10:26:33 -07:00
Ryan Rehman c7e39ef090 narrow: Move the top of narrow notices to `message_scroll.js`.
We refactor these 2 notices to match with the loading indicators,
thus they have been moved to `message_scroll.js`.

After a successful message fetch, we have logic to decide whether
we want to display the notices and also whether we want to hide
the loading indicators (which are already displayed).

We also conservatively hide the notices similar to the indicators
every time we narrow.
The only exception is that we show the history limit notice on
deactivating the narrow (visiting `home_msg_list`).
2020-06-16 00:21:21 -07:00
Ryan Rehman 577055fb54 message view: Fix double loading indicator situation.
Since on narrowing we call `load_messages_for_narrow`,
which fetches both top and bottom messages, two loading
indicators were temporarily displayed.
This was also the case for the `home_msg_list` when we
call `mesage_fetch.initialize` on startup.

To resolve this we do not display the bottom loading
indicator (for new messages), if the older messages
are being fetched too. This is only for the initial
narrow change, and the bottom loading indicator will
be displayed correctly when the user is at the bottom.

This fixes a regression introduced when we added bottom loading
indicators at all, which was temporarily reverted in
67053ff479 before being restored in the
last couple commits.
2020-06-15 22:28:39 -07:00
Ryan Rehman a630f291b9 message view: Refactor top loading indicators.
This commit makes the `loading_older_messages_indicator` similar
to the `loading_newer_messages_indicator`.
Now all the decisions about whether to show a loading indicator
will be made from the `fetch_status` API. We still hide the
indicators everytime the view is changed, as explained in the
previous commit.
2020-06-15 22:26:35 -07:00
Ryan Rehman e0b1fdb81c message view: Show home view bottom loading indicators.
As explained in 67053ff479,
multiple message fetches may be taking place at the same time.
So some other narrows / the home message list's indicator might
get shown for the current narrow.

This commit moves the updation of the indicators display logic
to the `fetch_status` API.
Now the `loading_newer_messages_indicator` gets displayed along
with the `loading_newer` = true updation for that narrow's message
list, i.e. just before we send the API request. But only if the
message list we are fetching matches with our current message list.

The same indicator is hidden similarly, along with the
`loading_older` = false updation for that narrow's message list,
i.e. just after the success response is recieved. But only if
the message list whose data we recieved  matches with our current
message list.

Also the indicators are hidden everytime we activate narrow
or deactivate narrow (`home_msg_list`). And on entering
`narrow.activate` we fetch for it's messages so they get
displayed again, if need be.
This is the reason `message_scroll.hide_indicators();` was
moved to a location above `fetch_messages`.

Fixes #15374.
2020-06-15 22:25:41 -07:00
Ryan Rehman b40c8bd9cd search suggestions: Refactor `get_default_suggestion`.
This commit actually just deletes the `get_default_suggestion`
function while the `get_default_suggestion_legacy` function's
logic remains the exact same, it is just renamed.

Since the operator can never be undefined as mentioned in the
previous commit, we do not require the check with undefined
and as a result the, `if (suggestion)` condition can be removed.
2020-06-15 20:16:40 -07:00
Ryan Rehman 72816b9408 minor: Refactor get_search_result of search suggestions.
The 3 changes made here are as follows:
* The if block for both the functions is simplified as
  `Filter.parse` will always return an array and also
  [].slice(0, -1) === [] is true.
* The code where `base_operators` is declared is moved
  to just before where it is actually used.
* The `base` variable declaration is changed to match
  the pattern of that present in the non-legacy function.
  Its value remains the same.

This is a prep commit for when we want to merge the
`get_search_result_legacy` and `get_search_result` functions.
2020-06-15 20:16:40 -07:00
Ryan Rehman 9c5d9c961c search: Parse search string correctly.
This is the exact same bug as observed in
02ab48a61e.

The bug is in the way we invoke `Filter.parse`.
`Filter.parse` returns a list of operators which
can contain only one 'search' term at max.
All strings with the 'search' operator present
in the query are combined to form this 'search'
term.

However on concatenating two filters we may get
two terms containing the 'search' operator. This
will lead to the search suggestions getting
generated based on only the last 'search' operator
term instead of all the terms having the 'search'
operator.

This is evident from the test change as suggestions
should be based on "s stream:of" but instead they
were based on just the latest query.
2020-06-15 20:16:40 -07:00
YashRE42 46247623fc navbar: Fix navbar for unknown streams.
In commit 35c8dcb599 we introduced the
`_stream_params` object within filter.js but we didn't correctly
handle cases where `_stream param`s is undefined within `get_title()`,
`generate_url()` and `get_icon()`, which cause the navbar to if eg a
guest user tries to access a stream they weren't subscribed to.

This commit fixes this by:
  * Adding the relevant checks
  * Adding node tests that include non-existent streams.
  * Adds the 'question-circle-o' icon for non-existent stream narrows.

A side note here is that "non-existent streams" fall under
"common narrows" as per our current definitions, which doesn't really
make sense but shouldn't bother us.

Fixes: #15387.
2020-06-15 16:48:24 -07:00
YashRE42 1e8b922548 navbar: Add missing internationalization to navbar.
This commit adds translation tags to a few user facing strings which
weren't translated prior:
 - "Unknown streams" text and description.
 - "All messages" heading.
 - Tooltip text for precise count of subscribed users.

The numeric count itself is not translated, because we do not do
similar anywhere else in the UI.
2020-06-15 16:48:24 -07:00
Tim Abbott 3087fbe854 stream_topic_history: Pluralize remove_message.
Since this function now does a bulk operation with several messages,
we should make sure it's named appropriately.
2020-06-15 10:52:04 -07:00
Tim Abbott ba2de34414 message edit: Move and clarify an important comment. 2020-06-15 10:47:10 -07:00
Aman Agrawal 0cffaa7b5d ui: Upgrade remove_message to allow removing messages in bulk.
We simply pass the visible message ids to remove_and_rerender
which supports bulk delete operation.

This helps us avoid deleting messages in a loop which freezes the
UI for the duration of the loop.
2020-06-15 10:41:12 -07:00
Aman Agrawal ccc0c8706c delete_message: Support `bulk_message_deletion`.
Fixes #15285
This event will be used more now for guest users when moving
topic between streams (See #15277). So, instead of deleting
messages in the topic as part of different events which is
very slow and a bad UX, we now handle the messages to delete in
bulk which is a much better UX.
2020-06-15 10:41:12 -07:00
Gittenburg 52b7dac6af emoji_picker: Fix DOM race condition with offsets.
We need to wait for the DOM to be ready before we save the
section_head_offsets ... otherwise they can be off.

Fixes #15380.
2020-06-15 10:34:07 -07:00
Anders Kaseorg 74c17bf94a python: Convert more percent formatting to Python 3.6 f-strings.
Generated by pyupgrade --py36-plus.

Now including %d, %i, %u, and multi-line strings.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-14 23:27:22 -07:00
sahil839 18429cfd29 realm: Allow only owners to set message retention policy for a realm.
This commits adds restriction on admins to set message retention policy.
We now only allow only organization owners to set message retention
policy.

Dropdown for changing retention policy is disabled in UI for admins also.
2020-06-14 21:23:53 -07:00
sahil839 87e72ac8e2 realm: Allow only owners to configure auth methods for a realm.
This commit adds the restriction on configuring auth methods for
admins. We now allow only owners to configure the auth methods
for realm.
2020-06-14 21:23:51 -07:00
sahil839 a6f31c3668 settings: Disable organization deactivation button for admins.
This commit adds the code to disable deactivate organization button
for admins. We now allow only owners to deactivate the organization.

The backend implementation for allowing only owners to deactivate
is already added in 81c28c1.
2020-06-14 21:20:30 -07:00
sahil839 dbd64c4362 settings_users: Only owner can deactivate other owners.
This commit adds the restriction of deactivating owners for admins
by disabling the deactivating button in the UI. Only owners are
allowed to deactivate other owners. The backend part of this is
already implemented in 86b52ef.
2020-06-14 21:20:30 -07:00
sahil839 c7a68d60f3 realm owner: Add frontend implementation of owner role.
This commit adds the option of owner role in user role dropdown
and also takes care of the restrictions while adding/removing
owner status of the user.
This commit also handles the places where we dispaly role of
the user in UI.
2020-06-14 21:20:30 -07:00
SiddharthVarshney 177ec5b2d5 sidebars: Replace chevron with ellipsis-v icon from the sidebars.
The chevron sometime can be confused as an icon for expanding the
stream topics especially for the new users.

This commit replaces the confusing chevron icon from the stream-sidebar,
topic-list, user-presence-row, all-messages and starred-messages with
ellipsis-v icon(vertical three dots).

Fixes: #7115
2020-06-14 20:57:43 -07:00
Siddharth Varshney 5b940fc1b8 ui: Fix stream filter top margin in left-sidebar.
Because of the negative margin in `#stream_filters` the
`STREAMS` header was slighty overlapping the first
stream filter resulting sharp border.
2020-06-14 16:09:33 -07:00
Siddharth Varshney b7100d8293 ui: Fix simplebar position in the left-sidebar.
The left simplebar sometime interferes with the
chevrons on the stream filters.

This commit reduces the width of active stream filter
by adding margin-right and hence fixes the overlap of
the simplebar over the active filters
2020-06-14 16:09:33 -07:00
Hemanth V. Alluri 5bbfaa225b webhooks/circleci: Overhaul the CircleCI integration.
This change should add a lot more information to
our CircleCI integration's output.

Signed-off-by: Hemanth V. Alluri <hdrive1999@gmail.com>
2020-06-14 13:14:55 -07:00
Ryan Rehman 542a3dea77 minor: Refactor the top of narrow notices.
The changes made here are as follows:
* We rename `show_history_limit_message` and `hide_history_limit_message`
  to `show_history_limit_notice` and `hide_history_limit_notice`
  respectively.
* We rename `hide_or_show_history_limit_message` to
  `update_top_of_narrow_notices` as now this function is responsible
  for updating the history limit notice as well the end of results
  notice.
* We extract 2 functions responsible for hiding and showing the end
  of results notice, similar to that of the history limit notice.
  All instances of `$(".all-messages-search-caution").hide();` are
  replaced with the call of `hide_end_of_results_notice` function.
2020-06-14 11:06:54 -07:00
Ryan Rehman e0b1096253 narrow: Show streams:all notice only after "oldest" is found.
The streams:all advertisement notice in search should only appear
after all results have been fetched to indicate we've gotten to the
beginning of the target feed.

The notice gets hidden at the start of `narrow.activate` and is
shown just after we've fetched an older batch of messages if the
"oldest" message has been found.
Previously it would get displayed after the first fetch which
takes place from `narrow.activate`. Thus we move this logic to
`notifications.hide_or_show_history_limit_message` which gets
called after a successful message fetch.

Since the home message view contains all the messages we are not
required to display this notice. However if it is already shown
we hide it as a part of `handle_post_narrow_deactivate_processes`.

To accomplish this we need to add `has_found_oldest` key to the
`fetch_status` API.
We also removed the `pre_scroll_cont` parameter as this was it's
only use case and is now redundant.
2020-06-14 11:06:54 -07:00
Aman Agrawal bcf4bf1222 recent_topics: Optimize filters_should_hide_topic.
We now get info from other libraries when it is required
in the current set of filters.
2020-06-14 11:05:57 -07:00
Aman Agrawal 57aee34845 recent_topics: Rename `muted` filter to `include_muted`.
This adds clarity to what this filter really does.
Revert muted variable rename via
e769323d0c.
2020-06-14 11:05:57 -07:00
Aman Agrawal 8a163840f4 message_events: Change narrow after updating local data.
On update_message events, we were changing narrow before we
locally updated the data, this resulted in a weird mismatch
between locally available data and that fetched from the server.
Ideally, we should not be requesting any data from the server
in most scenarios since the messages for new narrow is
locally available.

As a result, the new narrow didn't have any messages other than
a breadcrumb message. To fix this, we change narrow post
locally updating the data.

The original bug was not exactly reproduced, but a similar version
of it was simulated and was found to be fixed.

Tweaked by tabbott to preserve an optimization.
2020-06-14 11:02:50 -07:00
Tim Abbott e60771020a message_edit: Move selected ID fetching logic earlier.
This ensures that we do this fetch, which is intended to get data on
the pre-event state, before we start perturbing the message list data
structures via rerendering.
2020-06-14 10:49:22 -07:00
Gittenburg 12671fbc66 emoji_picker: Add missing Flags category.
Apparently iamcal/emoji-data has a dedicated category for flag emojis.

And get_all_emoji_categories() in emoji_picker.js doesn't return the
Flags category, because we haven't declared that category in our emoji
data logic.

Note that the category looks quite sparse because it lacks country
flags, since we don't yet support emojis combined with a ‍Zero Width
Joiner (ZWJ) (see #992 & #11767).

Fixes #15303.
2020-06-14 10:41:00 -07:00
Tim Abbott 67053ff479 message_fetch: Revert home view bottom loading indicators.
In the very common event that one ends up looking at not the home view
while the browser is catching the home view up, this ended up
resulting in loading indicators being displayed at the bottom of
whatever narrowed view one was looking at incorrectly.

A proper fix for this will involve making these loading indicators
conditional on what view one is looking at.  Since one can change
views rapidly from a narrowed message list to the home view (and in
the future, between narrows), probably the best approach would be to
move the state in `message_scroll.js` the state for whether a loading
indicator is expected to be shown into the `fetch_status` data
structures, and then make all decisions about whether to show/hide a
loading indicator be calls to a function with a name like:

current_msg_list.data.fetch_status.update_newer_loading_indicator()

At least, that's probably what we should call in places like
`narrow.deactivate()`.
2020-06-14 10:05:35 -07:00
Tim Abbott a1259c2521 narrow: Hide loading indicators unconditionally before setting state.
Before 77a26d41ae, there was only one
loading indicator (at the top of the page), so the if/else logic for
hiding loading indicators was correct, if confusing.  Since we've now
added a new bottom-of-page loading indicator, it's important to have
the logic correctly reset the state to hide all existing loading
indicators on narrowing, and then just render the ones needed/desired
by the current view.

Combined with similar code in `narrow.deactivate`, this achieves the
goal that we correctly update loading indicator state when switcing
views.
2020-06-14 09:58:23 -07:00
SiddharthVarshney 8636d82eba settings: Use icon to play notification sound. 2020-06-13 16:46:05 -07:00
Aman Agrawal 0327ec4c4b recent_topics: Show unread counts similar to other UI elements. 2020-06-13 16:29:19 -07:00
Aman Agrawal 9b862cd73f recent_topics: Select the filter text on lauch.
This will allow users to easily search for new topics
without losing the last filtered text.
2020-06-13 16:29:19 -07:00
Aman Agrawal 79d829bda1 Revert "recent_topics: Set 'unread' and 'participated' as default filters."
This reverts commit 0aeadd2c86.
2020-06-13 16:29:19 -07:00
Aman Agrawal a1cca4544c recent_topics: Improve variable naming of tableFixHead. 2020-06-13 16:29:19 -07:00
Aman Agrawal 347c0dc80f recent_topics: Improve code level documentation.
Improved documentation of set_filter and show_selected_filters
functions.
2020-06-13 16:29:19 -07:00
Aman Agrawal 2d6ada4360 recent_topics: Use get_topic_key everywhere.
This deduplication helps with readability.

Pass get_topic_key in recent_topic_row instead of
computing it in DOM.

Fix broken test_update_unread_count
after this change. This was a regression
which went unnoticed.
2020-06-13 16:29:19 -07:00
Aman Agrawal e769323d0c recent_topics: Refactor is_topic_hidden.
* We now only get info from other libraries when required.
* muted renamed to include_muted.
* function renamed to filters_should_hide_topic.
2020-06-13 16:29:19 -07:00
Aman Agrawal 6490f666af recent_topics: Fix boundary typo. 2020-06-13 16:29:19 -07:00
Aman Agrawal d7d5bc208c recent_topics: Rename count_senders for clarity. 2020-06-13 16:29:19 -07:00
Aman Agrawal 5931b69c57 recent_topics: Add note about reify_message_id_if_available. 2020-06-13 16:29:19 -07:00
Aman Agrawal 4aeb02f73d stream_header_colorblock: Create resuable css class.
stream-selection-header-colorblock css class can now be used
to reproduce stream header color block everywhere.
2020-06-13 15:38:40 -07:00
Steve Howell 22bf4696f5 refactor: Avoid triggers in stream_edit.
We extract stream_edit.rerender to make
the live-update code easier to follow.

The function should eventually be inlined,
but I want to clean up some other stuff first.
2020-06-13 15:35:39 -07:00
Steve Howell 186973cde2 refactor: Extract add_peer and remove_peer helpers.
These are basically shims for some deeper refactorings.

I basically just try to make the code express the
problems more clearly:

    - use stream_name instead of sub
    - make early-exit more explicit
    - make it clear that add_subscriber needlessly
      requires a name
    - make it clear we have an unnecessary loop

I also fixed some phony data in the test.
2020-06-13 15:35:39 -07:00
Steve Howell b965766f87 refactor: Call compose_fade without triggers.
We are trying to phase out the trigger-event way
of telling modules to do something.

In this case we not only remove the indirection
of the event handler, but we also get to remove
`compose_fade` from the `ui_init` startup sequence.

This also has us update `compose_fade` outside
the loop, although that's only a theoretical
improvement, since I don't think `peer_add` events
every actually include multiple streams.

To make the dispatch tests a little flatter, I
added a one-line change to zjsunit to add
`make_stub` to `global`.

To manually test:
    * have Aaron reply to Denmark (keep compose box open)
    * have Iago add Hamlet to Denmark
    * have Hamlet unsubscribe
2020-06-13 15:35:39 -07:00
Steve Howell 9d9342c2a5 dead code: Remove integration_bot_widget code.
This was work in progress from summer 2017
that never got completed.

See 534aa0b105
2020-06-13 15:35:39 -07:00
SiddharthVarshney 60010449d2 icon: Import a font-awesome 5 third party icon.
This is a prep commit for replacement of chevron
from sidebars.

This commit will add ellipsis-v icon in svg format downloaded
from font-awesome 5. This has to be done because font-awesome 4.7
(the version we are using) does not have this icon with
circular dots.

And font-awesome 5 as a whole doesn't make sense to upgrade to because
it's intentionally semi-crippled as part of their business plan.

Also include entry in THIRDYPARTY and Licence details.
2020-06-11 17:15:55 -07:00
SiddharthVarshney b82ca432bb right-sidebar: Fix the height of user presence list elements.
This will adjust the height of user presence list elements to
match with the left-sidebar list elements i.e. 23px.

Extra margin is removed to avoid increase in too much spacing
between elements.
2020-06-11 17:14:09 -07:00
SiddharthVarshney 46a98d2eec right-sidebar: Fix menu icon hover color.
This will fix the menu icon hover effect for the day mode.
2020-06-11 17:14:09 -07:00
Anders Kaseorg 365fe0b3d5 python: Sort imports with isort.
Fixes #2665.

Regenerated by tabbott with `lint --fix` after a rebase and change in
parameters.

Note from tabbott: In a few cases, this converts technical debt in the
form of unsorted imports into different technical debt in the form of
our largest files having very long, ugly import sequences at the
start.  I expect this change will increase pressure for us to split
those files, which isn't a bad thing.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 16:45:32 -07:00
YashRE42 6506447bf1 navbar: Only set searchbox text when displaying the searchbox.
Previously, the navbar failed at managing the searchbox text state in
cases where, eg, the user performs navigation by browser history.

This commit resolves the issue by ensuring that the searchbox text is
only (and always) set when the searchbox is made visible, and as such
there is no "state" to manage and we will always display the correct
text.

It also adds a test in `search_legacy.js` to make sure that the search
text is placed as intended.

Fixes: #14771.
2020-06-11 15:49:12 -07:00
YashRE42 939f040674 navbar: Extract `reset_searchbox_text` in tab_bar.
The navbar currently fails at managing the searchbox text state in
cases where, eg, the user performs navigation by browser history.
This is a prep commit that will help resolve the bug.
2020-06-11 15:49:12 -07:00
Steve Howell 5c6fb8dbbf code cleanup: Avoid shadowing the tab_bar global.
I tried to make the most minimal change here
possible, since I don't really know this module
well.  Possible alternatives were:

    * $('#tab_bar') everywhere
    * elem
    * tab_bar_elem

I don't feel strongly.

Long term I believe we intend to change the name
of this module to something more like `navbar.js`???
2020-06-11 11:05:06 -07:00
Steve Howell 863660281e code cleanup: Use exports for internal references.
When we call functions inside our own modules that use
the `window.foo = exports` pattern, we have always had
a pretty strong preference to call `exports.internal_function`
instead of `foo.internal_functions`.

The stragglers here weren't violating this convention
for any intentional reason.  Some of the places here
probably were part of code moves where somebody
(probably me) moved functions into the modules to avoid
unnecessary indirection, and I missed a spot where I
could change from `presence` to `exports` (or whatever).

And other places are probably just kinda arbitrary
decisions by the original developer, and we just haven't
bothered to clean it up until now.
2020-06-11 11:05:06 -07:00
jagansivam28 b40597cf3e settings_org: Combine upload_realm_logo and upload_realm_icon function.
This combines `upload_realm_logo` and `upload_realm_icon` into single
function called `upload_realm_logo_or_icon`.  The functions wer near
duplicates.

Additional refactoring should be able to deduplicate the logic further.

Part of #14730.
2020-06-10 17:05:29 -07:00
jagansivam28 1c3485647f realm logo: Refactor upload_widgets.js.
We can remove a {{theme_mode}}-settings class on the upload button
and access day/night from `.closest("realm-logo-section")`
so that only the outer ID differs between the two widgets.

Part of #14730.
2020-06-10 17:02:06 -07:00
Vinit Singh 8b2098f34d refactor: Add css nesting to #out-of-view-notification. 2020-06-10 17:00:39 -07:00
Vinit Singh dc96b8a23d drafts: Show drafts count on draft button.
This change displays the number of currently saved drafts
on the draft button like "Drafts (2)".

Patially resolves #5591.
2020-06-10 17:00:39 -07:00
Anders Kaseorg 67e7a3631d python: Convert percent formatting to Python 3.6 f-strings.
Generated by pyupgrade --py36-plus.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-10 15:02:09 -07:00
YashRE42 4f6377d493 navbar: Correctly recolor navbar icon when stream is renamed.
Previously, renaming the stream would cause `colorize_tab_bar` to fail
because the search filter would provide it the old stream name and the
look up for the stream color would fail.

A quirk of how this system currently works makes it so that even
though the filter is set to the old stream name (and so becomes
inconsistent with the stream_data state) the `_stream_params` object
is maintained to be consistent with stream_data and as such can be
relied upon to find the correct color of the icon.
2020-06-10 14:25:18 -07:00
YashRE42 e389129f34 subs: Call `filter.fix_stream_params` when updating stream name.
Previously the navbar did not live update the stream name correctly.

The correct behaviour was blocked on the `_stream_name` prop on the
filter object. The original purpose for maintaining this prop was
convenience, to reduce calls to `subs`, however, it would become
inconsistent with the value from `subs` on stream rename.

In this commit we add a call to `filter.fix_stream_params` in
`subs.update_stream_name`. This fixes live rerendering in the navbar,
despite the fact that searchbox in the nav (and the filter object via
`filter.operands("stream")[0]`) will still have the old name.

This is a slightly hacky way of masking some of the problems in the
Filter object. However, it should make do until we migrate to a stream
ID based state there.

Fixes: #14728.
2020-06-10 14:25:18 -07:00
YashRE42 96e272081d navbar: Add globe icon to navbar for web public streams.
Prior to this commit, the navbar didn't display web public streams as
any different from ordinary streams.

Now, we show a globe icon for web public streams. This commit also
adds a node test for the same.

We also modified the navbar behaviour table, which is the following
dropbox paper:
https://paper.dropbox.com/doc/Navbar-behavior-table--A0sp57z~7R5PeHuxHL__Gn5ZAg-cNOGtu7kSdtnKBizKXJge
2020-06-10 14:25:18 -07:00
YashRE42 bb6ce47c33 navbar: Live update icon for stream privacy changes.
Prior to this commit the icon in the navbar didn't live update to
reflect changes in stream privacy.

Here, we add a call to `tab_bar.render_title_area` in
`subs.update_stream_privacy()`, to enable live updates on the icon.

Fixes #14728.
2020-06-10 14:25:18 -07:00
YashRE42 d496304caa subs: Call `filter.fix_stream_params` when updating stream privacy.
The navbar currently does not live update the stream icon correctly
for changes in stream privacy.

One place where the correct behaviour gets blocked is on the
`_is_stream_private` prop in the filter object. We keep props such as
this for convenience, to reduce calls to `subs`, however, this prop
becomes inconsistent with the value we get from `subs` when the stream
privacy is updated.

In this commit we add a call to `filter.fix_stream_params` in
`subs.update_stream_privacy`. This change does not fix the live
rerendering in the navbar because we don't call redraw yet, but
it's a prep commit to towards that goal
2020-06-10 14:25:18 -07:00
YashRE42 35c8dcb599 filter: Extract `get_stream_params` and `fix_stream_params`.
The navbar currently does not live update the stream name or the icon
for stream privacy correctly.

One place where the correct behaviour gets blocked is on the
`_stream_name` and `_is_stream_private` props on the filter object.
We keep these props for convenience, to reduce calls to `subs`,
however, these props become inconsistent with the values from `subs`
when the stream is renamed or stream privacy is changed.

This refactor extracts out `get_stream_params` and `fix_stream_params`
methods as a prep commit towards correcting the problem, but does not
make any behavioural changes.

This is a prep commit for solving #14728.
2020-06-10 14:25:18 -07:00
YashRE42 b292c30d6a subs: Move comment about live update for stream names in navbar.
A comment about the difficulties relating to live updating stream
names in the navbar was incorrectly placed within the function for
live updating stream descriptions in
023187b3f1.

This moves the comment to the right place.
2020-06-10 14:25:18 -07:00
Clara Dantas 451ea753a2 settings_users: Simplify get_item function. 2020-06-10 12:14:58 -07:00
Tim Abbott 6f159ce5c5 templates: Clean up wording around topic moves.
This switches us to cleaner, simpler labels for moving topics; while
also avoiding claiming that we're only allowing moving topics to other
streams.
2020-06-10 12:12:17 -07:00
Tim Abbott 26083e4b10 popovers: Improve label for choosing colors. 2020-06-10 09:55:51 -07:00
Aman Agrawal 7585776c76 stream_header: Fix broken header color and outflowing boundary.
The stream header was moved below the selection option and the
boundary selection input was overflowing, both were fixed via
this commit.
2020-06-10 09:50:49 -07:00
Aman Agrawal 9b9154be91 recent_topics: Set focus on input element on launch. 2020-06-09 22:08:31 -07:00
Aman Agrawal ec00e39e45 recent_topics: Fix misplaced thead border and adjacent css properties. 2020-06-09 22:08:31 -07:00
Aman Agrawal e5e02319b4 recent_topics: Show msg if no topics are visible. 2020-06-09 22:08:31 -07:00
Aman Agrawal ad2e7026c8 recent_topics: Add functionality to sort rows via header.
Add custom sorting for stream and topic headers.
2020-06-09 22:08:31 -07:00
Aman Agrawal 084cbd4ff7 recent_topics: Use list_render to display topic rows.
This fixes the laggy behaviour when there are 2k+ rows to processes,
since list_render uses lazy render based on what rows are visible
to the user.
2020-06-09 22:08:31 -07:00
Aman Agrawal 0aeadd2c86 recent_topics: Set 'unread' and 'participated' as default filters.
Decided after a poll on czo.
2020-06-09 22:08:31 -07:00
Aman Agrawal 33ace41ffe recent_topics: Add filter button to show muted topics.
We don't show muted streams/topics by defualt. Only when user
turns on muted filter.
2020-06-09 22:08:31 -07:00
Aman Agrawal 89fe133d2d recent_topics: Add button to clear search. 2020-06-09 22:08:31 -07:00
Aman Agrawal 9f50825610 recent_topics: Only rerender when recent_topics is visible.
We update the data in the background but only update the view
when recent topics is visible to user.
Also, we always do a complete rerender on launch.
2020-06-09 22:08:31 -07:00
Aman Agrawal e8cc9da4c7 recent_topics: Don't complete_rerender on filter change.
We store the relevant data to hide/show a topic in the row itself,
and use jquery to hide/show it on filter change.

This also fixes search breaking the set filters.
2020-06-09 22:08:31 -07:00
Aman Agrawal 272a3eed8a recent_topics: Show unread count after topic name.
We remove the non-obvious unread count column and move the unread
counts to be displayed after topic.
2020-06-09 22:08:31 -07:00
Aman Agrawal e6611089fd recent_topics: Update stored message id of locally echoed messages.
This fixes the bug that message was undefined since we used to store
locally echoed message id and were not updating it after new message
id for the same message was received from the server.
2020-06-09 22:08:31 -07:00