Commit Graph

35740 Commits

Author SHA1 Message Date
Anders Kaseorg 257a026f13 docs: Bump copyright year.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-23 16:04:54 -07:00
Anders Kaseorg b26a420c7a styles: Size full-viewport fixed elements as 100%, not 100vw × 100vh.
Mobile Chrome includes the height of the address bar in its
calculation of 100vh, which was causing a corresponding part of our
content to be pushed off the bottom of the screen.

Fixes #11324.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-23 15:47:43 -07:00
YashRE42 30065b4ee8 navbar: Increase the click area of to initiate search.
This commit:
- Switches margin for padding on the search closed icon, to ensure we
  cover the region to the right of icon as clickable area.
- Applies the click handler that initiates the search to the second
  last element of the navbar:
  - This will most commonly be the narrow_description element, but may
    also be the entire navbar eg in the case of "ALL" or "starred".
    Applying this change to user names in "group-pm-with: ..." based
    narrows is a little questionable, but there are no other triggers
    on these names so this change makes sense for now.
  - The narrow_description may also contain links, which need to be
    handled correctly so that the behave like links should. We work
    around the onClick on the narrow_description, by applying a
    handler to <a> tags and invoking stopPropagation.
- We also add CSS to change the cursor to a pointer to make the
  search icon change color on hover over the clickable area to
  indicate that the search box can be opened with a single click.
- However, since <a> tags are handled differently, we add a hover
  listener which makes sure it behaves appropriately. We also increase
  the vertical padding of the <a> tags so they cover the entire
  vertical navbar region.
2020-04-23 15:37:51 -07:00
YashRE42 7c23c8730c navbar: Vertically align search icon to center of navbar. 2020-04-23 15:33:14 -07:00
Vishnu KS c45d594b0e settings: Set correct hostname for droplets in 18.04.
https://chat.zulip.org/#narrow/stream/3-backend/topic/droplet.20hostname
2020-04-23 15:32:42 -07:00
Rohitt Vashishtha 2825e6ad48 i18n: Support subexpressions of type (t "text") in Handlebars. 2020-04-22 17:57:16 -07:00
Rohitt Vashishtha 9d1f9e8a75 settings: Improve user interaction in DropdownListWidget.
This is a finicky change; we need to adapt around bootstrap internals
to first steal focus from the list, and then if the user uses arrow
keys, send that key to the list letting bootstrap focus on the list
elements.

The reverse: stealing abck focus to the input from the list, is not
possible without changing third/bootstrap.js because it's concept of
currently selected item depends on the item being focused. We retain
the pre-commit behavior for this, where the user can SHIFT+TAB to get
back to the input and type.

Ideally, a user will now interact with this widget like this:

1. Click the button to open the widget. The input is in focus.
2. Type a query to filter the results.
3. Seemlessly start using arrow keys to select an option.
4. Press "enter" to select the option.
2020-04-22 17:57:16 -07:00
Rohitt Vashishtha 8bf407878d stream_data: Create realm_has_notifications_stream().
We use this as part of our effort to wrap the use of -1 for null/None
from the rest of the code.
2020-04-22 17:57:16 -07:00
Rohitt Vashishtha 41481a906c settings: Simplify settings_list_widget interface.
We move more common code into settings_lsit_widget for cleaner code
in settings_org.js.
2020-04-22 17:57:16 -07:00
Rohitt Vashishtha e79935dbf7 stream_data: Remove page_params.notifications_stream.
We shouldn't add redundant data to page_params. Since we already have
page_params.realm_notifications_stream_id, we can use that value instead
of creating page_params.notifications_stream.

We, however, still need the name of the notifications stream to render
it in templates. Thus we create stream_data.get_notifications_stream().
2020-04-22 17:57:16 -07:00
Rohitt Vashishtha fe5a1eeaeb settings: Extract settings_list_widget.js.
We still have a dependency on settings_org in settings_list_widget that
we should try to remove.
2020-04-22 17:57:16 -07:00
Rohitt Vashishtha 5098944afc settings: Consolidate CSS of all dropdown widgets. 2020-04-22 17:57:16 -07:00
Rohitt Vashishtha b580baf682 settings: Refactor notifications_stream setting to use DropdownListWidget.
This commit removes most of the duplicate logic for the stream selection
dropdowns for the settings: `realm_signup_notifications_stream_id` and
`realm_notifications_stream_id`.

We also make minot changes to DropdownListWidget to accomodate the stream
rendering of the format: `#stream_name`.

We finally switch to using stream_ids instead of stream_name everywhere
which makes reading data from page_params simpler.
2020-04-22 17:57:16 -07:00
sahil839 3a7de8ad3b models: Add has_permission as a generic function for different policies.
This commit removes can_create_streams and can_subscribe_other_users
to use has_permission as a generic function in UserProfile model for
these settings policies.

