Commit Graph

10387 Commits

Author SHA1 Message Date
Anders Kaseorg f1d475206e search: Fix ESLint prefer-arrow-callback error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-14 12:38:25 -07:00
Tim Abbott cb54e30832 Revert "search: Fix blur event handler for `search_query_box`."
This reverts commit 63643c9d9d.

As the commit mentions, it makes a UI change for legacy search which
has largely been considered a regression.  We've been running with
this reverted in zulip.com essentially since it was first merged.
2020-07-14 12:26:28 -07:00
Tim Abbott 42d601e214 help: Fix exception with invalid fragment causing bogus extra scrollbars.
Apparently, our scrollbar logic crashed with an invalid URL fragment
(hash), which resulted in initialization not completing and thus the
logic failing.

In my view the root issue here is that we're not doing a good job of
catching JavaScript exceptions in portico pages.

Fixes #15706.
2020-07-14 12:19:52 -07:00
Gittenburg bc1f2fa80e reactions: Add back missing e.stopPropagation().
In 42f20e81be I fixed an edge case but
also accidentally made clicking on reactions open the compose box.

This commit adds back the e.stopPropagation(); and explicitly hides the
emoji picker popover, to address the inconsistency fixed in the previous
commit.
2020-07-14 00:38:36 -07:00
YashRE42 75cfd886b7 navbar: Fix disappearing left border when search opens.
Previously, we were experiencing a bug that caused the left border of
the searchbox/tab_bar to disappear when the searchbox was opened. This
bug was a result of the following changes:
- 4cdd7aed2b accidentally added this line
  as right: 2; instead of right: 2px;
- 46c966576d fixed this line to be
  right: 2px; but caused the regression.

This commit fixes the bug by deleting this line.
2020-07-14 00:37:40 -07:00
SiddharthVarshney 972a1019cf message_controls: Replace chevron-down with ellipsis-v icon.
After migrating chevron-down with ellipsis for
sidebar-menu, this commit will do the same for
message narrow for consistency.
2020-07-13 16:12:26 -07:00
SiddharthVarshney 1ea9e2841c message_controls: Make click area for icons more uniform.
Previously user have to click pixel perfect on the message controls
icons to achieve the click action.

This commit will uniformly increases the click target
area for the icons.

Tweaked by tabbott to avoid some weird glitches.
2020-07-13 16:12:06 -07:00
SiddharthVarshney d0fd0cae3f message-controls: Use <i> tag for starred message icon.
Throughout the codebase we use <i> tag for icons.
This commit will add <i> tag inside the starred message
div and fa classes are now used with this <i> tag.

The starred message div is now consistent with other
message_controls divs.

Tweaked by tabbott to use the name star_container for better
readability.
2020-07-13 15:59:12 -07:00
YashRE42 ae7ff04fe6 navbar: Purge tab_list label from code base.
Prior to commit eb4a2b9d4e the center
area of the navbar was based on a structure that appended crumbs or
"tabs" as <li>s, forming a tab_bar and a tab_list.

However, in eb4a2b9d4e we apply a new
style and structure to the navbar which lets go of the convention of
tabs. Hence, we'd like to purge the tab_bar and tab_list labels from
our code base.

It would have been nicer if we could simply purge tab_bar from the
codebase and rename "#tab_list" so that we have an anchor and wrapper
structure in the html, but dropping the float: left on tab_bar causes
some confusing problems such as causing the horizontal border to
disappear and the search_box to shift out of its intended position and
so its simpler to get rid of tab_list from our code base first.

This commit:
- Removes the #tab_list wrapper div from tab_bar.hbs.
- Removes any #tab_list selectors from night_mode.scss so that they
  simply target based on "#tab_bar" instead of "#tab_bar #tab_list".
- Removes tab_list selectors from zulip.scss, so that #tab_list
  attributes now apply to the #tab_bar, in the process we drop the
  duplicated width property and reorder the attributes.
- Replaces all mention of #tab_list with #tab_bar in JS files.
2020-07-13 15:39:36 -07:00
YashRE42 632f62c8b6 navbar: Remove padding-top from #tab_bar CSS because it defaults to 0.
Prior to commit eb4a2b9d4e the center
area of the navbar was based on a structure that appended crumbs or
"tabs" as <li>s, forming a tab_bar and a tab_list.

