Commit Graph

11787 Commits

Author SHA1 Message Date
Anders Kaseorg eae05ba0ae rendered_markdown: Fix stream-topic parser.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-29 12:16:49 -07:00
Aman Agrawal 374ce1094b giphy: Use `zulip-icon` font to render giphy icon. 2021-04-29 09:02:25 -07:00
Aman Agrawal 5bd37b44f2 zulip-icon: Add `zulip-icon` as classPrefix for icon.
This avoids general class names like `bot`.
2021-04-29 09:02:25 -07:00
Aman Agrawal 2a1bcd4b59 giphy: Fix incorrectly working show/hide behaviour.
There were some changes that were lost/added by mistake
during a rebase of #17707 after #18154 was merged.

Fixes the GIF icon being hidden / displayed incorrectly
with respect to the settings.

These changes were originally part of
67527a2517 but
were lost during the rebase.
2021-04-29 09:02:25 -07:00
sahil839 37b4d07934 settings_data: Add 'user_can_create_streams' helper.
This commit adds 'user_can_create_streams' helper which is
used to check whether user can create streams or not and
replaces all the instances of 'page_params.can_create_streams'.

This change helps us to remove the complex logic of updating
'page_params.can_create_streams' for 'realm_update' event in
'server_events_dispatch.js', as we will always get the updated
values from the added helper for checking whether the users can
create streams or not.
2021-04-28 15:37:00 -07:00
sahil839 0452d8e175 settings_data: Add 'user_can_subscribe_other_users' helper.
This commit adds 'user_can_subscribe_other_users' helper in
settings_data.js amd this helper will replaced all the
instances of page_params.can_subscribe_other_users.

We also remove the incorrect code in server_events_dispatch.js
where we were updating page_params.can_invite_to_stream which
is actually not used in other parts of code and instead of it
page_params.can_subscribe_other_users is used to check whether
user is allowed to subscribe others or not. This code was
added in 272ed9068.
Though this could have been done in a different commit, but as
we are adding the code to use the correct updated value in this
commit only, this has been fixed here.

There is also no need of adding that complex logic to update the
correct 'page_params.can_subscribe_other_users' field on
'realm_update' event, as we are using user_can_subscribe_other_users
helper and thus we always use the updated values to check whether
the user is allowed to subscribe others or not.
2021-04-28 15:37:00 -07:00
sahil839 38a4105744 settings_data: Add 'user_can_invite_others_to_realm' helper.
This commit adds 'user_can_invite_others_to_realm' function
in settings_data.js which replaces all the instances of
'page_params.can_invite_others_to_realm'.

This change makes it possible to remove the complex logic of
updating 'page_params.can_invite_others_to_realm' on
'realm_update' event as we are using above added helper instead
of using page_params object and thus we always use the updated
value to check whether user can invite others or not.

The 'user_has_permission' helper will be used by functions added
for create_stream_policy and invite_to_stream_policy in further
commits and will help in avoiding code duplication.
2021-04-28 15:37:00 -07:00
sahil839 21dd589f32 settings_config: Use a common object for different policy values.
This commit replaces different objects - create_stream_policy_values,
invite_to_realm_policy_values and invite_to_stream_policy_values,
with a single object common_policy_values.

Though invite_to_realm_policy do not use other fields of objects like
description, order, etc. but we can keep it as it is for now as we
would separate this setting from "Are invitations required...."
dropdown and these fields will be used then.

This is a prep commit for commits that will add helper functions in
settings_data for these policies replacing the usage of page_params
object.
2021-04-28 15:37:00 -07:00
Megamind 84db1e9737
frontend: Fix overflow of alert-word-status-text in narrowed window. 2021-04-28 09:34:30 -07:00
ligmitz 91c81eadd0 sidebars: Fix truncated lists when notifications panel is visible.
When notifications panel is open at the top, the buddy list and
streams-filter container gets truncated due to max-height exceeding
the necessary value. The commit fixes the issue by subtracting the
panels height when it is visible.  The logic to do so is already
present, but we need to ensure that we trigger the full resize code
when we get into this situation.