Relevant changes are made to events.py to avoid duplication at some
places.
2020-04-22 17:48:52 -07:00
Puneeth Chaganti d5f5a99b07 tools: Verify that all integrations have bot avatars. 2020-04-22 17:45:30 -07:00
Puneeth Chaganti 18ae06404b tools: Use pre-generated avatar images for documentation bots.
Avatar images for bots used by the tool to generate integration
documentation screenshots are pre-generated and committed to the repository.
The `generate-integration-docs-screenshot` tool now uses these images,
instead of trying to create these avatar images on the fly.

Also, deleted the unused `create_png_from_svg` function.
2020-04-22 17:45:30 -07:00
Puneeth Chaganti 8ef6addc77 integrations: Add bot avatars for existing integrations with logos. 2020-04-22 17:45:30 -07:00
Puneeth Chaganti 87648596ee integrations: Add script to create bot avatars for integrations.
These avatars can be directly used by bots used for documenting these
integrations. In future, these could be used by bots created from a web UI.
2020-04-22 17:45:30 -07:00
Puneeth Chaganti 679f092a75 integrations: Extract code to get logo path for integrations. 2020-04-22 17:45:30 -07:00
Puneeth Chaganti e97c39c587 tools: Extract png generation code to separate module. 2020-04-22 17:45:30 -07:00
sahil839 0b9bea4566 typeahead: Show only active users in mention typeaheads.
'get_active_message_people` function is added which returns active
users who have sent the messages that are currently showing up in
the feed.

typeahead fetches the users from 'get_active_message_people` instead
of `get_message_people` and thus shows only active users in the
mention typeahead and excludes deactivated users.

Fixes #14310
2020-04-22 16:50:24 -07:00
Tim Abbott 2ed139cab3 message_edit: Hide spinner after a failure.
Otherwise, the spinner appears alongside the error message until the
widget is closed.
2020-04-22 16:38:32 -07:00
YashRE42 8b7e70ac27 message_list: Remove edit forms rather than just hiding them.
It is more semantically accurate to remove these elements instead of
just hiding them. We were previously using a .empty().append() chain
during creation/display of these forms, hence, we clearly don't desire
to preserve the element anyway (neither are there any worthwhile
benefits of trying to).
2020-04-22 16:25:38 -07:00
YashRE42 a27e6aa673 message_edit: Show inline topic edit spinner only via save handler.
This commit delegates the responsibility of displaying a spinner to
the "save_inline_topic_edit" function.
2020-04-22 16:25:38 -07:00
YashRE42 ee68ac9957 message_edit: Show error message if error edit fails.
Message_edit.js had a bug where if the inline topic_edit failed, it
would not show an error because it attempted to make a look up for
the message_id as though it were a message row edit, which would not
work. That was changed in a refactor, which made it apparent that
there was no error being rendered at all. This commit corrects it by
rendering the error, it also adds some styling to ensure the error
message is displayed inline and it makes a change to the template so
the error is rendered before the spinner.
2020-04-22 16:25:37 -07:00
YashRE42 ba40d68522 message_edit: Add Escape as hotkey to close the inline topic edit. 2020-04-22 16:25:37 -07:00
YashRE42 aa4adce4a4 message_edit: Refactor handle_edit_keydown to separate inline topic edits.
This commit cleans up the dirty if/else structure of
handle_edit_keydown by switching to switch case statements, and also
separates the handler for inline_topic_edits and that for message
row edits.
2020-04-22 16:25:37 -07:00
YashRE42 f18ef0469a message_edit: Refactor .save and .end to separate inline topic edits.
This commit makes it so that inline (recipient bar) topic edits follow
a different path from full message row edits in `message_edit.js`.
This commit:
- deletes `.save()` endpoint and replaces all calls to it with
 `.save_message_row_edit()` and  `.save_inline_topic_edit()`
- deletes `.end()` endpoint and replaces all calls to it with calls to
  either ".end_message_row_edit()" and ".end_inline_topic_edit()".
2020-04-22 16:25:37 -07:00
YashRE42 53dde9af68 message_edit: Refactor handle_edit_keydown to use switch case style. 2020-04-22 16:25:37 -07:00
Anders Kaseorg 9d9ae735c0 circleci: Test zulip-puppet-apply on Ubuntu 16.04.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 16:16:56 -07:00
Anders Kaseorg bfb314ff3a lint: Remove exclusions for Python 2 style type comments.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 16:16:08 -07:00
Aman Agrawal 2dc6d09c2a python3-upgrade: Move python2 scripts to run on python3. 2020-04-22 16:13:15 -07:00
arpit551 12c83141ed ci: Run Focal CI job.
Uncomment Focal CI job and fix its name.
2020-04-22 16:10:59 -07:00
arpit551 aabad1c0bb test: run test-locked-requirements only for Bionic.
Currently our compiled requirements files will differ for different
python versions. So we will run test-locked-requirements only for Bionic.
2020-04-22 16:10:59 -07:00
arpit551 fe6be1f61e setup_venv: Remove python2 dependencies for virtual environment.
These dependencies are not needed.
2020-04-22 16:10:59 -07:00
Steve Howell 39f18c1b4e node test: Remove unnecessary zrequires.
Some extraneous zrequires were added in
3bc818b9f7

