Commit Graph

10243 Commits

Author SHA1 Message Date
Pragati Agrawal d453520022 settings_user: Fix event propagation for bot and user edit form modal.
When the user clicks a button that opens a modal, and if we don't break off
the corresponding click event. This condition in the global click handler
will become true and enables all mouse events outside modal.

```js
    $(document).on('click', function (e) {
        ...
        // If user clicks outside an active modal
        if ($('.modal.in').has(e.target).length === 0) {
            // Enable mouse events for the background as the modal closes
            $('.overlay.show').attr("style", null);
        }
```

Related to #12369.
2020-06-19 12:53:13 -07:00
Tim Abbott 9173f32a10 api docs: Fix formatting in changelog.
The CSS changes prevent our API docs markdown processor from
preserving line breaks within inline code block content.
2020-06-18 22:38:05 -07:00
Siddharth Varshney bbb07aed38 portico: Add hint text for invite only realm on /login.
Fixes: #10542

This will make obvious for users what to do when they are not able to login.

Test added by hackerkid.
2020-06-18 17:23:11 -07:00
sahil839 821e25ffb0 streams: Show message retention policy details in subscription_type text.
This commit adds message retention policy details in the subscription_type
text below the stream description.

We do not show any text when realm-level settings is set to forever and
stream-level is set to either forever or realm_default.
2020-06-18 17:13:04 -07:00
sahil839 d9b7228444 streams: Add frontend to set/update message_retention_days of a stream.
This commit adds frontend support for setting and updating message
retention days of a stream from stream settings.

Message retention days can be changed from stream privacy modal of the
stream and can be set from stream_creation_form while creating streams.

Only admins can create streams with message_retention_days value other
than realm_default.

This commit also contains relevant changes to docs.
2020-06-18 17:00:34 -07:00
sahil839 5f63d6b7f1 streams: Enable live update of stream_post_policy in subscription_type text.
This commits adds the code for live update of stream_post_policy in
subscription_type text in stream settings.

This is done by passing stream_data.stream_post_policy_values to the
template data, which were not passed previously and the if conditions
were not evaluated correctly.
2020-06-18 17:00:34 -07:00
Rohitt Vashishtha 6ea3816fa6 markdown: Use html5 <time> tag for timestamps.
Previously, we had implemented:
    <span class="timestamp" data-timestamp="unix time">Original text</span>
The new syntax is:
    <time timestamp="ISO 8601 string">Original text</time>
    <span class="timestamp-error">Invalid time format: Original text</span>

Since python and JS interpretations of the ISO format are very
slightly different, we force both of them to drop milliseconds
and use 'Z' instead of '+00:00' to represent that the string is
in UTC. The resultant strings look like: 2011-04-11T10:20:30Z.

Fixes #15431.
2020-06-18 14:11:33 -07:00
Steve Howell 9423d150ac emoji_picker: Add expectOne to emoji_picker.navigate.
There is apparently some way to have two instances
of `.emoji-popover-emoji-map`, although I can't
reproduce it.

This causes an `expectOne` check to fail fairly
deep in the stack.

Now we report it more directly.

This commit and a few previous ones mostly
address #15348 by trying to either a) not
depending on having a single instance of
the popover or b) making it more explicit
in cases where do expect that invariant.

Fixes #15348
2020-06-18 13:18:50 -07:00
Steve Howell 91dec2729f refactor: Extract $emoji_map in navigate().
This is just a pure refactor for now, but
we may want to modify this to more precisely
determine the active map (in case multiple
pickers are open for some reason).
2020-06-18 13:18:50 -07:00
Steve Howell 37e57e0aaa emoji picker: Only modify parent popover for tab clicks. 2020-06-18 13:18:50 -07:00
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