Fixes: #18221
Fixes: #17823
2021-04-28 08:34:59 -07:00
im-adithya 009b7bca24 alert_words: Fix highlighting of adjacent alert words.
This prevents the regex from requiring multiple spaces between
adjacent alert words by using lookahead and lookbehind (rather than
the before/after checks each needing to eat a whitespace character) so
that consecutive alert words (if any) can be highlighted.

With a frontend test covering adjacent corner cases by tabbott.

Fixes #17320
2021-04-28 07:54:50 -07:00
Adam Birds 188273d8f5 integrations: Add JSON Printer webhook integration.
I have added the JSON Printer integration which will show any webhook
payload inside a code block which is useful for webhook testing.

Fixes #17969.
2021-04-28 07:23:18 -07:00
Aman Agrawal 61975c3e8f giphy: Use MutationObserver to check when popover is visible.
setTimeout doesn't work all the time especially when trying to
hide and display the popover at once, like when you press
to open giphy popover in message edit form while another giphy
popover is open from the compose box.

MutationObserver works reliably, hence we choose to use it
instead.
2021-04-28 07:07:36 -07:00
Aman Agrawal fe982e4105 giphy: Clear gifs_grid variable after hiding popover. 2021-04-28 07:07:36 -07:00
Aman Agrawal 94b2f6e232 compose_control_buttons: Use class of giphy icon to locate it.
Since giphy icon can be present in compose box and messaged edit
form at the same, we don't want should use a class here.
2021-04-28 07:07:36 -07:00
Aman Agrawal 33641d7e05 giphy: Change icon of GIF picker.
We use an icon which is more clear for what it stands for.

Increase allowed size of message-control-buttons slightly so
that they are clearly visible. This is more important for
GIF icon to be visible properly than any other icon here.
2021-04-28 07:07:36 -07:00
Aman Agrawal f47e93481e giphy: Set rating according to realm_giphy_rating.
We set rating of GIFs retrieved from GIPHY according to
realm_giphy_rating setting. Also, we allow user to set
a rating in organization settings.
2021-04-28 07:07:36 -07:00
Aman Agrawal 9021444e0c message_edit_form: Remove drafts link.
It was added while deduplicating code between compose and message
edit form. This can be confusing to users, hence removing.
2021-04-28 07:07:36 -07:00
Tim Abbott 826685f0ee message_list: Fix misported blueslip.fatal call.
In fe66aef0ad, this call to
blueslip.fatal was ported incorrectly to `throw new Error` despite the
latter not supporting the extra_data parameter.

We address this by just doing blueslip logging with the extra data first.

Fixes #18273.
2021-04-27 23:27:51 -07:00
Tim Abbott c5ed782581 markdown: Remove unnecessary null check.
This null check has been nonfunctional at least since we removed
moment.js from the project.

Fixes an issue reported in #18273.
2021-04-27 23:20:44 -07:00
Tim Abbott 807cbdff7d emoji: Remove unnecessary toggle_reaction check for undefined.
This function requires two arguments; checking for the event being
undefined is code leftover from a previous implementation.

Fixes an issue reported in #18273.
2021-04-27 23:20:32 -07:00
Tim Abbott a6f4230895 settings: Remove broken default streams error handler.
For unknown reasons, 6f7b973d3b
introduced an invalid semi-duplicate call to ui_report.error that
passed the wrong number of parameters.

We should just call `ui_report.error`, which already had logic to
handle the distinction between 40x and 50x errors.

Fixes an issue reported in #18273.
2021-04-27 23:19:04 -07:00
Tim Abbott 9dd88e845a compose_actions: Remove useless conditional.
get_focus_area can never return undefined.

Fixes an issue reported in #18273.
2021-04-27 23:13:40 -07:00
100RABHpy 5df6f6f0c1 compose: Fix bug in draft when stream is not set.
Fixes #18052
When we select a draft with no stream, topic of
drafts gets disappeared. This commit fixes this bug.

In the restore_draft function of drafts.js, we were
explicitly removing the topic of the draft when the stream is
not set.

This was bit reluctant to me, like why we're removing
the topic when the stream is not set. After discussing this on
the Zulip organization chat, I came to know that all code for
drafts is added in commit 1929cc5190.
And as this is a big commit, this microcode would not have
gotten much scrutiny and might get missed.

