Commit Graph

9193 Commits

Author SHA1 Message Date
Aman Agrawal 44efc8eb37 web_public_view: Redirect to current narrow after login.
Add current hash as `next` URL to all login buttons
a spectator can access while in app.
2022-04-28 10:47:49 -07:00
Anders Kaseorg 567859d15d dropdown_list_widget: Convert DropdownListWidget to ES6 class.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-27 22:09:10 -07:00
Anders Kaseorg d131327760 dropdown_list_widget: Convert MultiSelectDropdownListWidget to ES6 class.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-27 22:09:10 -07:00
Anders Kaseorg 59c4680370 dropdown_list_widget: Reorder MultiSelectDropdownListWidget constructor.
ES6 class constructors must call the superclass constructor before
accessing this.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-27 22:09:10 -07:00
Anders Kaseorg 175dd999ac dropdown_list_widget: Separate setup method from constructor.
This refactoring is required so the next commit can reorder the
constructor.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-27 22:09:10 -07:00
Lauryn Menard 1292338537 frontend: Add `org_type` to realm settings updates and events.
Adds a drop-down menu for updating the organization type in the
`organization_profile_admin` page. Implements front end for
this setting to work / update like other organization profile,
notification and permissions settings.

One special note about this dropdown is that the listed options
should change once an organization has successfully set a type
other than 'unspecified' in the database. To accomplish this
the initial settings overlay build checks the realm_org_type
value in the page_params to select the correct options list,
and when the dropdown value is reset, either for update events
or for discarding changes, the page_params value is again used
to check for whether the 'unspecified' value should be present
as an option in the dropdown menu.

Adds basic node test for the `server_events_dispatch`.
Also adds a new help center documentation article for this
organization setting that is linked to in the UI.

Fixes #21692.
2022-04-26 16:29:12 -07:00
Dinesh 1c0368c402 compose_state: Add is_topic_field_empty().
This is required for adding a narrow-to-recipient button which
we do not want to show when topic field is empty.
2022-04-26 12:58:28 -07:00
Dinesh d363ea6158 compose: Extract update_on_recipient_change().
Runs when there's a change in recipient fields of compose box.
Moved the `update_fade` function to this.

This is a preparatory commit to add a feature to go to the
narrow you're composing to where we want to update the
button visibility when the recipients changes. The update could be
run in the function this commit adds.
2022-04-26 12:58:19 -07:00
sayamsamal 9488022d86 message_feed_ui: Remove "Unmute topic" from message action menu.
See the previous commit for background.
2022-04-25 17:35:02 -07:00
sayamsamal 86607ba318 message_feed_ui: Remove "Mute topic" from message action menu.
This change is motivated by a few considerations:

* The message actions menu has grown quite a bit and is at risk of
  feeling cluttered, especially with the upcoming Read Receipts feature.
* Conceptually, this menu is for interactions with the message, not
  its topic. There are other convenient ways to do this, in the topic
  recipient bar and left sidebar; hopefully removing this isn't much of
  an inconvenience. (If we add something back, we'd probably want a
  full "Topic actions" popover, not just this single item)
* Combined with the next commit, this removes the last copy of the
  topic name in this popover, which is helpful to its shape/layout,
  since topic names have much more variable length than the labels
  present here.

Fixes #21432
2022-04-25 17:29:36 -07:00
Aman Agrawal d0a697fba7 recent_topics: Disable filter buttons for spectator.
Instead of setting `disable` attribute to the elements, we make
them look like disabled and remove interactions with them. This
helps us keep the hotkey handling logic for navigation easier
to manage.

Fixes #21279
2022-04-22 15:33:26 -07:00
Sahil Batra 77fd03e426 invite: Add custom option for invite expiration time in frontend. 2022-04-20 13:31:37 -07:00
Sahil Batra 93eb5799ef invite: Pass time value to valid_to.
This is a prep commit for adding
custom expiration option.
2022-04-20 13:31:37 -07:00
Sahil Batra 61365fbe21 invites: Use expiration time in minutes instead of days.
This commit changes the invite API to accept invitation
expiration time in minutes since we are going to add a
custom option in further commits which would allow a user
to set expiration time in minutes, hours and weeks as well.
2022-04-20 13:31:37 -07:00
Raghav Luthra 22a5d008c1 user_settings: Add a setting to display names of users who reacted.
Added a setting to the bottom of Settings > Display settings > Theme section
to display the reacting users on a message when numnber of reactions are
small.