This is not a huge deal, but it makes it
appear as if data modules are dependent
on things that they don't really care
about.  The tests should provide a bit
of signal on how "deep" an object's
dependencies go.
2020-04-22 18:54:27 -04:00
YashRE42 bad60ca7be navbar: Append space at the end of filter for search convenience.
As long as the current narrow isn't already a search narrow or empty,
we add a single space at the end of the current filter so that the
user can just press the right arrow key and begin typing their search
term, instead of having to add a space themselves.
2020-04-22 15:11:30 -07:00
Ryan Rehman c81240547e muting: Fix real time sync of muted topics. 2020-04-22 15:07:15 -07:00
Ryan Rehman 3bc818b9f7 muting ui: Update the muted topics table in settings.
The set_up_muted_topics_ui and templates have been
refactored to use list_render.
This is done to support filtering and sorting of
the muted stream topics.

This also includes the addition of a new Date muted header.
2020-04-22 15:07:15 -07:00
Anders Kaseorg 6983491a0f install-{sgrep,shellcheck}: Check that we detect the version correctly.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 15:05:17 -07:00
Anders Kaseorg c00f626f8e styles: Fix code block white-space for Python-Markdown upgrade.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 15:03:24 -07:00
Anders Kaseorg ba6ed1e177 .editorconfig: Add .scss, .hbs; drop weirder rules.
For example, nobody uses 4 space indents for .yml.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 15:03:08 -07:00
Steve Howell 02252c255a db tools: Use common scheme for digests.
We have two different digest schemes to make
sure we keep the database up to date.  There
is the migration digest, which is NOT in the
scope of this commit, and which already
used the mechanism we use for other tools.

Here we are talking about the digest for
important files like `populate_db.py`.

Now our scheme is more consistent with how we
check file changes for other tools (as
well as the aformentioned migration files).

And we only write one hash file, instead of
seven.

And we only write the file when things have
actually changed.

And we are explicit about side effects.

Finally, we include a couple new bot settings
in the digest:

    INTERNAL_BOTS
    DISABLED_REALM_INTERNAL_BOTS

NOTE: This will require a one-time transition,
where we rebuild both databases (dev/test).
It takes a little over two minutes for me,
so it's not super painful.

I bump the provision version here, even
though you don't technically need it (since
the relevant tools are actually using the
digest files to determine if they need to
rebuild the database).  I figure it's just
good to explicitly make this commit trigger
a provision, and the user will then see
the one-time migration of the hash files
with a little bit less of a surprise.

And I do a major bump, not a minor bump,
because when we go in the reverse direction,
the old code will have to rebuild the
database due to the legacy hash files not
being around, so, again, I just prefer it
to be explicit.
2020-04-22 14:41:42 -07:00
Steve Howell f4942e9927 digest refactor: Clean up names and comments.
We now use `extra_strings` instead of `package_versions`
to allow for more generic digests to be built
(without naming confusion).
2020-04-22 14:41:42 -07:00
Anders Kaseorg 3ac9982411 circleci: Test provision and upgrade error messages on Ubuntu 16.04.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 14:39:32 -07:00
Mateusz Mandera ec6022a186 logging_util: Handle record.status_code missing in skip_200_and_304.
Fixes #14595.
Invalid HTTP requests could end up in an unhandled exception in
skip_200_and_304 due the record not having the status_code attribute
set. With this change we'll avoid the exception

Example:
curl  -X POST -H 'Transfer-Encoding : chunked' --data-binary 'a' 'http://zulipdev.com:9991/json/messages/57'

2020-04-21 10:56:22.007 WARN [django.server] "POST /json/messages/57 HTTP/1.1" 405 95
2020-04-21 10:56:22.007 INFO [django.server] code 400, message Bad request syntax ('a')
2020-04-21 10:56:22.008 WARN [django.server] "a" 400 -
2020-04-22 11:26:13 -07:00
Anders Kaseorg fead14951c python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.

We can likely further refine the remaining pieces with some testing.

Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:

-    invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+    invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(

-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None

-    notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
-    signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+    notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+    signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)

-    author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+    author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)

-    bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+    bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)

-    default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-    default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+    default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+    default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)

-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}

-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}

-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 11:02:32 -07:00
Anders Kaseorg af1aef9b39 models: Move flush_per_request_caches after cache definitions.
This will work around https://bugs.python.org/issue34939 when we
convert the type comment to a Python 3.6 style annotation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 10:49:20 -07:00
Anders Kaseorg f8c95cda51 mypy: Add specific codes to type: ignore annotations.
https://mypy.readthedocs.io/en/stable/error_codes.html

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 10:46:33 -07:00
Anders Kaseorg 029bfb9fee mypy: Remove unnecessary type: ignore annotations.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 10:46:33 -07:00