However, in eb4a2b9d4e we apply a new
style and structure to the navbar which lets go of the convention of
tabs. Hence, we'd like to purge the tab_bar and tab_list labels from
our code base. This commit pushes us towards that goal by simplifying
the future merge of the two CSS labels.
2020-07-13 15:39:36 -07:00
YashRE42 a050061494 navbar: Drop letter spacing from #tab_bar in CSS.
Prior to commit eb4a2b9d4e the center
area of the navbar was based on a structure that appended crumbs or
"tabs" as <li>s, forming a tab_bar and a tab_list.

However, in eb4a2b9d4e we apply a new
style and structure to the navbar which lets go of the convention of
tabs. Hence, we'd like to purge the tab_bar and tab_list labels from
our code base. This commit pushes us towards that goal by simplifying
the future merge of the two CSS labels.

The letter-spacing attribute was set to its default value and so we
remove it and rely on the default.
2020-07-13 15:39:36 -07:00
YashRE42 f0882e8539 navbar: Remove unnecessary overflow attributes from #tab_bar CSS.
Prior to commit eb4a2b9d4e the center
area of the navbar was based on a structure that appended crumbs or
"tabs" as <li>s, forming a tab_bar and a tab_list.

However, in eb4a2b9d4e we apply a new
style and structure to the navbar which lets go of the convention of
tabs. Hence, we'd like to purge the tab_bar and tab_list labels from
our code base. This commit pushes us towards that goal by simplifying
the future merge of the two CSS labels.

Currently the #tab_bar is just a container for the #tab_list and the
 #tab_list handles the overflow attributes and so these do not serve
any purpose.
2020-07-13 15:39:36 -07:00
YashRE42 e4f1dfe80b navbar: Remove height attribute from #tab_bar CSS.
Prior to commit eb4a2b9d4e the center
area of the navbar was based on a structure that appended crumbs or
"tabs" as <li>s, forming a tab_bar and a tab_list.

However, in eb4a2b9d4e we apply a new
style and structure to the navbar which lets go of the convention of
tabs. Hence, we'd like to purge the tab_bar and tab_list labels from
our code base. This commit pushes us towards that goal by simplifying
the future merge of the two CSS labels.

We have the same selector within #tab_list and the duplication is
unnecessary.
2020-07-13 15:39:36 -07:00
YashRE42 437b9a1a90 navbar: Refactor >:nth-last-child(2) style to use scss nesting. 2020-07-13 15:39:36 -07:00
YashRE42 87c9d527ef navbar: Add comment in scss explaining the nth-last-child(2).
Ideally we would not be relying on something that requires a 4 line
comment, and also makes it harder to add more static elements at the
end of the navbar, but this block should be acceptable for now.

One alternate would be a "grow-1" class or similar but we might need
to think that through.
2020-07-13 15:39:36 -07:00
YashRE42 bf91dad438 navbar: Simplify narrow_description conditional in hbs template.
Previously, we had the entire div within the conditional, instead of
just the contents, which were the only variable elements.

This change moves the conditional over just the contents of the div
and improves readability.
2020-07-13 15:39:36 -07:00
YashRE42 25765faf58 navbar: Live update sub_count.
Previously, the navbar sub count would not live update as users
subscribed or unsubscribed, this commit adds the relevant calls in
stream events.

It would have been better to just have a single call within
server_events_dispatch but it seems difficult due to the way of
mark_subscribed and mark_unsubscribed are structured.

stream_events.mark_unsubscribed conditionally calls
subs.update_settings_for_unsubscribed which calls
subs.rerender_subscriptions_settings and as such handles the update
for the subscriptions modal on its own. Hence, we simply rely on the
stream_data.update_calculated_fields to ensure the subscriber counts
are updated and make a call to
tab_bar.maybe_rerender_title_area_for_stream(sub).

stream_events.mark_subscribed is similar.
2020-07-13 15:38:15 -07:00
YashRE42 0667925c93 refactor: Extract maybe_rerender_title_area_for_stream(modified_sub).
Previously, we had the lines from this block being duplicated in all
the stream update paths, which is a little brittle.

