Commit Graph

11981 Commits

Author SHA1 Message Date
aryanshridhar c25155a143 hotkeys: Fix a minor typo in comment.
'Rnter' -> 'Enter'
2021-05-09 09:18:07 -07:00
Wesley Aptekar-Cassels 27d9643274 frontend: Remove hover effect from small messagebox.
Textboxes shouldn't have hover effects.
2021-05-08 08:26:16 -07:00
Wesley Aptekar-Cassels 8453aac260 frontend: Use placeholder style for small messagebox text.
This makes the small messagebox (previously referred to as the "Reply"
button) look more like a textbox.
2021-05-08 08:26:16 -07:00
Wesley Aptekar-Cassels 8bc0c14e81 css: Explicitly set placeholder text style.
Previously, we relied on the browser placeholder text style, but this
makes it impossible to style text to look like a placeholder.

Chrome uses `color` to set the placeholder, while Firefox uses
`opacity`. This commit sets both, since setting one without the other
will lead to strange behaviour.

We pick the color for the light and day themes to ensure that we meet
WCAG standards for accessibility.
2021-05-08 08:26:16 -07:00
Wesley Aptekar-Cassels 9fdd7184c6 frontend: Make "Reply" button look more like a textbox.
* Use "text" cursor effect
* Reduce padding
* Remove blue color in placeholder text
2021-05-08 07:59:31 -07:00
Tim Abbott 747cbb5dde integrations: Fix JavaScript exception on category pages.
This logic threw an exception ever since we added new buttons at the
bottom of the page that were inside the container this looped over.
2021-05-08 07:54:51 -07:00
Tim Abbott e319a1e5e8 templates: Fix typo in stream deactivation modal. 2021-05-08 07:31:40 -07:00
aryanshridhar 5e47d8446f deactivate_stream: Add Help link widget for UI modal.
Added Help link widget for deactivate_stream UI modal
which redirects to /help/archive-a-stream within
the user documentation.
2021-05-08 07:29:24 -07:00
aryanshridhar 5a254bf495 deactivate_realm: Add Help link widget for UI modal.
Added Help link widget for deactivate_realm UI modal
which redirects to /help/deactivate-your-organization within
the user documentation.
2021-05-08 07:29:24 -07:00
aryanshridhar e1fc389d79 deactivate_account: Add Help link widget for UI modal.
Added Help link widget within account settings for
deactivate account UI modal which redirects to
/help/deactivate-your-account within the user documentation.
2021-05-08 07:29:23 -07:00
Abhijeet Prasad Bodas eadbce4b0c message list: Don't exclude 1:1 PMs with muted users in pm-with narrows.
Previously, we used to hide 1:1 PMs with muted users everywhere
in the UI. This commit makes it so that such messages will now be
visible in `pm-with/<muted_user>` narrows, meaning these will not
be excluded from message lists, but will still be hidden under
the "This message was hidden." dialog implemented earlier.
2021-05-07 16:21:35 -07:00
Abhijeet Prasad Bodas a59f545136 message lists: Exclude 1:1 PMs with muted users.
* We hide 1:1 PMs from and to muted users throughout
the UI, because doing so will not lead to loss of
conversational context. The "to" part is also important,
because the last few messages sent to a user before
muting them would probably be asking them to stop
spamming.

* After this change, we will need to do filtering for either
user or topic muting in pretty much all narrows, so we need
to keep the `_all_items` list in MessageListData always
up-to-date.

* A further commit will relax this and make it possible to
view these messages only when in a `pm-with/muted_user`
narrow.
2021-05-07 16:21:35 -07:00
Abhijeet Prasad Bodas e64e5936ce message lists: Don't allow user/topic mute message filtering independently.
This basically reverts 4bd7ec7c36 and
3a9dfc02e6.

The plan earlier was to have compeletely different codepaths
for user and topic muting, so that we could call seperate
functions in the message list class on receiving the respective
events.