So removing this feature is not an issue. Also, it may be a bad
design decision to delete topic when we restore drafts. So we should
remove this feature.
2021-04-27 21:56:34 -07:00
100RABHpy 0713484cfc compose: Fix bug in draft when topic is not set.
When we select a draft with no topic, we typically got navigated to an
empty narrow, because the topic field was empty. Rather than
navigating to a view that will show "Nothing's been sent here yet!",
we should not navigate at all.

Initially, in the restore_draft function of the drafts.js
we were only checking that stream is empty or not,
now we also check for the topic, and if both are set,
we navigate to related context; otherwise, we don't navigate.
2021-04-27 21:55:58 -07:00
Tim Abbott 50f00d3e97 emails: Add unsubscribe link infrastructure for marketing emails.
This is intended to be used in any marketing emails that we send with
the send_custom_email infrastructure.
2021-04-27 21:36:09 -07:00
Abhijeet Prasad Bodas fc53d2c66a topic muting: Clean up live update code.
Previously, we used to do a kind of "local echo"
whenever the user muted/unmuted a topic. Meaning,
we used to do most of the UI update work before making
the API call to mute the topic, instead of after
receiving the `muted_topics` event. This behavior
has been so since the beginning of time
(b4b6fa14d3) and isn't ideal because:
1. If the request fails on the backend, the UI
could end up in an incorrect state.
2. Adds code complexity.
3. Makes it difficult to catch bugs related to
live-update (like the one fixed by
f725711ff2).
4. Isn't consistent with other parts of the
codebase, which do the UI update while handling
events.

This commit makes it so that all the UI update
work is done only after recieving the `muted_topics`
event.

The only possible issue with this strategy could
be users sending another duplicate request in the small
time span before receiving the event. But that isn't
a big problem, because all requests involved here are
idempotent, and the worst that can happen is a HTTP 400.
2021-04-27 17:53:06 -07:00
Abhijeet Prasad Bodas 2c4505d322 settings/muted-topic: Move list-create code to designated file.
This code better fits in `settings_muted_topics`.
2021-04-27 17:53:06 -07:00
Abhijeet Prasad Bodas eff16c934c settings/muted-topics: Fix unnecessary use of stopImmediatePropogation.
We do not have any other click handlers for the
`settings-unmute-topic` class, so `stopPropogation`
should be sufficient.
2021-04-27 17:53:06 -07:00
Tim Abbott 63e3d3dd36 settings: Capitalize notification sound names with CSS. 2021-04-27 16:43:28 -07:00
akshatdalton b573964bfa notifications: Add support for `None` option in `Notification sound`.
This commit adds support for a `None` option in the dropdown menu
of `Notification sound`. When this option is selected, no audible
notification is sent to the user.

`None` will appear as the first option in the dropdown menu, since
this is not categorized as a playable audio.

This new option is added so that folks can disable audio notifications
without losing their other notification configuration (like for PMs, mentions).

Necessary test case is added for this new option.

Fixes #16090.
2021-04-27 16:42:16 -07:00
Nyior 8e2042d378 security: Add tooling to nag users if a Zulip server is very old.
This will help ensure that users upgrade their Zulip server.

Essentially rewritten by tabbott.

Fixes part of #17826.
2021-04-27 12:10:48 -07:00
m-e-l-u-h-a-n a2c7f35e5c refactor: Add type field to pill items.
Item field is added to the pill items, this is done to utilize
it wherever possible, to distinguish between diffrent types
of pill items(stream|user_groups|users).

It is also a preparatory commit to support expanding of stream
and user group pills.
2021-04-27 12:07:57 -07:00
Tim Abbott 9eb6188dd8 hotspots: Remove useless and malformed alt text.
Since it was introduced in 5ce0db9f43,
we've had alt text for the hotspots illustration with an invalid
translation tag.

Fix this by removing the alt text, since the image has no functional
effect and so the right answer should it fail to load or the user is
visually impaired is to ignore it.
2021-04-27 11:12:24 -07:00
Aman Agrawal 4f3cae7d65 compose_control_buttons: Rename giphy_api_available to giphy_enabled. 2021-04-27 10:06:25 -07:00
Aman Agrawal 1a525be3a3 compose_control_buttons: Convert titles to tooltips. 2021-04-27 10:06:25 -07:00
Aman Agrawal 7772ef187e compose: Make close compose icon more visible.
Users may not know there is a way to close the compose box especially
in night mode since the close icon blends with the background.
2021-04-27 10:06:25 -07:00
Aman Agrawal 1b844a8d1c message_edit: Deduplicate control buttons.
Deduplicate control buttons by re-using the
compose_control_buttons.

