Commit Graph

34236 Commits

Author SHA1 Message Date
Tim Abbott b234c52699 templates: Wrap stream_settings_checkbox. 2020-01-28 14:23:47 -08:00
Tim Abbott 7af6be9aaf subs: Fix reloading the browser to "manage streams" UI.
I'm not sure when this regressed, but the bug is one of those subtle
"8" != 8 issues.

Fixes #13756.
2020-01-28 14:17:29 -08:00
Pragati Agrawal b2c71b7cd8 stream edit: Move realm_setting_disabled in settings context.
Basic intention for this change is just to make code clean and intuitive.
2020-01-28 14:09:07 -08:00
Pragati Agrawal ada37a10f4 stream edit: Move logic for disabled checkboxes from template to js.
In templates we determine checkboxes are disabled by using the following
`if` clause,
```
{{#if (or (and is_muted notification_setting) realm_setting_disabled)}}
disabled="disabled"
{{/if}}
```
and it is more intuitive to do such calculation in javascript code, so we
added an `if_disabled` attribute in `settings` context which replaces
logical operations from `if` statement.

So for non-notification settings, it is
```
is_disabled: check_realm_setting[setting]
```
where check_realm_setting[setting] is same as realm_setting_disabled.

and for notifiaction settings it is,

```
ret.is_disabled = check_realm_setting[setting] || sub.is_muted;
```
2020-01-28 14:09:07 -08:00
Pragati Agrawal b862184d23 stream edit: Move is_checked calculation of stream settings in js.
It is more intuitive to do logical operations in js code instead of
templates and it is also cleaner.
2020-01-28 14:09:07 -08:00
Pragati Agrawal fd09111d8d stream_edit: Minor refactoring of stream_edit.stream_settings function.
The primary reason for this refactor is `.map` is more suitable in this
context instead of `_.each`.
2020-01-28 14:09:07 -08:00
Pragati Agrawal 0059624449 stream settings: Remove redundant arguments as a context to template.
This removes redundant arguments passed to `stream_settings_checkbox`
template from `subscription_settings`.
2020-01-28 14:09:07 -08:00
Tim Abbott 01de1c40d9 plans: Address some frequently asked questions. 2020-01-28 14:07:28 -08:00
Tim Abbott 0fa67c84d8 hotkey: Optimize processing_text.
Profiles of typing in the Zulip webapp's compose box after opening the
stream creation widget showed that hotkey.processing_text was a
significant expense.  There's no good reason for this -- the function
just needs to inspect the focused element; it just was written with a
sloppy selector.

While there's a secondary issue that, there's no good reason for this
extremely latency-sensitive code path (typing an additional character)
to be doing something extremely inefficient.
2020-01-28 16:47:56 -05:00
Steve Howell 67a3af4d88 emojis: Make it easier to type smiley icons.
We now give "slight smile" precedence over
"small airplane" if you type "sm".

More generally, we favor popularity over prefix
matches for emoji matches, as long as the popular
emoji matches on any of its pieces.
2020-01-28 12:48:02 -08:00
Steve Howell a87798bb8e refactor: Use Set for popular emojis. 2020-01-28 12:48:02 -08:00
Steve Howell 345fcd3a69 mobile sharing: Move sort_emojis into typeahead. 2020-01-28 12:48:02 -08:00
Steve Howell 011d52470c refactor: Move popular_emojis to typeahead library.
I removed a slightly confusing code comment, which I
will address in a follow up commit.  Basically,
"slight smile" still doesn't win over "small airplane"
when you search for "sm", which kind of defeats the
purpose of having popular_emojis for the typeahead
use case.  This is a problem with sort_emojis, though,
so when the comment was next to the list of popular
emojis, it wasn't really actionable.
2020-01-28 12:48:02 -08:00
Steve Howell 16ae53890b refactor: Move util.prefix_sort to typeahead.triage. 2020-01-28 12:48:02 -08:00
Steve Howell c2e6423b41 marked: Use startsWith instead of indexOf.
We are sweeping the codebase to use startsWith
when possible.  I kept this on a separate
commit due to us vendoring the library, just
to reduce some noise.
2020-01-28 12:48:02 -08:00
Steve Howell d0453dc8f4 performance: Use startsWith in many places.
Using startsWith is faster than indexOf, especially for long strings
and short prefixes.  It's also a lot more readable.  The only reason
we weren't using it was when a lot of the code was originally written,
it wasn't available.
2020-01-28 12:47:37 -08:00
Steve Howell d3e961e179 performance: Improve prefix_sort.
We only convert the query to lowercase outside the
loop for an Nx speedup, where N = number of items.

