Commit Graph

11527 Commits

Author SHA1 Message Date
Anders Kaseorg 236e114870 styles: Consistently use generic fallback font families.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-05 15:18:41 -07:00
Aman Agrawal 1a83112cf9 giphy: Register click events inside giphy module.
Primary reason for this is to allow us more control over
creation of giphy popover as will be evident in future commits.
2021-04-05 15:04:50 -07:00
Aman Agrawal 4593ca9ed7 click_handlers: Export convert_enter_to_click from ui_util.
This allows us to use this function in other places without
importing click_handlers which depends on a lot of other modules.
2021-04-05 15:04:50 -07:00
Aman Agrawal 5e83965e80 giphy: Use GIPHY web SDK to allow inserting GIFs in compose box.
We use GIPHY web SDK to create popover containing GIFs in a
grid format. Simply clicking on the GIFs will insert the GIF in the compose
box.

We add GIPHY logo to compose box action icons which opens the GIPHY
picker popover containing GIFs with "Powered by GIPHY"
attribution.
2021-04-05 15:04:49 -07:00
Steve Howell d50462568b refactor: Avoid update_calculated_fields() calls.
This change should make live-update code less brittle,
or at least less cumbersome.

Instead of having to re-compute calculated fields for
every change to a stream message, we now just compute
the fields right before we render stream settings UI.
2021-04-05 09:52:19 -07:00
Steve Howell 36632637dc refactor: Remove foo_display fields on subs.
Also add a helpful comment explaining how these work.
2021-04-05 09:52:19 -07:00
Steve Howell 5624ed2afe refactor: Extract stream_data.clean_up_description().
We use this in the few places where update_calculated_fields()
could plausibly be dealing with a new rendered description.
2021-04-05 09:52:19 -07:00
Steve Howell 99b177dc7d minor: Avoid reliance on is_old_stream. 2021-04-05 09:52:19 -07:00
Steve Howell 430fadfb0b refactor: Extract stream_data.can_subscribe_others(). 2021-04-05 09:52:19 -07:00
Steve Howell 36fd76dc20 refactor: Extract can_view_subscribers().
We also remove some needless uses of the calculated
field in the node tests.
2021-04-05 09:52:19 -07:00
Steve Howell ea972569a3 refactor: Extract stream_data.can_change_permissions(). 2021-04-05 09:52:19 -07:00
Steve Howell b27ff978c7 minor: Extract can_preview() helper. 2021-04-05 09:52:19 -07:00
Steve Howell 93471ed3e4 refactor: Extract can_toggle_subscription(sub).
We don't want to rely so much on calculated fields,
and the `should_display_subscription_button` name
is a bit misleading in certain contexts.
2021-04-05 09:52:19 -07:00
Steve Howell 9c9d74fd6d minor: Use page_params.is_realm_admin.
We don't need to get this off the sub.
2021-04-05 09:52:19 -07:00
Steve Howell 4380fe4eaf refactor: Extract stream_settings_data.
This is mostly a pure code move.

In passing I remove an unneeded call to
update_calculated_fields in the dispatch code,
plus some tests that don't need them.
2021-04-05 09:52:19 -07:00
Ganesh Pawar 5262ca7621 hotkey: Map numpad navigation keys to close compose when empty.
This maps pageup/pagedown/home/end to close compose when used in empty
compose box, matching the existing behavior for the Up/Down arrow keys.

Currently, these keys do nothing when used in an empty compose box.
Typically, a user intends to navigate when pressing these keys (and
with empty compose, they can't be expecting to navigate within the
compose box), so it makes sense to map them to navigate the message
feed just to save users from needing to hit `Esc` in these contexts.