This is a preparatory commit for #20980.
2022-04-19 17:30:16 -07:00
George A. Michel 6c6986e2d3 popovers: Introduce case sensitivity to move topic button behavior.
Previously, the confirm button would be disabled when the user
attempted to change the capitalization of a topic, but still keep
it in the same stream. This commit fixes this discrepancy.
2022-04-19 16:10:35 -07:00
George A. Michel ca60660dc3 popovers: Replace move topic error with conditionally disabled button.
This commit changes the behavior of the move topic modal in
'stream_popover.js'. Instead of relying on an error banner, it
will now disable the submit button whenever an identically named
topic exists in the currently selected stream. To accomplish this,
it introduces a callback, update_submit_button_disabled_state(),
and calls it in three cases:

1. When the modal is initially loaded.
2. When the dropdown is changed.
3. When the topic name is changed.

The case insensitivity of topic comparison has been preserved.

Fixes #21711.
2022-04-19 16:03:38 -07:00
Sahil Batra 69a7cf9b7b streams: Check/uncheck the announce checkbox as per the previous state.
On changing the stream announce from being disabled to enabled, we
check/uncheck it based on its previous state when it was enabled.
2022-04-17 17:27:22 -07:00
Sahil Batra 2b6d2df6ff streams: Fix behavior of announce-stream checkbox in stream creation form.
This commit solves the bug which keeps the announce stream checkbox checked
for non-admin users when users are only allowed to create private streams
and not public streams.

The desired behavior is to not allow users to announce private streams, so
we keep the checkbox unchecked and disabled.

This commit fixes the above mentioned bug by removing the if-else block which
was executed after update_announce_stream_state (the function which handles
updating the checkbox considering if the realm has notifications stream or
not and whether the stream being created is public or private) and only checks
whether the realm has notification stream or not to show or hide the announce
stream checkbox irrespective of privacy of the stream being created.

This commit also fixes the handler to update the checkbox state on changing
privacy to update the checkbox state only on changing privacy value and not
on toggling the checkbox itself or changing post policy.

Fixes #21705.
2022-04-17 17:27:12 -07:00
Anders Kaseorg eda000899b actions: Split out zerver.actions.message_edit.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:36 -07:00
somesh202 b4aeb7a622 compose: Remove "stream" mention in case of PMs.
This commits adds an wildcard_mention_array which would contain the
mention tokens according to the message type. In case of PMs, it uses
only "all" and "everyone" mentions.

Fixes part of #21643.
2022-04-13 16:06:05 -07:00
somesh202 5bddd8fa48 compose: Fix "Notify" string in wildcard mentions typeahead for PMs.
This commit attempts to fix the suggestions typeahead for wildcard
mentions in case of PMs by using a conditional which checks for the
current compose_state and changes the string in parentheses accordingly.
In case of PMs, it uses the "(Notify recipients)" string instead of
"(Notify stream)".
2022-04-13 16:06:05 -07:00
aparna-bhatt 80bbca22f7 flatpickr: Use 24-hour time in time picker when appropriate.
We just need to translate the Zulip setting to the appropriate
`flatpickr` option.

Fixes #18960.
2022-04-08 15:01:36 -07:00
jai2201 c6f2b9c636 left-sidebar: Use same logic as of Topics view to render PMs.
Change the logic for rendering PM threads in PM section to
be in the same as that of topics view --
In default view, only recent 5 PM threads would be shown
and append the active conversation as the 6th one at last
if not present in those 5.