And then we use startsWith instead of indexOf, which
means we don't senselessly search entire strings
for matches.

(We've had startsWith polyfills for a while now.)

Unfortunately, unless a string start with the
exact casing of the query, we still create an
entire lowercase copy of the string for the case
insensitive match.  For the English use case
(and many other languages), we could further
optimize this by slicing the string before
converting it to lowercase.

Unfortunately, you have languages like German
with the straße/STRASSE problem.  It's not clear
to me how we handle them with the current code,
but I don't want to break that yet.
2020-01-28 13:49:03 +00:00
Steve Howell 10e75e6df5 refactor: Clean up prefix_sort get_item usage.
We use the nice es6 syntax to create the get_item
helpers (in the callers and for the default
value in the function).

Also we use better es6 style for the looping.
2020-01-28 13:07:25 +00:00
Steve Howell 162cb27690 emoji sort: Inline helper function. 2020-01-28 12:04:11 +00:00
Tim Abbott a3f08f01ec django: Use request.user.is_authenticated consistently.
In Django 2.0, request.user.is_authenticated stops supporting
`.is_authenticated()` and becomes just a property.  In 1.11, it's a
CallableProperty (i.e. can be used either way), and we already use it
as a property in several other places, so we should just switch to
using it consistently now to get it off of our Django 2.x migration
checklist.
2020-01-27 17:50:18 -08:00
Tim Abbott 1655aabe65 auth: Simplify logic around streams_to_subscribe.
This avoids some typing issues we'll have to resolve before upgrading
to Django 2.
2020-01-27 17:20:17 -08:00
Rohitt Vashishtha 630c564fc7 bugdown: Rewrite List Preprocessor logic to properly parse fences.
Previously, we didn't track opening and closing fences separately,
with led to bugs like not parsing a list that was immediately after
a quoted fence; we treated each ``` as a new fence.

This commit rewrites the function to maintain a stack of currently
open fences. If any of the parent fences is a code fence, we do not
insert a new line before a list.

We also add some test cases specifically to test this behavior with
complexly nested lists.

Fixes #13745.
2020-01-27 17:14:27 -08:00
Tim Abbott 56b49e5566 invite: Fix capitalization for 'receives new stream notifications'.
Caught by out i18n capitalization linter.
2020-01-27 17:06:51 -08:00
Steve Howell c968be9667 node tests: Add more direct tests for typeahead.
Our legacy unit tests do kind of deep testing; we
want to test get_emoji_matcher more directly.
2020-01-27 16:32:11 -08:00
Steve Howell b945cfd291 test-js-with-node: Extract run_tests_via_node_js(). 2020-01-27 16:32:11 -08:00
Steve Howell cc07bf04b7 test-js-with-node: Move constants toward top. 2020-01-27 16:32:11 -08:00
Steve Howell ed845d4da4 minor: Add static/shared/js to not-enforced logic.
This is an expedient fix--we should possibly just
require all modules in static/shared to be 100%
covered.
2020-01-27 16:32:11 -08:00
Steve Howell 4125eb28fd mobile sharing: Extract shared/js/typeahead.js.
This extracts get_emoji_matcher and all the
functions it depended on, most of which were
in composebox_typeahead.js.

We also move remove_diacritics out of the people
module.

This is the first major step for #13728.
2020-01-27 16:32:11 -08:00
Tim Abbott c2ab63094d invite-user: Adjust default size of the emails text area.
It looks cleaner starting with full page width.
2020-01-27 15:37:00 -08:00
Hashir Sarwar 69eadf6001 invite_user: Left-aligned the elements in invite users screen.
This change allows the stream names to fit in one line when
we have a long string particularly for notifications stream
with a message 'recieves notifications for new streams'.
2020-01-27 15:37:00 -08:00
Hashir Sarwar 13b3eb24b0 invitations: Avoid adding to notifications stream unconditionally.
Adding invited users to the notifications stream unconditionally isn't
a correct behaviour for guest users, where the previous behavior of
including the notifications stream no longer makes sense. Therefore,
while inviting a new user, the notifications stream is listed along
with other streams with a message "recieves notifications for new
streams" in order to distinguish it from other streams.

Fixes #13645.
2020-01-27 15:36:59 -08:00
Steve Howell 05f1c6983b stream create: Avoid unnecessary val attribute.
We used to put the user's email in a value, which was
redundant (we could find the value from
our parent's label) and brittle (would break
on email changes).

Now the DOM's a bit slimmer and more robust.

Also note that we now deal with user_ids, not emails,
in the call stack until we hit the "edge" and convert
to emails for the server.
2020-01-27 19:30:39 +00:00
Steve Howell 548bc8a4cf stream create: Remove obsolete markup.
We removed the last code to use the data-email
markup in the last commit.  (It was actually
just needed for tests.)
2020-01-27 18:16:39 +00:00
Steve Howell 0f6192cf6b casper: Use data-user-id for user checkboxes.
In the stream-create UI, we can look for data-user-id
now.
2020-01-27 18:16:39 +00:00
Steve Howell a0bd93d720 casper: Extract user_checkbox() helper.
This sets the stage to eliminate the data-email
markup.
2020-01-27 18:16:39 +00:00
Steve Howell 8e7ad57131 casper: Add get_user_id() helper. 2020-01-27 18:16:39 +00:00
Steve Howell ef892271dc int_dict: Fix type errors for user_groups.
This fixes some harmless type errors from the
following commit:

    6ec5a1f306

The IntDict code automatically converts strings to
integers, so this was not a user-facing problem, but
we want to have our callers do the conversions
explicitly.
2020-01-27 13:14:40 -05:00
Tim Abbott b80f8babcc node tests: Fix test failure in templates.js.
The partially merged code in #13703 was missing required test changes
in the first commit.
2020-01-26 22:52:59 -08:00
Mateusz Mandera 92c16996fc redis_utils: Require key_format argument in get_dict_from_redis. 2020-01-26 21:40:15 -08:00
Mateusz Mandera ad460e6ccb redis_utils: Validate requested key length in helper functions. 2020-01-26 21:40:15 -08:00
Mateusz Mandera 859bde482d auth: Implement server side of desktop_flow_otp. 2020-01-26 21:40:15 -08:00
Mateusz Mandera 8d987ba5ae auth: Use tokens, with data stored in redis, for log_into_subdomain.
The desktop otp flow (to be added in next commits) will want to generate
one-time tokens for the app that will allow it to obtain an
authenticated session. log_into_subdomain will be the endpoint to pass
the one-time token to. Currently it uses signed data as its input
"tokens", which is not compatible with the otp flow, which requires
simpler (and fixed-length) token. Thus the correct scheme to use is to
store the authenticated data in redis and return a token tied to the
data, which should be passed to the log_into_subdomain endpoint.

In this commit, we replace the "pass signed data around" scheme with the
redis scheme, because there's no point having both.
2020-01-26 21:32:44 -08:00
Hashir Sarwar 91aff4eec3 invite_subscription: Add `#` to the stream names.
Written the stream names as e.g. #announce, to match
how we display them elsewhere.
2020-01-26 21:20:11 -08:00
Tim Abbott 9ac3e1099c analytics: Remove last_modified field from FillState.
This field wasn't used for anything, and I think it has very limited
use for debugging, since fundamentally, it'll almost always have a
value within the hour of the actual timestamp in FillState, and any
more fine-grained logging we might want would be available in the
analytics job's own logs.

The proximal reason to remove it is that apparently Django's
model_to_dict doesn't support auto_now fields, and that caused some
trouble when working on adding more complete import/export support for
analytics data.
2020-01-26 20:38:26 -08:00
Tim Abbott d7ba77b83b search: Simplify CSS for search_icon.
This is preparatory refactoring for replacing the top navbar UI; in
the new version, the search_icon may not be an <a> tag.
2020-01-25 23:55:48 -08:00
Tim Abbott d356622594 docs: Add link from LDAP docs to invitation docs.
This addresses confusion we had with some organizations where they
were surprised that with only LDAP enabled, the "invite more users"
feature was available.

Fixes #11685.
2020-01-25 23:41:19 -08:00
Abhishek-Balaji 434e8d3104 home: Extract compute_show_invites_and_add_streams.
This extracts a function for computing show_invites and
show_add_streams, for better readability and testability.

This commit was substantially cleaned up by tabbott.
2020-01-25 23:41:08 -08:00
Rohitt Vashishtha 39420d6adb night_mode: Render the message instead of showing raw `/night` text. 2020-01-25 22:56:45 -08:00
Vishnu KS 97a25657a5 tests: Set class name of video call test to TestVideoCall.
The previous class name TestFeedbackBot was probably
leftover from copy paste.
2020-01-25 22:54:59 -08:00
Vishnu KS 05b4610381 bots: Remove feedback cross realm bot.
This completes the remaining pieces of removing this missed in
d70e799466 (mostly in tests).
2020-01-25 22:54:44 -08:00