Hence, in this commit, we extract it out with a comment explaining
what it does and call it in all the duplicated spots.
2020-07-13 15:36:53 -07:00
Gittenburg 53c66fd9c4 message_header: Fix date alignment in PMs.
My previous message_header fix
0b4568d249
accidentally changed the alignment of dates in private messages (so that
it was inconsistent to the alignment in other narrows).
2020-07-13 13:26:54 -07:00
sahil839 fff7fe21cb stream_edit: Use narrow_state.stream_sub instead of narrow_state.stream.
We use narrow_state.stream_sub instead of narrow_state.stream to directly
get the sub object instead of stream name, while subscribing to a stream
from the stream narrow.
2020-07-13 13:09:17 -07:00
sahil839 a0d2c7db16 stream_data: Modify is_user_subscribed to use stream id.
This commit changes stream_data.is_user_subscribed to use stream id
instead of stream name.
We are using stream ids so that we can avoid bugs related to live
update after stream rename.
2020-07-13 13:09:17 -07:00
Ryan Rehman 14c869d803 message send: Update failed message ui on re-send success.
We have logic in place to update the ui for re-sending messages
on recieving the acknowledgement from the server on that API call.

However, if the acknowledgement is recieved through the get events
request before the `on_success` of `resend_message`, the message
gets re-rendered allowing the failed message actions to be clickable.

Now, we update the ".message_failed" ui for both cases. This helps
in preventing the "Trying to get local_id from row that has reified
message id" exception.

Fixes #15351.
2020-07-13 12:29:33 -07:00
Aman Agrawal 55f80a2502 recent_topics: Don't render topic of deactivatedstreams.
Fixes error when trying to render topic of a deactivated stream in
the Recent Topics widget.
2020-07-13 11:22:43 -07:00
Aman Agrawal 46c966576d scss: Fix broken rules. 2020-07-13 10:46:34 +05:30
Aman Agrawal c32f27a05d hash_util: Show error if url is invalid.
For urls we cannot handle, we inform user via a nice
error message.

See comment in decodeHashComponent for some of the cases it
fixes for us.
2020-07-10 11:01:31 -07:00
Aman Agrawal f97d35ebd2 ui_report: Use fadeOut to hide error.
fadeTo is not a good method to hide elements since it sets
opacity to 0 in which the element still can consume space and
be clickable. We set it's display to None using fadeOut method.

Also, allow this method to be called via ui_report.error.
2020-07-10 11:01:31 -07:00
Gittenburg 0b4568d249 message_header: Fix overlap on mobile with flex.
Previously .recipient_row_date was positioned absolutely, allowing it to
overlap with the topic name on narrow screens. This can be solved by
using flexbox. To implement the empty space between the bar controls and
the date on wider screens we move the date outside of the bar controls
(which also makes more sense semantically since the date isn't a
control).

Fixes #15501.
2020-07-09 13:13:38 -07:00
sahil839 67ea4bd937 stream: Fix incorrect dispaly of stream notifications settings.
The stream notification settings checkboxes were not checked
even when the notifications were turned on for the stream.
This was happening because we were passing stream name to
receives_notifications instead of stream id.

This commit fixes the bug by passing stream id to
receives_notifications. This change should have been done
in f3604fb while refactoring receives_notifications to use
stream id instead of name.
2020-07-09 12:46:44 -07:00
Vinit Singh bf31d92fa7 emoji_picker: Fix keys not working if search yields no results.
As a consequence of commit 1113589b9d the backspace key and some other
keys did not respond if the search yielded no results.
This change fixes that bug.
2020-07-09 11:55:13 -07:00
Aman Agrawal 18bebbf290 recent_topics: Set correct container as scrolling container.
This fixes the bug of extra topics not being rendered on scrolling.
list_render uses `max-height` to determine which container is being
scrolled upon. Set the `max-height` on the scrolling container of
recent topics to help list_render identify it.
2020-07-08 17:51:27 -07:00
Vinit Singh 8b54cce833 emoji_picker: Improve emoji picker search results.
This sorts the emoji picker's search results using the same
`typehead.sort_emojis` function as the compose typehead.