However, this cannot be done, because if we, for example, on
receiving a `muted_users` event, filter `_all_items` based on
just user mutes, and store the result in `_items`, then, that
result may still contain topic-muted messages, which is
undesirable. Hence whenever we filter messages, we must do so
based on both user as well as topic muting.
(The code for the former will be added in further commits.)

So, we will have a single function which will handle updating
the message lists for muting.
2021-05-07 16:21:35 -07:00
Aman Agrawal 0dd8ce6ff9 recent_topics: Hide reply button when search or filters selected.
Since there is no context for a message in the search or filter buttons,
we don't show reply button either of them are focused.
2021-05-07 16:07:52 -07:00
Aman Agrawal 5040246474 recent_topics: Load enough topics to maintain scroll position.
We were losing scroll position after re-render because there
were not enough rows present in the table to focus back to
the same position. With this commit it is possible now since we
always render with enough rows to do so.
2021-05-07 16:07:52 -07:00
Aman Agrawal 2066553635 recent_topics: Always keep a `visible` topic row in focus.
We save the scroll position of the user by keeping the topic
row at the center of the visible scroll container in focus. The
avoids focus being reset to first topic row when recent topics
renders. Thus, this improves the UX of recent topics.
2021-05-07 16:07:52 -07:00
Aman Agrawal d2e3dbeb50 list_widget: Allow instance to change load_count as per state.
Add a function which is called before every render to
get the number of items it can render. This can be used by
instance to load custom number of items as per its state.
2021-05-07 16:07:52 -07:00
Aman Agrawal 7d6b65e8f4 list_widget: Give instances more control over scrolling behaviour.
We allow ListWidget instances to pass functions in opts that can
be called after scrolling to determine when to render.
Also, allow a callback function to be called pre render.
2021-05-07 16:07:52 -07:00
Aman Agrawal 51acbefc8a recent_topics: Display compose box & enable compose hotkeys.
We move compose from being a part of message feed to
being a part of  middle column which is a common parent of recent
topics and message feed. This allows us to use a common compose
box for both the views. Fortunately, compose actions were
independent of this change so there weren't any evident
side effects.

Fixes #17543
2021-05-07 16:07:51 -07:00
Aman Agrawal 1bc21a6a2f compose: Extract function to update compose buttons.
These two functions just have text_stream different, rest are
same.
2021-05-07 15:51:54 -07:00
Gaurav Pandey 36ad9b7d0e api: Fix encoding of strings in user settings endpoints.
* Remove unnecessary json_validator for string parameters.
* Remove unnecessary JSON encoding in frontend calls.  Structurally,
  JavaScript does correct encoding without explicit JSON encoding.

Fixes part of #18035.
2021-05-07 14:10:45 -07:00
Gaurav Pandey 232c7107eb api: Fix encoding of strings in tutorial endpoint.
* Remove unnecessary json validator for string parameter.
* Update frontend to pass right parameter.

Fixes part of #18035.
2021-05-07 14:06:54 -07:00
Gaurav Pandey d4219da254 api: Fix encoding of strings in realm domain endpoint.
* Remove unnecessary json_validator for string parameters.
* Update frontend to pass right parameters.

Fixes part of #18035.
2021-05-07 14:06:54 -07:00
Gaurav Pandey d6cf1ef27b api: Fix encoding of strings in hotspot endpoint.
* Remove unnecessary json_validator for string parameter.
* Update frontend to pass right parameters.

Fixes part of #18035.
2021-05-07 11:45:25 -07:00
Vishnu KS 752fd2e2d1 corporate: Fix string encoding in billing and sponsorship endpoints. 2021-05-07 09:37:40 -07:00
Ryan Rehman e48c24872f message send: Do not retry failed message if already in progress.
The `.refresh-failed-message button` was registering clicks even
while the button was spinning (has already been clicked once).
Thus a network request was sent for every subsequent click which
raises an exception that the local id is not found in the message
store as it had already been reifyed by the first request.

