Commit Graph

10203 Commits

Author SHA1 Message Date
sahil839 5f62696bc5 subs: Remove click handler for a non-existent class.
This commit removes the click handler used for
'empty_feed_sub_unsub' class.
This class was used only in home.html and was replaced
by 'stream_sub_unsub_button' in 576be51.
2020-06-20 14:21:28 -07:00
Ryan Rehman 21cdc26193 search: Support multiple search pills creation.
This reverts part of b0d632577f.
The problem was that multiple queries were combined as a single
search pill. And since we create the pills then narrow / search,
we added a comma seperator between them for the typeahead lookups
as required by the logic in `input_pill.js`.

This however introduced a new bug where the search suggestions
were incorrect as the typeahead lookup table wasn't updated, so
every time an item from the type ahead was selected it updated
the input string with an invalid operator.

Thus to resolve the first problem, we follow a simpler approach
by extracting all operators from the search string using our
`Filter.parse` logic and next add the pills, one by one.
2020-06-19 16:18:52 -07:00
Ryan Rehman 70b92c7eb3 search: Clicking on a search pill should not lose searchbox focus.
Whenever a search pill is selected or deleted by a click the navbar
gets rendered as the searchbox loses focus. This allows the user to
be able to continue editing the search query without having to refocus
the searchbox.
2020-06-19 16:18:52 -07:00
Ryan Rehman 63643c9d9d search: Fix blur event handler for `search_query_box`.
A main change is that we now display the navbar if the search box
is not focused. This was already present in the search pills version
but adding it to the legacy version is an improvement.

We sufficiently increase the timeout so that the pills are actually
deleted. This was required when `filter.is_common_narrow()` is true,
as then only we render the narrow description and close the search bar.

This commit also matches another behaviour of the legacy search.
i.e. We narrow every time a search suggestion is clicked.

The now redundant "focusin" and "focusout" event handler tests are
also removed.
2020-06-19 16:18:52 -07:00
Ryan Rehman 897bfb8b95 typeahead: Prevent lookup on backspace keyup event on searchbox.
This change was only required for the search pills enabled
search. As there is a valid use-case where the user might
want to remove just the latest pill(s) and then narrow.

This wasn't possible previously because, the typeahead was
looked up every time the backspace key was pressed. And since
the only way to narrow in search is through the enter key,
if the user entered it then the searchbox would get updated
with the first suggestion in the typeahead.
The alternative for the user would be to first lose focus on
the searchbox (by clicking outside) the focus again which
doesn't generate the typeahead. Then only the enter key would
be available for narrowing.

We do not display the typeahead after the search pills are
created. This is done just to match the behaviour for the
deletion of pills case too.

We use this approach and we don't just change the line
in `search.js` from  `helpOnEmptyStrings: true` to
`helpOnEmptyStrings: !page_params.searchpills enabled`
because we still need to provide suggestions for '',
on initial lookup or every time the empty input searchbox
with search pills present gains focus.
2020-06-19 16:18:52 -07:00
jagansivam28 9038c7f28f settings CSS : Fix 'user-avatar-source' text reflow bug.
When we move the avatar upload widget to `image_upload_widget.hbs` file
the CSS `position:absolute` for `avatar-source` is preserved.
by removing CSS `position:absolute` we can fix the bug.
2020-06-19 15:53:51 -07:00
Steve Howell 00e60c0c91 events: Use stream_id for peer_add/peer_remove.
Two things were broken here:
    * we were using name(s) instead of id(s)
    * we were always sending lists that only
      had one element

Now we just send "stream_id" instead of "subscriptions".

If anything, we should start sending a list of users
instead of a list of streams.  For example, see
the code below:

    if peer_user_ids:
        for new_user_id in new_user_ids:
            event = dict(type="subscription", op="peer_add",
                         stream_id=stream.id,
                         user_id=new_user_id)
            send_event(realm, event, peer_user_ids)

Note that this only affects the webapp, as mobile/ZT
don't use this.
2020-06-19 14:48:42 -07:00
Rohitt Vashishtha df6530529a settings: Fix race condition in getting users' last active time.
We recently removed an API call for fetching user list for our
Settings>Users/Deactivated panels, which introduced a bug where
we rendered the users table before last active information is
processed by the frontend.

This commit makes us process presence before rendering our settings
panels. We move the presence init above because we need to initialize
settings_sections before hashchange.

Fixes #15453.
2020-06-19 13:08:40 -07:00
Rohitt Vashishtha c3bfa3de0d timestamp: Update night mode css after the syntax change. 2020-06-19 13:07:16 -07:00
Dinesh 88821ec3f2 apple_auth: Add icon for log in and sign up buttons.
This should have been included in 04453114, but I've
forgotten to include it. So, fixing it with this.
2020-06-19 12:55:24 -07:00
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