Resolves #15694.
2020-07-08 13:47:03 -07:00
Gittenburg 6e5fb85ade refactor: Improve method name in emoji_picker. 2020-07-08 13:25:49 -07:00
Gittenburg 9f20fdc87a refactor: Replace getter with const in emoji_picker. 2020-07-08 13:25:49 -07:00
Gittenburg 08b9aacb88 hotkey: Detect arrow keys while holding shift.
This is useful for the emoji-picker where holding down shift lets you
select multiple emojis. Otherwise when selecting multiple emojis with
the keyboard shortcuts you would need to release shift everytime you
wanted to navigate with the arrow keys.
2020-07-08 13:25:49 -07:00
Gittenburg 5bb10036b5 emoji_picker: Allow selecting multiple while holding Shift.
We detect shift with event.shiftKey so we need to pass the event around.

Fixes #8465.
2020-07-08 13:25:49 -07:00
Gittenburg 1113589b9d emoji_picker: Move enter handling into picker.
This means the picker no longer has to export
is_composition(emoji) and toggle_selected_emoji().
2020-07-08 13:22:24 -07:00
Gittenburg 42f20e81be emoji_picker: Fix inconsistency in edge case.
Previously clicking on an existing message reaction (outside of the
emoji picker) while having the emoji picker open, removed the reaction
without updating the highlighting of the reacted emoji in the emoji
picker.

The emoji picker already is already closed when clicking outside.
The message reaction click handler however previously stopped the event
propagation, leaving the picker open, allowing the inconsistency.
2020-07-08 13:21:53 -07:00
sahil839 9ccb33a894 subs: Fix bug of subscribing/unsubscribing user by clicking on stream row.
There is a bug when clicking on the stream row in stream settings page
subscribes/unsubscribes the user from stream. The ideal behaviour
should be that user should be subscribed/unsubscribed only
when user clicks on tick icon. The buggy behaviour is visible only after
clicking the tick icon once.

This is because clicking on tick is adding sub_unsub_button class to the
stream row, while it should be added only to the ".check" element to
re-enable the button to handle requests.

This commit fixes the bug by adding the "sub_unsub_button" class to
".check" element only and not to the stream row and same change
is done for removing the "sub_unsub_button" class also.
2020-07-07 17:12:01 -07:00
sahil839 48eba187bb stream_edit: Fix bug in subscribing/unsubscribing from stream settings.
Subscribe/Unsubscribe button in the right section of stream settings
page is not working because the target element in click handler was
changed to 'check.sub_unsub_button' in c234b4f2 and the button in
the right section with class 'sub_unsub_button' also uses the same
click handler.

This commit reverts c234b4f2 and the bug of subscribing/unsubscribing
the user by clicking on stream row in the stream settings page, which
c234b4f2 intended to fix will be fixed in next commit.
2020-07-07 17:12:01 -07:00
Tim Abbott 8672805ddf compose: Use rendered_markdown.update_elements for previews.
As we add more features where rendered_markdown.update_elements does
something useful, it'll become important to run this code everywhere
we render markdown in the DOM.

One can see in this case that we had actually copied one hunk of
rendered_markdown.update_elements years ago, before we extracted it as
an independent function; we get to delete that copy.

Fixes #15500.
2020-07-07 14:37:09 -07:00
sahil839 04ef6ba63a compose: Set wildcard_mention for message before further validation.
We do not show the warning while sending messages to announce
stream if there is a wildcard mention in the message (i.e.
when wildcard_mention != null)

There are two cases where we should ideally show the warning
but we don't-

 - When there is no wildcard mention in the message and
   wildcard_mention is set to undefined (initial value of
   wildcard_mention).
   This is because "wildcard_mention != null" returns true for
   this case and thus the warning is not shown, assuming the
   message to have wildcard mention.

 - When previous message had a wildcard mention and now a message
   is being sent with no wildcard mention.
   This is because the condition "wildcard_mention != null" is
   checked with the previous value of wildcard_mention and not
   with the value according to current message content, and thus
   the warning is not shown, assuming the message to have wildcard
   mention.