In PM section with unreads, a maximum of 8 conversations
would be shown and rest of them would be hidden behind
the 'more conversations' li-item, clicking on which takes
to the zoomedIn view of PM section where all the present
PM threads would be visible.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
2022-04-06 16:51:15 -07:00
Tim Abbott 3388eaf644 pm_list_data: Rename display_message => display_object.
We try to keep the term "message" in variable names reserved for
things that are actually Zulip messages.
2022-04-06 16:51:15 -07:00
Tim Abbott 64cdb9a919 left sidebar: Rename convos => conversations variable names.
This name violated our policy against abbreviations.
2022-04-06 16:51:15 -07:00
Aman Agrawal 4a73fd9e10 overlays: Add `is_modal_open` check along with `is_active` check.
This applies the fixes we have when restoring scroll position and
marking messages as read in background for overlays to modals.
2022-04-06 14:27:20 -07:00
Greg Price 00c017f83c apps: Link to release page for Android, rather than directly to APK.
The old link here broke once we introduced separate APKs per ABI,
in zulip/zulip-mobile#5296.

We could make a direct link to app-armeabi-v7a-release.apk , the one
that's compatible with almost all devices.  But perhaps better is to
just go back to linking to the release page, where the user can
choose the best APK for their device.  (If they're in the habit of
downloading APKs manually to install on their device, then probably
that means they're going to be used to choosing the right one.)

User report and discussion:
  https://chat.zulip.org/#narrow/stream/48-mobile/topic/Direct.20apk.20download.20link.20is.20404/near/1358758
2022-04-05 17:52:52 -07:00
Steve Howell c7ed21f891 markdown: Avoid blueslip dependency.
If katex throws an error that we can't deal with,
we just re-throw it now.
2022-04-05 15:22:53 +00:00
Steve Howell 83e3deab44 markdown: Remove last uses of helpers global. 2022-04-05 13:44:48 +00:00
Steve Howell 918de49f6b markdown: Nest get_linkifiers_regexes().
This makes parse() more re-entrant.

This also drives out a change to the linkifiers
test, where I no longer couple the linkifiers
logic to markdown concerns. I probably should have
done this in an earlier commit, but better late
than never. I didn't bother to split out a commit
for the test stuff, since it's just tests and
the commit is still fairly atomic in nature.
2022-04-05 12:42:15 +00:00
Steve Howell 17b60efdc7 markdown: Inject function for emoticon translations.
We want our parser to be as re-entrant as possible.
2022-04-04 14:07:18 -07:00
Steve Howell 03c15c8c14 markdown: Rename r to renderer. 2022-04-04 14:07:18 -07:00
Steve Howell 214ec099bb markdown: Eliminate setup() call.
It has always been pretty arbitrary what we did inside
of setup() vs. parse(), and we want to avoid unpredictable
results from other platforms neglecting to call setup().

On my machine you can parse a simple message in about
25 microseconds, based on a trial of a million messages
with the content of "**bold**".  Whatever portion of
that time is related to setup-related things like
compiling regexes should be negligible from the user's
perspective, since we never run parse() in a loop.
2022-04-04 14:07:18 -07:00
Steve Howell a77bf90601 markdown: Narrow stream/user_group types for mobile.
Our sub (i.e stream) and user_group objects have a bunch
of fields that aren't relevant to markdown parsing, so
we create narrow types that make it easier for us to
share code with mobile in the future.

I considered working purely in id space, but the problem
there is that user-entered stream names and user group
names need to be canonicalized.
2022-04-04 14:07:18 -07:00
Steve Howell 2bfdbbe7dc markdown: Extract get_topic_links. 2022-04-04 14:07:18 -07:00
Steve Howell 326dbfb934 markdown: Use options, not rules, for linkifier regexes.
This avoids the need to set a global from linkifiers.js.
2022-04-04 14:07:18 -07:00
Steve Howell 029b3e79a9 markdown: Add abstract_map() concept.
The abstract_map() helper clarifies that our code
doesn't need a concrete Map object from JS. This
change is possibly premature until we get a little
bit closer on integrating with mobile, since it
solves kinda the same problem that we might handle
more elegantly with TypeScript or Flow.

OTOH I find it to be pretty non-intrusive for the
webapp.
2022-04-04 14:07:18 -07:00
Steve Howell 3884710033 markdown: Inject linkifiers helper. 2022-04-04 14:07:18 -07:00
Steve Howell 1156001840 markdown: Inject emoji helpers.
Note that we try to avoid the helpers global, but we
still need a future commit to further clean things up.
2022-04-04 14:07:18 -07:00
Steve Howell 94f1fe6891 markdown: Avoid helpers global in some places.
These are the low-hanging-fruit places where we
can avoid using the helpers global.

The long term goal here is to make the markdown
code truly re-entrant, but some challenges still
remain.
2022-04-04 14:07:18 -07:00
Steve Howell cc51e89730 markdown: Set handlers at parse time.
This will help us make the code a bit more
re-entrant in future commits.
2022-04-04 14:07:18 -07:00
Steve Howell 38a3d89a13 zcommands: Fully parse messages from the server.
Before this change, we would use **some** options relating
to parsing messages, but not all of them.  The reason for
this was completely unintentional.

It's mostly a moot point, since the server sends back pretty
generic messages when you do something like invoke the
"/dark" command, and the message would parse the same way
whether or not the parser was looking for things like user
mentions or stream links.

In order to make this code predictable, I had to decide
whether we do a completely vanilla parse or a full message
parse. My decision now is mostly tactical. It's a trivial
one-line change to just use all the options for message
parsing, whereas it requires a major overhaul to allow a
vanilla parse.

I also predict that we will eventually want to parse these
server responses as if they were messages. I doubt the
zcommand responses would ever take advantage of it, but I
could imagine things like nag messages wanting to use user
mentions.

Even if my predictions are wrong, my decisions here are
pretty easy to reverse once we learn more.

For the particular case of zcommands, it is puzzling to me
why the server doesn't just send back HTML, but I don't want
to open that can of worms yet, as that would technically be
an API change.

For now I am happy with the one-line fix.
2022-04-04 14:07:18 -07:00
Steve Howell 06ba05b44d markdown: Extract parse_non_message().
The zcommand code was calling directly into the "marked"
library, which was extremely misleading, since you don't
get a vanilla parse of the markdown due to the fact
that markdown.js calls setOptions at initialize time.

This commit shifts the responsibility to markdown.js
as well as adding a bit of test coverage, but it is
otherwise just a pure code-move refactoring.

The next commit will tweak things further.
2022-04-04 14:07:18 -07:00
Steve Howell cf1149539e emojis: Swap the loops to build the emojis map.
This is mostly done for correctness reasons--it is
easiest from a logical standpoint to set the realm
emojis at the end of the function, since we do not want
them to be overwritten by normal emojis. The code
worked before this change, but it involved a clunky
check to map.has().

There is also probably a very minor performance
improvement insofar as N (the number of normal
emojis) is typically greater than R (the number
of realm emojis), and we eliminate N calls to
map.has in return for R calls to map.set.  Even
if R is quite large, the readability advantages
probably far outweigh any performance considerations,
since we are using native map calls.

Thanks to Austin Riba for this suggestion.
2022-04-04 13:28:49 -07:00
Steve Howell 3f6d0939fc emojis: Extract build_default_emoji_aliases(). 2022-04-04 13:28:49 -07:00
Steve Howell e7738981b7 emojis: Make build_emojis_by_name() a pure function. 2022-04-04 13:28:49 -07:00
Steve Howell d10e7ef85c emojis: Make build_emoticon_translations() a pure function. 2022-04-04 13:28:49 -07:00
Steve Howell c943447c6e emojis: Un-share the emoji.js module.
The mobile app was never able to use the shared
version of emoji.js, because, among other problems
with our code organization, the emoji.js module
is strongly based on a mutate-the-data paradigm
that doesn't play nice with React.  The way
that we mutate data and violate encapsuation
here is something that we would mostly want to fix
without even trying to shared code with mobile, so
subsequent commits will try to extract some pure
functions into a shared module.
2022-04-04 13:28:49 -07:00
Archisman Das 491b1513eb settings: Fix length of custom profile field URL input.
The backend validates that URL inputs are RFC valid URLs (with no
specific length limit), but the frontend appears to have a maximum
length of 50 specified, likely because of a copy-paste error.

Increase the HTML maxlength for this input to 2048, which is a length
supported for URLs by all major browsers.

Fixes #21633
2022-04-04 12:10:05 -07:00