A link to `help` overlay was added to `message_edit_form`
as a part of this process.

This fixes a bug that when video provider is set to `Jitsi`
from `none` in organization settings while message_edit_form
is open, the video icon is not displayed since
it was not present in the message_edit_form DOM even if
compose.update_video_chat_button_display tries to display it.
It is fixed since the `.video_link` element is always present
in DOM of `message_edit_form` now.
2021-04-27 10:06:25 -07:00
Aman Agrawal 4c60585820 giphy: Get message_id for `compose_giphy_logo` from `.message_row`. 2021-04-27 10:06:25 -07:00
Aman Agrawal 4a55296377 emoji_picker: Get message_id from `.message_row` for `.emoji_map`. 2021-04-27 10:06:25 -07:00
Aman Agrawal 54b31df1b6 emoji_map: Convert from id to class.
Since it can present in multiple elements, we use it as a class.
2021-04-27 10:06:25 -07:00
Aman Agrawal 9816da629b message_edit: Get `message_id` from `message_row` for `video_link`.
We remove `data-message-id` from `.video_link` in `message_edit_form`
and get message_id from `message_row` when it is required.
2021-04-27 10:06:25 -07:00
Aman Agrawal 84a7f08acc compose: Use `class` to find `markdown_preview` related elements.
We convert the following elements to use a class instead of
id for accessing them across the codebase:

* markdown_preview
* undo_markdown_preview
* markdown_preview_spinner
* message_edit_content
* preview_content

Converted them together since changes to one impacted the other in
some modules like click_handlers.

Also, added a function in rows to get `message_row`.
2021-04-27 10:06:25 -07:00
Aman Agrawal 8ebced2791 compose: Use `compose_upload_file` class for upload file icon.
We use `.compose_upload_file` across compose and message_edit_form
for file upload icon. This will help us share common code between
`compose` and `message_edit_form`.
2021-04-27 10:06:25 -07:00
Aman Agrawal 7ae04a6ba8 compose: Use `file_input` class for file input element.
In both compose and `message_edit_form` we use `file_input`
class to identify the file `input` element. This will help
to more easily share common elements between compose and message_edit.
2021-04-27 10:06:25 -07:00
Aman Agrawal eae1829ead message_edit_form: Convert from `id` to `class`.
Since we can have multiple instances of `message_edit_form`, it
makes sense to have it as a class.

We track the message_edit_form by setting an id to
`form` element dependent on message_id.
2021-04-27 10:06:25 -07:00
Abhijeet Prasad Bodas 3e9b4a2090 mute user: Hide from right sidebar users list.
This commit makes it so that muted users never appear
in the right sidebar buddy list, filter text or not.

The hiding is done in the frontend only, and we still
recieve presence data from the server as before, so
no extra work is required on unmuting someone, other
than to rerender the user list.
Long term if we find that there are too many muted users,
we may want to optimize how we send presence data, but
that is unlikely to happen.

The other less extreme option is to gray out muted users,
but that cannot be done because it would conflict
with the graying out we do for non-recipients when the
compose box is open.
2021-04-26 17:44:18 -07:00
Abhijeet Prasad Bodas 4f9c6889d1 buddy_data: Rename `get_user_id_list` to `get_filtered_user_id_list`. 2021-04-26 17:42:44 -07:00
Abhijeet Prasad Bodas aa47ca0ac0 buddy_data: Move all user_id filtering code to `filter_user_ids`.
This makes the naming more intuitive and gives us a
single place to add more conditions on filtering
user_ids, with the current motivation being filtering
muted users, the logic for which will be added in further
commits.
2021-04-26 17:42:39 -07:00
Abhijeet Prasad Bodas 5860fb050a buddy_data: Move no filter text logic to `filter_user_ids`.
This is a prep change for eventually moving all
filtering logic to `filter_user_ids`.
2021-04-26 17:37:26 -07:00