This commit changes the code to set wildcard_mention from the
latest message content before performing other validations and
thus solves the problems described above.
2020-07-07 10:42:55 -07:00
Rohitt Vashishtha 912e372c4e markdown: Remove !avatar() and !gravatar() syntax.
This particular commit has been a long time coming. For reference,
!avatar(email) was an undocumented syntax that simply rendered an
inline 50px avatar for a user in a message, essentially allowing
you to create a user pill like:

`!avatar(alice@example.com) Alice: hey!`

---

Reimplementation

If we decide to reimplement this or a similar feature in the future,
we could use something like `<avatar:userid>` syntax which is more
in line with creating links in markdown. Even then, it would not be
a good idea to add this instead of supporting inline images directly.

Since any usecases of such a syntax are in automation, we do not need
to make it userfriendly and something like the following is a better
implementation that doesn't need a custom syntax:

`![avatar for Alice](/avatar/1234?s=50) Alice: hey!`

---

History

We initially added this syntax back in 2012 and it was 'deprecated'
from the get go. Here's what the original commit had to say about
the new syntax:

> We'll use this internally for the commit bot.  We might eventually
> disable it for external users.

We eventually did start using this for our github integrations in 2013
but since then, those integrations have been neglected in favor of
our GitHub webhooks which do not use this syntax.

When we copied `!gravatar` to add the `!avatar` syntax, we also noted
that we want to deprecate the `!gravatar` syntax entirely - in 2013!

Since then, we haven't advertised either of these syntaxes anywhere
in our docs, and the only two places where this syntax remains is
our game bots that could easily do without these, and the git commit
integration that we have deprecated anyway.

We do not have any evidence of someone asking about this syntax on
chat.zulip.org when developing an integration and rightfully so- only
the people who work on Zulip (and specifically, markdown) are likely
to stumble upon it and try it out.

This is also the only peice of code due to which we had to look up
emails -> userid mapping in our backend markdown. By removing this,
we entirely remove the backend markdown's dependency on user emails
to render messages.

---

Relevant commits:

- Oct 2012, Initial commit        c31462c278
- Nov 2013, Update commit bot     968c393826
- Nov 2013, Add avatar syntax     761c0a0266
- Sep 2017, Avoid email use       c3032a7fe8
- Apr 2019, Remove from webhook   674fcfcce1
2020-07-07 10:39:44 -07:00
Sanskar Bajpai bd6fe786cf date_row: Update color via update_table_stream_color.
Previously, the function update_table_stream_color did not update the
color of the date_row when it appeared within a topic.  This was
incorrect because it meant that a small piece of the border to the
left of the message box would be left to the previous color when the
stream color was updated.  This commit resolves the issue by adding an
update.

Fixes #15197.
2020-07-06 18:37:35 -07:00
Rohitt Vashishtha c87446a8de timestamp: Extract and improve timerender.get_timestamp_for_flatpickr.
To make the typeahead code more readable, we extract this function to
timerender. We also improve the logic to be more readable, and add tests
to confirm its validity.
2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 5d1365b265 minor: Format comments to be sentences and fix typo. 2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 0b510cd66d timestamp: Hide timestamp forrmat errors in local echo. 2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 1f765b41ce timestamp: Throw error if frontend cannot parse backend supplied time.
We have moved our invalid timestamp logic to use timestamp-error class,
however, if there are any valid outputs by the backend markdown that
the frontend considers invalid, we want to debug them. This commit
adds tooling to ensure we log those error messages.
2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 088b8e28c3 timestamp: Translate 'invalid time format' message on the frontend. 2020-07-06 15:53:56 -07:00
Rohitt Vashishtha 732ec3c0e6 timestamp: Change syntax to `<time:timestammp>`.
We had been using !time() syntax for timestamps so far. Since its
an unreleased feature, we can make changes without affecting many
people.

Fixes #15442.
2020-07-06 15:53:56 -07:00
Rohitt Vashishtha ca73d81bba timestamp: Extract show_flatpickr() in composebox_typeahead.
The time_jump typeahead code now reads like other typeaheads,
uncluttered with the flatpickr logic.
2020-07-06 15:53:56 -07:00