Fixes #17917
2021-04-05 07:21:57 -07:00
Tim Abbott e7e2340eda hotkeys: Move copy_with_c shortcut definition and improve comments.
The `copy_handler` function that this shortcut calls is not useful
unless the body of a Zulip message is selected, so we shouldn't try
running it in other situations.
2021-04-05 07:20:32 -07:00
Tim Abbott 4462df64da hotkey: Fix incorrect preventDefault for recent_topics hotkeys.
This logic correctly prevents the hotkeys implemented below it from
being active when "Recent topics" is open.  We expect to change some
parts of that soon (see #17685), but in any case, we should always
return false in the hotkey code when we don't process a key, so that
default browser behavior works.

This fixes browser shortcuts like Ctrl+C, Ctrl+V, etc. when recent
topics is loaded.

This bug was introduced in 1eafb1d8b3.

Thanks to ganpa3 for noticing this bug.
2021-04-05 07:20:32 -07:00
Aman Agrawal 1d12fb0bb9 recent_topics: Extract function to check `table` focus. 2021-04-04 18:01:06 -07:00
Anders Kaseorg 6dc783e562 eslint: Enable sort-imports for member sorting.
This sorts the members imported within each individual declaration; we
use import/order for sorting multiple declarations.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-03 15:54:14 -07:00
Steve Howell 5fe8bbd9da node tests: Clear message_user_ids.
This defends against future intra-test leaks.
2021-04-03 15:03:00 -04:00
Tim Abbott 53adf889e5 popovers: Change label for "Copy link to conversation".
"Copy link to message" is both a clearer label, and also more likely
to be what someone is looking for.  (It also avoids adding the
"conversation" terminology to the product).

The previous label was also somewhat inaccurate, because it actually links
to a specific message in the conversation.
2021-04-03 07:47:07 -07:00
Mandeep Singh ea3cb941d4 settings: Replace user groups delete button with fa-trash-o.
This makes this settings page a bit more consistent with the rest of
the site.
2021-04-03 07:43:33 -07:00
Aman Agrawal f7f5308986 recent_topics: Don't change background color on thead hover.
We expect to give recent topics a cleaner look by doing so.

Fixes #17934
2021-04-03 07:41:01 -07:00
Tim Abbott 4488254da9 streams: Adjust confirmation message for stream deactivation. 2021-04-02 22:09:48 -07:00
Mateusz Mandera 82b43a8cfe streams: Use "archive stream" phrasing instead of "delete stream".
The previous phrasing was misleading in relation to what the action
actually does.
2021-04-02 22:06:48 -07:00
Palash Singh Raghuwanshi 7c43f1e2f7 static: Fix setting gear to be not active when app loads.
From the commit history, this typo has always been there; because it
had the same priority as the `opacity: 0.5` for that element,
it can be nondeterministic whether the bug appeared.

Fixes #17476.
2021-04-02 18:15:00 -07:00
Anders Kaseorg ceb7e2d2bd Revert "markdown: Add support to shorten GitHub links."
This reverts commit 9c6d8d9d81 (#16916).

This feature has known bugs, and also wants some design changes to
make it customizable like linkifiers, so we’re retargeting this to
post-4.x.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-02 15:52:34 -07:00
Aman Agrawal 0267ba54b2 filter: Return false for invalid filters.
For filter values which don't exist or are invalid in some
way, we return false to show user that there are no messages
in the filter user is trying to render. Our previous behaviour
was to show all the messages and ignore the filter which
isn't good.
2021-04-01 21:53:22 -07:00
aryanshridhar f19c7a2f69 emoticon_translation: Update comment for precise object length. 2021-04-01 16:52:32 -07:00
yashika 0fc3aa3a11 muting: Make topic muted notifications clearer.
The popup that appears when you mute a topic is a bit hard to read,
since nothing makes the topic and stream names jump out from the rest
of the paragraph.  Fix this by using bold around the stream/topic and
also cutting a bunch of unnecessary verbiage.

Tweaked by tabbott to further simplify the language.
2021-04-01 16:25:12 -07:00
Anders Kaseorg 0868641ea4 Revert "static: Make alert-box available for portico pages."
This reverts commit a00f5dd90e (#17801).

That commit introduced a regression in the portico pages as described
in commit 85b3157b47.  Since that fix
introduced a regression of its own, we need to revert both commits for
now.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-01 15:25:23 -07:00
Anders Kaseorg 6a877890b8 Revert "css: Fix webapp alert styling incorrectly applying to portico."
This reverts commit 85b3157b47.

This broke the × button on Blueslip alert boxes, because @extend does
not work across different PostCSS compilation units.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-01 15:25:23 -07:00
Anders Kaseorg 2595fa88a0 setup: Use the number of completed password changes for race detection.
The start time of the last password change was the wrong time to use,
because we could start a password change, start another request,
finish the password change, and then observe that the other request
failed due to the password change.

We could use the end time, but a counter is more robust to
sub-millisecond race conditions.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-01 13:49:02 -07:00
Tim Abbott b8eb3d676a recent topics: Clarify label for filter box.
* We shouldn't use "Search" when we mean "Filter".  Filter is correct
  here, since we are just showing a subset of what's otherwise shown,
  and won't find anything that's older (or whatever).
* The stream/topic wording was unnecessary; the things we're filtering
  are topics (E.g. "Filter users" might look at name/email, and is the
  right label, not "Filter name/email").
2021-04-01 13:27:30 -07:00
YashRE42 dc02d4550f narrow_banner: Refactor first_operand conditionals to use switch/case. 2021-04-01 07:38:39 -07:00
YashRE42 f85f0c4b0b narrow_banner: Refactor empty banner is: operands to use switch/case. 2021-04-01 07:38:39 -07:00
aryanshridhar 00c493a75a dropdown_list_widget: Properly handle reset button text.
There can be several cases when we don't require a reset button
with the dropdown_list_widget.
Hence, Added an abstraction for dropdown_list_widget that
renders the button only if it's corresponding text is passed.
2021-03-31 17:57:56 -07:00
Riken Shah bfc1e45a91 password_change: Avoid unnecessary redirect to the login page.
This commits adds on to 9884226f, which was added to
handle a rare race condition that occurs when the
session hash is not updated by the backend during the
password change process.

It handles a variant race situation where the request was initiated
before/during the password change event and completed after it was
completed. Hence, forcing the page to redirect to the login page.
2021-03-31 11:03:09 -07:00
Tim Abbott 85b3157b47 css: Fix webapp alert styling incorrectly applying to portico.
In a00f5dd90e, we needed to move the
`alert-box` styles from alerts.css to be visible in portico pages.
However, when doing so, we incorrectly moved all of alerts.css, which
also has styles for `alert` and` alert-error` designed to make it
convenient to include hidden elements for potential errors in the
webapp settings UIs directly in the HTML template (and then use
show/hide to manage them).

We fix this by moving just the alert-box scope to the common
components.css module, which is designed as the place for styles
shared between the webapp and portico pages.

This fixes an issue where the error messages for wrong password and
the like were invisible :(.
2021-03-31 10:06:40 -07:00
Signior-X 66d7e711b2 refractor: Replace manual autosize of textarea with compose_ui autosize.
This commit make compose_ui.autosize_textarea handle most of the autosize
logic of the textarea. It audits for any logic that is trying to do
autosize manually and replace it with compose_ui.autosize_textarea.
This allows to have better check for when the textarea is autosized.

Mainly done this so that we can have a check on #compose-textarea when
to autosize and when not to, thus helping to have all the logic in only
one function.
2021-03-31 07:49:47 -07:00
sahil839 f73d101854 stream: Use 'hidden.bs.modal' event for enabling mouse background events.
We now unconditionally enable backgroung events when 'hidden.bs.modal'
event is triggered on closing of modal. We do not need to handle them
separateley for closing modal by close_modal, data-dismiss or escape.
We handle this by single handler for modals in settings and subscription
overlay.

Fixes #16688.
2021-03-30 17:02:46 -07:00
sahil839 7489213768 modals: Do not remove modal element from DOM after closing the modal.
This commit changes the code to not remove the modal element from DOM
after closing the modal for the deactivation stream modal and stream
privacy modal.

This is a prep commit for enabling background mouse events
unconditionally using 'hidden.bs.modal', because removing element
using '.remove' remove all events attached to it and this will also
remove the 'hidden.bs.modal' event which we do not want.

This remove behavior is inconsistent as we remove some of the modals
but do not remove some, so for now we are not removing the modal
after closing but it is anyway removed before opening a modal to handle
case of having two elements of same id and avoids any bugs.
This behavior of when to remove the element from DOM and when to not
remove needs to be discussed and may be modified in future.
2021-03-30 17:02:46 -07:00
sahil839 677ba4bc25 streams: Show warning when unsubscribing a private stream.
We show a modal as a warning when unsubscribing a private stream
because it is a irreversible action and one cannot re-subscribe
tovit until added by other member of stream.

Fixes #9254.
2021-03-30 17:02:44 -07:00
sahil839 60f486d941 confirm_dialog: Add close-modal-btn class to cancel buttons.
This commit adds "close-modal-btn" class to cancel button in
the modal and cross icon.

We do this change because we would add a modal for unsubscribing
from private stream in further commit using confirm_dialog module.
We would need to avoid the unexpected closing of stream settings
on closing the modal which can be done by calling 'e.stopPropagation'
to prevent propagating of events in other elements.
Thus, adding this class will mean that the handler used for stream
privacy modal for this same task will be used for unsubscribe modal
also.
2021-03-30 16:51:42 -07:00
sahil839 208f3d7f1b confirm_dialog: Focus on the yes_button after opening the modal.
This commit adds the code to focus the confirmation/yes button
after opening the modal such that the user can just confirm by
pressing Enter.
2021-03-30 16:51:42 -07:00
sahil839 2e6723f337 stream: Add close-modal-btn class to cancel btn in deactivate stream modal.
This commit adds 'close-modal-btn' class to cancel button and cross icon
in the deactivation stream modal.

This change is a prep commit for enabling background events on
'hidden.bs.modal' event. As we would enable background events in furhter
commit using the 'hidden.bs.modal' event, we would need to remove the
'hide.bs.modal' event of deactivation_stream_modal which removes the
element from DOM.
When we remove this event we would need a e.stopPropagation call to avoid
unexpected closing of stream settings which was not a problem previously
because the element was being removed from DOM before actual closing of
modal.
So instead of adding a different handler, we can use the handler used
for stream privacy modal here by adding this new class.
2021-03-30 16:51:42 -07:00
sahil839 4d3a2c10fb stream_edit: Rename class of cancel btn in stream-privacy modal.
This commit renames the class of both cancel button and the cross
icon to close-modal-btn.

This change is a prep commit for enabling background events on
'hidden.bs.modal' event. As we would enable background events in
furhter commit using the 'hidden.bs.modal' event, we would need to
remove the 'hide.bs.modal' event of deactivation_stream_modal which
removes the modal element from DOM.
When we remove this we would need a e.stopPropagation call to avoid
unexpected closing of subscription settings, which was not a problem
before as the element was removed from DOM before the actual closing
of modal.
So instead of adding a separate `e.stopPropagation' call, we can use
the same handler that is being used for stream privacy modal and this
is the reason the class name of cancel button of privacy modal is
being changed.
2021-03-30 16:51:42 -07:00
sahil839 0fb4045807 subs: Do not remove stream row when unsubscribing using hotkey.
We do not remove the stream row instantly from the subscribed list in
subscription overlay when unsubscribing from public streams in most
of the cases but we do so when unsubscribing using hotkey.
This commit makes it consistent by not removing the stream row on
unsubscribing using hotkey.

We also not remove the 'active' class as streams settings is still
open in the right seciton and this behavior is also consistent with
the other ways of unsubscribing.

Note that this behavior is only for public streams, we remove the
stream row in case the stream is private, as user cannot
resubscribe himself and this behavior is consistent across all ways
of unsubscribing.
2021-03-30 16:51:42 -07:00
aryanshridhar ce148ce770 frontend: Fix broken label tag and removed label expression.
- Rectifies broken label tag having a misleading 'for' attribute.
- Removed 'name' attribute from unlabelled span tag.
- Removed label expression from DropdownListWidget to built an,
  abstraction for control group only.

Fixes #17311.
2021-03-30 16:14:42 -07:00