Fixes #18375.
2021-05-07 08:47:11 -07:00
Riken Shah 089ca2bdcf node_tests: Add remaining tests for `panels.js`.
In this commit, we add the node tests for `panels.js`, which started
in 2f36c5aefc commit (it added tests for
the server upgrade alert).
2021-05-07 08:41:41 -07:00
Riken Shah 37b265495b alert_words: Revert back `before_punctuation` regex to stable one.
In this 009b7bca24 commit `before_punctuation`
regex was updated to use lookbehind feature of regex.

This caused a regex error in some browsers (reported in
Safari) because lookbehind feature is not yet supported
on all the browsers (https://caniuse.com/js-regexp-lookbehind).

This commit fixes that error by reverting to stable regex which
works on all the browsers.
2021-05-06 20:36:52 -07:00
Anders Kaseorg 405bc8dabf requirements: Remove Thumbor.
Thumbor and tc-aws have been dragging their feet on Python 3 support
for years, and even the alphas and unofficial forks we’ve been running
don’t seem to be maintained anymore.  Depending on these projects is
no longer viable for us.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-06 20:07:32 -07:00
Anders Kaseorg 779353b44e apps: Link to macOS Apple silicon native build.
Leave the Intel build as the prominent default, since it will run on
both platforms.  (I would have liked to detect the appropriate
platform, but Apple seems to have put significant effort into making
that impossible for anti-fingerprinting reasons, which is probably an
overall good.)

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-06 17:52:00 -07:00
Anders Kaseorg fa8532d9b7 apps: Move id="download-android-apk" from span to a.
Due to spaghetti CSS that should be fixed but isn’t fixed here, the
<span> wrapper is still needed so the hover effect is applied.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-06 17:52:00 -07:00
Riken Shah 2f36c5aefc navbar_alerts: Add button to hide "Server Upgrade" alert for 7 days.
This button will allow users to avoid a distracting red banner across
their screen, while they wait for their sysadmin to do the upgrade
work.

Fixes: #18359
2021-05-06 15:55:40 -07:00
Anders Kaseorg fc9481a24e js: Remove some pointless IIFEs.
Some of these were there because they predate block-scoped const/let.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-06 14:38:57 -07:00
Aman Agrawal 707d23d1e8 recent_topics: Don't rerender when topic_data is unchanged.
Since we don't process private messages yet, we don't
need to re-render when we receive a new private message
as it doesn't change any data related to recent_topics.
2021-05-06 12:06:22 -07:00
Adam Birds a3ba8b9efd integrations: Add Freshping webhook integration.
I have added a webhook integration for Freshping.
2021-05-06 11:18:35 -07:00
Alya Abbott 279f7b1c8d user docs: Create separate "Code blocks" user documentation page.
* Move the extended documentation of code blocks to a separate page.
* Merge "code playgrounds" documentation to be a section of that page.
* Document copy widget on code blocks.
* This commit changes how we refer to "```python" type syntax for code
  blocks. Instead of being called a syntax highlighting label, this is
  now referred to as a "language tag", since it serves both syntax
  highlighting and playgrounds.
* Remap all the links.
* Advertise this new page in various places that previously did not have a link.
2021-05-05 16:11:21 -07:00
Tim Abbott c60609efeb css: Fix hover effect for status list messages in night theme.
Fixes #17944.
2021-05-05 15:37:30 -07:00
Tim Abbott 318dd8b408 css: Remove grey styling for day theme compose buttons.
This day theme styling was added in
74dbcdf2a8, and some users interpreted
this buttons styling as suggesting that these buttons were disabled.
2021-05-05 11:51:56 -07:00
Abhijeet Prasad Bodas 65249d90e9 compose_typeahead: Exclude muted users from results.
Hides muted users from PM recipients and compose box
mention typeaheads.
2021-05-05 09:42:30 -07:00
Abhijeet Prasad Bodas 04c355c248 typing notifications: Exclude muted typists. 2021-05-05 09:35:27 -07:00
Abhijeet Prasad Bodas 47764ded76 user muting: Add helpers to filter out muted users.
This will allow us to avoid duplication of array filtering
logic of the form-
`Array.filter((user_id) => !muting.is_user_muted(user_id))` and
`Array.filter((person) => !muting.is_user_muted(person.user_id))`
2021-05-05 09:34:39 -07:00
Abhijeet Prasad Bodas e4d5114c3c filter: Add new is_non_huddle_pm method.
We want to exclude 1:1 PMs from muted users everywhere
except in `pm-with/<muted_user>`.
This method will help us determine whether we are in such
a narrow.
2021-05-05 09:29:51 -07:00
Abhijeet Prasad Bodas 9f6ad779e4 message view: Allow revealing hidden message from muted sender.
* We show a "Click here to reveal." hyperlink in the hidden
message dialog for user to click on and read a hidden message.

* The "reveal" action is temporary, in the sense that a revealed
message will again be hidden once the broswer tab reloads or
if the user renarrows.

* When a message is revealed, we make sure to show the sender
of that message, even if it isn't the first message of it's group.
This is because the first message of that message group (which
would have otherwise shown the sender) can still be hidden.

* Reactions and background color after revealing a message are
the same as if the message hadn'e been hidden at all in the
first place.
2021-05-05 09:15:45 -07:00
Abhijeet Prasad Bodas 5d796987f2 message view: Hide messages sent by muted users.
* We hide the sender and reactions on messages sent by muted
users, and replace the content with a "This message was hidden"
dialog.

* Ideally, we should collapse a series of consequetive
messages sent by muted users into one such dialog, but
that could break the cursor behaviour and `near/<message_id`
links, so we as of now show one dialog per muted message.

* Because we hide the sender, there is a chance of the first
hidden message in a group looking like it was sent by the
author of the message above it. To tackle this, we intentionally
make the hidden message dialog float-left, so that it is clear
that this is a special type of message.

* For context, we still show the timestamp of the message.

* Starring, editing, deleting etc a message still work just like
before.

A further commit will add the ability to reveal a
hidden message.
2021-05-05 09:15:45 -07:00
sahil839 357e3c7135 settings_users: Fix the sorting of owner and admin in users list.
We were not considering the owner role in `sort_role` function
which was leading to improper sorting when sorting the users
list according to role. This commit fixes this bug by considering
role in `sort_role` function.
2021-05-05 09:02:59 -07:00
Tim Abbott 638ffb36a4 refactor: Move click handlers to compose_closed_ui.js. 2021-05-04 20:55:58 -07:00
Aman Agrawal 0db7fe389e message_viewport: Extract function to check if it is visible.
We also add a check to see if `message_feed_container` is visible,
since it is possible that recent topics could be visible which
was not a possibility when this logic was written.
2021-05-04 16:40:43 -07:00
Sumanth V Rao db2ad6bada puppeteer: Add settings test for realm-playgrounds. 2021-05-04 12:19:04 -07:00
Sumanth V Rao a40fe26586 help: Document playgrounds on /help, /features and /for/open-source.
Linked the Help Center document in places like
    - zulip.yaml (/events, /register/, realm/playgrounds,
                  /realm/playgrounds/{playground_id})
    - /help/format-your-message-using-markdown (Linked to make
      users reading the markdown code block style, aware of this
      feature)
    - /templates/settings/playground_settings_admin.hbs (Linked
      as a reference to read more about playgrounds before
      configuring one)

Also showcase the feature on /features and /for/open-source.
2021-05-04 12:19:01 -07:00
Sumanth V Rao 215320bc72 settings_playground: Add typeaheads for `pygments_name` field.
The typeahead suggests a human-readable `pretty_name` for the
`language` field in the add-playgrounds form.

The suggestions are sorted based on the popularity of these
languages.

E.g: A `py` prefix would match with `Python` first before
matching with others like `Python 2.x` based on priority.
2021-05-04 11:39:33 -07:00
Sumanth V Rao c21a40d823 settings_playground: Add UI to delete a playground.
The UI makes use of an onclick on the trash icon to call
DELETE /realm/playground/{playground_id}. The id is
extracted from the data attribute `data-playground-id`
set on that element.
2021-05-04 11:39:33 -07:00
Sumanth V Rao a510dac024 settings_playground: Add UI to create a new playground.
The design of the form is similar to the linkifiers page
and is styled similarly.

The introduction text for "Code playgrounds" is improved
with more details and examples.

Also, we can remove the hardcoded playground and the fix
we had previously done to prevent breaking the hardcoded
playground.
2021-05-04 11:39:33 -07:00
Signior-X 5b13f99936 avatar: show loading animation while deleting profile picture.
This commit displays the loading animation and hides other
avatar options as delete_user_avatar is called and as we get
response from the server, we show the options back and hide
the loading animation.
2021-05-04 10:11:16 -07:00
Tim Abbott 9b645816bf subs: Fix exceptions with Zephyr mirror realms.
These two blocks of code has incorrectly placed or implemented
conditionals for the rare corner case of Zepyhr mirroring
organizations.

Longer-term, we'll want to refactor this further to directly reference
can_render_subscribers, making the logic more general.
2021-05-04 09:47:55 -07:00
aryanshridhar 9575f88f22 subs: Trigger stream-creation UI for users permitted to create stream.
The previous commit remove an obsolete form laying within
subscription_table_body.hbs. However, doing so broke the functionality
of triggering the stream-creation modal using the 'Enter' hotkey.

This commit re-introduces the functionality of loading the stream
creation modal only if the user has the permission to create streams.

At the same time, we make sure it's still possible to subscribe to
streams within zephyr mirroring organizations.
2021-05-04 09:42:46 -07:00
Tim Abbott 472c845908 subs: Remove obsolete form. 2021-05-04 09:33:56 -07:00
Tim Abbott ce336ed4ff streams: Fix typo in stream deactivation modal. 2021-05-04 08:58:47 -07:00
Ken Clary 74dbcdf2a8 frontend: Change 'reply' button label to reflect selected message.
The 'reply' button shows the stream>topic or recipient(s) of the
selected message, for better UX.  It also expands to fill the
remaining horizontal space in the button bar -- this should help make
it easier for new users to figure out how to reply.

Finally, it uses "Message" instead of "Reply", to better match the
compose box.

Fixes #17940.
2021-05-03 14:58:02 -07:00
aryanshridhar 00f964e500 invites_modal: Replace modal confirmation text to Confirm.
Followup of #17926.
Basically, the aim is to concise modal texts
to use 'Confirm' instead of long labels since they can
tricky for translators and can also create bad strings
having long words.
2021-05-03 13:16:19 -07:00
akshatdalton bf41f455cd message_view: Add support for unmuting of topic from its recipient bar.
Earlier, a user can only mute a topic from its recipient bar but can't
unmute it from there (and in fact we displayed an option to mute even
if the topic was already muted!). This commit fixes that bug and
allows a user also to unmute the topic from its recipient bar.

There are two core issues here;
* We did not have code, an icon, etc. for the "already muted" case in
  the recipient bar logic at all.
* We did not rerender messages in !excludes_muted_topics views when
  muting state changed.

See: 660475bd0c for background on when
we started only rerendering the streams with excludes_muted_topics
after muting changes.  Rerendering of newly muted topics are important
for live rendering if a user is narrowed to that topic itself, which
are essentially all excludes_muted_topics narrows anyway.

Hence, now, we rerender by calling the `rerender` function for muted
topics (which is done just before we update the items for muting via
the function: `update_items_for_topic_muting`).

Tweaked by tabbott to add comments explaining the reasoning and
long-term plans.

Fixes #15223.
2021-05-03 13:07:09 -07:00
akshatdalton dd0e7bcb2e popovers: Simplify muting logic for stream popover.
This if/else statement is a lot more readable.
2021-05-03 12:35:41 -07:00
akshatdalton 91afcda484 topic muting: Show feedback widget only if hotkey (`M`) is used.
We are restricting the feedback widget (confirmation pop-up)
to be visible to the users if they have muted the topic using
the hotkey: `M`, because if the users have muted the topic in
some other way then it is known to them about their activity.
In fact, the confirmation pop-up was intrusive to some users
(see #2367).

While using the hotkey they can unknowingly mute the topic. Hence, in
such a case, it is necessary to acknowledge the users about their
action.
2021-05-03 12:34:40 -07:00
sahil839 51e40dd668 settings: Add moderators option for wildcard_mention_policy in frontend. 2021-05-03 12:12:01 -07:00
Aman Agrawal c285e3f25e giphy: Add just space as a content to fool popover library.
Since we don't have content for GIPHY popover at the time
popover is rendered, we need to render with some fake
content otherwise popover library doesn't allows for us
to show the popover.

This came into notice after 5adc6d7297
broke show popover behaviour for GIPHY but didn't break it for
emoji popover as emoji popover already renders with some content.
Prior to this commit, popover library used `title` as content for
GIPHY popover.
2021-05-03 08:33:24 -07:00
Siddharth Asthana 4262c04db1 registration: Encode source realm as an integer.
In the source realm selector, when we select a realm from which we want
to import the data, we pass the source realm's string_id. The problem
with this approach is that the string_id can be an empty string. This
commit makes the source_realm pass the realm's id instead of string_id.
Now, the source_realm's value will either be an integer or "" (empty
string) when we don't want to import settings from any realm.
2021-05-02 11:12:49 -07:00
Anders Kaseorg 802c8de0e8 fenced_code: Wrap math blocks in the frontend like the backend.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-01 15:36:15 -07:00
sahil839 f5f6617476 streams: Add frontend code for moderators only stream post policy. 2021-05-01 08:21:50 -07:00
mandepsingh 61de39dd6f help: Improve alignment for markdown tables. 2021-05-01 08:21:03 -07:00
pilgrim2308 a74b52db22 UI: Add Zulip version in gear menu.
Currently only enabled in development, since the exact details don't
seem right..

Co-Author-By: Signior-X <b19188@students.iitmandi.ac.in>
Co-Author-By: Aman Agrawal <amanagr@zulip.com>

Implements UI for #8005.
2021-04-30 17:58:08 -07:00
Tim Abbott 01245c86b3 sidebars: Add a bit of margin above sidebar links.
This avoids slightly glitchy looking behavior in certain scroll
positions where there just isn't enough space above link to make it
look like it's top of the other element.
2021-04-30 16:07:25 -07:00
Tim Abbott 3e8ec76aa0 css: Slightly increase size of left sidebar. 2021-04-30 16:02:31 -07:00
Tim Abbott ed6d5dcf36 css: Extract variables for the widths of the sidebars. 2021-04-30 16:02:31 -07:00
Nikhil Maske 74bc1a0fe5 pm_left_col: Shift the PMs list slightly towards right.
Currently we show the PMs list align with the Private
messages header that make them no difference between
header and its elements list and it may confuse the user
to notice that PMs list is expanded or not. We follow
a trend of shifting the child elements slightly towards
right from the parent header element in stream-topic list.
Maintaining this trend we fix this issue similarly, the
PMs list is shifted by 10px towards the right.
2021-04-30 16:02:31 -07:00
Nikhil Maske 88856f58c5 refactor: Cleanup the existence of fraction_present.
Replacing the group PMs icon with "fa fa-group" icon
drops the color class "fraction_present" logic. As there
is no more use of fraction_present class this commit
cleanups its all existence from the codebase.
2021-04-30 16:02:31 -07:00
Nikhil Maske b7fb130578 left_sidebar: Replace user_circle_class with fa fa-group icon.
It is difficult to distinguish group PMs from 1:1 PMs, so to
improve the UI it is better to show different icon for group
PMs. Here we are using fa fa-group icon for group PMs.

Fixes #18069.
2021-04-30 16:02:29 -07:00
Ganesh Pawar ddf2127035 widgets: Prevent edits to widgets.
As of now, editing a widget doesn't update the rendered content.
It's important to ensure that existing votes or options added later on
don't get deleted when rendered.
This seems more complex than it's worth.

For now, we just prevent edits to widgets.
This commit makes the UI clearer that editing widgets isn't allowed.

See also:
https://github.com/zulip/zulip/issues/14229
https://github.com/zulip/zulip/issues/14799

Fixes #17156
2021-04-30 09:55:25 -07:00
Nikhil Maske 0023f7f9a0 settings css: Make HTML table headers sticky.
Introduce a new class "table-sticky-headers" in the settings
and organisation settings HTML table tags and it is used
to make the table headers fix at the top. This commit also
add the background-color and hover properties to the
settings and organisation settings table to make them look
similar to the recent_topics_table.
2021-04-30 08:19:47 -07:00
Aman Agrawal 5adc6d7297 compose_control_buttons: Use data-tippy-content instead of title.
We don't want browser default titles and tooltips to overlap,
so we remove titles here.
2021-04-30 07:52:32 -07:00
Nikhil Maske a1d0fa5cbb confirm_dialog: Change copy in several dialogs.
Based on feedback from @alya in #17947.
2021-04-29 20:43:04 -07:00
Abhijeet Prasad Bodas 7f9c3bb4d0 starred messages: Fix "unstar all in topic" is incomplete.
Currently, when there are some old starred messages
in a topic, it is possible that some of them won't be
unstarred on doing "Unstar all messages in topic".
This happens when those messages haven't been fetched
yet from the server, and we have no way to verify if
they actually belong to the topic.

This commit fixes that by changing this mechanism to
first fetch all starred messages in the topic from
the server, and then send their IDs back to the backend
to unstar them.

While doing this, we assume that the user does not
have more than 1000 starred messages in that topic.

Note that, we still depend on the local data to
decide whether or not the "Unstar all messages in
topic" option should be shown in the topic popover.
A method similar to the above cannot be used here, because
making server requests before opening the popover
could visually slow down the popover opening.

Using local data for the topic popover would probably
not be a big problem, because users would want to
unstar all messages in a topic probably after noticing
that there are a lot of them, meaning there was at least
one starred message from that topic which was already
fetched, which is sufficient for us to conclude that
we need to show the option in the topic popover.

Fixes #17790
2021-04-29 16:43:39 -07:00
Abhijeet Prasad Bodas ded3d94f62 starred messages: Clean up "unstar all in topic" warning.
The dialog now shows `stream > topic` instead of
just the topic.
This creates a new tiny widget for this purpose,
which can be reused in other places too.

The `undefined` case is probably very unlikely, but
if the `stream_id` is bad, after the user confirms,
the request will fail on the backend, which could
confuse the user, since there will be no changes to
the starred messages in view.
So, we don't open the confirmation dialog at all in
such cases.
2021-04-29 16:43:39 -07:00
Abhijeet Prasad Bodas 4bd7ec7c36 message lists: Rename update_items_for_muting to include `topic`.
This change will help avoid confusion with a similar
method which will be added in further commits for
user muting.
2021-04-29 16:21:38 -07:00
Abhijeet Prasad Bodas 9d8bcce4c1 message_list: Don't store excludes_muted_topics twice.
There is no need to store this field (and make sure
that it's the same in both the message_list and
message_list_data objects) on message_list objects,
because we can anyways access it easily with
`message_list.data.excludes_muted_topics`, and storing
it just on the data object seems more intuitive.
This also simplifies the constructor for the `MessageList`
class.
2021-04-29 16:13:06 -07:00
Abhijeet Prasad Bodas 15e3420ee4 mute user: Hide from top left corner PM list.
We hide a conversation from the top-left corner PM list if
it is-
* A 1:1 PM where the other user has been muted, or
* Huddle where all users have been muted.
2021-04-29 16:13:06 -07:00
Aman Agrawal 4a91d5ffdb compose_control_buttons: Change class name for GIF icon.
Since we no longer use giphy logo to open giphy
popover, this is a more appropriate name.
2021-04-29 16:06:51 -07:00
Aman Agrawal 818b4ee7f9 giphy: Don't change logo color in night mode.
Since giphy logo is no longer an svg, we don't need to change its
color.
2021-04-29 16:06:51 -07:00
sahil839 06547d5c9b user_events: Update the role field in person object on change of role.
This commit adds code for live updating the role field of person
object on receiving role change event from server and thus enables
live update of role in users list of settings overlay.
2021-04-29 15:27:15 -07:00
sahil839 253a935cb2 user_events: Add code to live update is_moderator on role change.
This commit adds code to live update page_params.is_moderator and
person.is_moderator on receiving role change event.
The code for changing role to moderator and from moderator to any
other role was added in previous commit.
2021-04-29 15:18:49 -07:00
sahil839 730c0493b3 users: Show user role as 'moderator' in frontend for realm moderators.
This commit modifies the code to show "Moderator" correctly for
realm moderators.

As, we show role using settings_config.user_role_values object and
the same is used for showing options in changing role dropdown, this
commit also adds the moderator option in that dropdown and thus allows
the user to change role to moderator and from moderator to any other
role from frontend.
But the code for live updating page_params.is_moderator and
person.is_moderator will be in further commit.
2021-04-29 15:18:49 -07:00
sahil839 5332abcf6a settings: Add moderators option in frontend for invite_to_realm_policy.
This commit adds 'admins and moderators' option in frontend for
invite_to_realm_policy.

The logic for moderator for checking whether user is allowed to invite
others or not was added in previous commit as we use common helper
user_has_permission for all policies.
But the test user_can_invite_others_to_relam is updated for including
moderator role in this commit.
2021-04-29 15:18:49 -07:00
sahil839 6a58cf922f setting: Add moderator option in create stream and invite to stream policy.
This commit adds 'admins and moderators' option for create_stream_policy
and invite_to_stream_policy in frontend.
2021-04-29 15:18:49 -07:00
sahil839 f9503a4681 settings: Use role value directly to set user-role-select dropdown.
Since, we now have role value in the person objects sent from server
we can directly use that to set the value of dropdown used for
changing user role, instead of using multiple if-else conditions
for checking is_admin, is_owner, etc.
2021-04-29 15:18:49 -07:00
sahil839 77499589f9 users: Use role value directly to display user role text in frontend.
Since, we now get role value in person objects sent from server, we
can simply user user_role_map to display role in different places
instead of having multiple if-else conditions to check flags like
is_admin, is_guest, etc.
2021-04-29 15:18:49 -07:00
sahil839 4f354e28eb settings_users: Remove is_admin and is_guest fields from bot_info.
The is_admin and is_guest fields were used only by users and not
bots.
2021-04-29 15:18:49 -07:00
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
Abhijeet Prasad Bodas 2c30b543e7 buddy_data: Move related functions to be together.
This is a direct code move which puts all the functions
related to `user_id` lists near the bottom of the file.
This will make the file slightly easier to read.
2021-04-26 17:37:23 -07:00
sahil839 9e19490c52 settings: Add full members option in frontend for invite_to_realm_policy.
This commit adds 'admins and full members' option in frontend for
invite_to_realm_policy.
2021-04-26 17:28:01 -07:00
sahil839 84c8ef3505 settings: Remove extra space from options of invite_to_realm_policy. 2021-04-26 17:07:58 -07:00
nikhilmaske-2001 32bde79b61
confirm_dialog: Use the Confirm and Cancel labels.
Long labels like "Yes, Unsubscribe this stream" can
be confusing for translators and it can also create bad
strings that can end with like 4 long words in German.
It is better to have the simple options like "Confirm"
and "Cancel". This commit fixes this issue by changing
the text to "Confirm".

Fixes #17926.
2021-04-26 16:36:21 -07:00
Tim Abbott c3247128ff lint: Fix prettier issues with last commit. 2021-04-26 14:50:58 -07:00
aryanshridhar 29df7dc9c1 realm_emoji: Add warning modal before overriding default emoji.
Previously, realm emojis can override default emojis in emoji-picker,
if the user sets an exisitng emoji name to his/her custom emoji.

For clear understanding--
If a user sets an realm emoji with name `smile`, this leads to the
newly realm emoji override the existing default emoji `smile`.

To address such behaviour, Added a warning modal which requires
the user confirmation before overriding the default emoji.

Fixes #16913.
2021-04-26 14:42:10 -07:00