Commit Graph

6524 Commits

Author SHA1 Message Date
Steve Howell 772d7fa705 user settings: Improve deactivation-confirm code.
We are now more rigorous about only showing one
modal, only having one handler active, and not
needing to pull info out of the DOM.
2020-05-09 10:41:14 -07:00
Steve Howell fd3d7fa9f2 user settings: Move get_human_profile_data().
This is a purely lexical move (apart from changing
a closure variable to an argument), which is
simply designed to make less indentation for the
reader and to de-clutter `handle_human_form`.
2020-05-09 10:41:13 -07:00
Steve Howell f3e425c071 user settings: Build profile fields in open_human_form. 2020-05-09 10:22:37 -07:00
Steve Howell 79c25f40ce minor: Use person.full_name directly.
The get_full_name() helper is overkill when
we already have the `person` object, and the
surrounding code is already referencing fields
directly.
2020-05-09 10:22:37 -07:00
Steve Howell d5cadbcec2 user settings: Separate code for bot form.
When editing a bot, there are only two fields
that are similar to humans--full name and
email--which are trivial.

Before this commit we used a single codepath
to build the human form and the bot form.

Now we have two simple codepaths.

The tricky nature of the code had already led
to ugly things for the bot codepath that
fortunately weren't user facing, but which
were distracting:

    - For bots we would needlessly set things
      like is_admin, is_guest in the template
      data.

    - For bots we would needlessly try to update
      custom profile fields.

The code that differs between bots and humans
is nontrivial, and the code was both hard to read
and hard to improve:

    - Humans don't have bot owners.

    - Bots don't have custom profile fields.

The bot-owner code is nontrivial for performance
reasons.  In a big realm there are tens of thousands
of potential bot owners.  We avoid the most egregious
performance problems (i.e we don't have multiple
copies of the dropdown), but we may still want
to refine that (at least adding a spinner).

The custom-profile-fields code is nontrivial due
to the dynamic nature of custom profile fields,
which can bring in specialized widgets like
pill fields.

Now each form corresponds to a single endpoint:

    * human -> /json/users
    * bot -> /json/bots

Before we had a lot of conditional logic in
the template, the code to build to views, and
the code to submit the data.  Now everything is
much flatter.

The human code is still a bit messy (more work
coming on that), but the bot code is fairly
pristine.  All three components of the bot code
fit on a page, and there are no conditionals:

    - admin_bot_form.hbs
    - open_bot_form
    - handle_bot_form

We may want to grow out the bot code a bit
to allow admins to do more things, such as
adding services, and this will be easier now.
It would also be easier for us now to share
widgets with the per-user bot settings.

Note that the form for editing human data will
continue to be invoked from two panels:

    - Users
    - Deactivated users

There are some minor differences between
users and deactivated users, but the shape of
the data is the same for both, so that's still
all one codepath.

We eliminate `reset_edit_user` here, since
it was never used.

One nice thing about these forms was that they
had very little custom CSS attached to them
(at form-level specificity), and it turned out
all the custom CSS was for the human-specific
form.
2020-05-09 10:22:37 -07:00
Steve Howell f2ee1a1a65 user settings: Extract handle_* helpers.
This is purely refactoring.

The new call tree is:

    on_load_success
        populate_users
        handle_deactivation
        handle_reactivation
        handle_user_form
        handle_bot_owner_profile
        handle_bot_deactivation

The actual sequence of operations should be
identical to before.
2020-05-09 10:22:37 -07:00
Steve Howell 56517788fb user settings: Extract section.*.create_table(). 2020-05-09 10:22:37 -07:00
Steve Howell 2272c5e6eb modals: Use selectors for open_modal/close_modal.
When reading the calling code, it's helpful to know
that we're really just passing in a selector.  The
calls to open_modal/close_modal are nicer now to
reconcile with surrounding code, and you don't have
to guess whether the parameter is some kind of
"key" value--it really just refers directly to a DOM
element.

There is nothing user-visible about this change, but
the blueslip info messages now include the hash:

    open modal: open #change_email_modal
2020-05-09 10:22:37 -07:00
Steve Howell d3aded2ae7 drafts: Rename open_modal -> open_overlay.
We consider the drafts thing to be an overlay,
not a modal, so the old name was confusing.
2020-05-09 10:18:59 -04:00
Aman Agrawal 0c2b25cab3 home/page_params: Add suffix `_mib` to clarify the size units.
The docs say "megabytes" or "MB", but client software needs to
know the actual meaning, which is in mebibytes.
2020-05-08 14:54:54 -07:00
Pragati Agrawal bd9b74436c org settings: Enable message_retention_days in org settings UI.
Since production testing of `message_retention_days` is finished, we can
enable this feature in the organization settings page. We already had this
setting in frontend but it was bit rotten and not rendered in templates.

Here we replaced our past text-input based setting with a
dropdown-with-text-input setting approach which is more consistent with our
existing UI.

Along with frontend changes, we also incorporated a backend change to
handle making retention period forever. This change introduces a new
convertor `to_positive_or_allowed_int` which only allows positive integers
and an allowed value for settings like `message_retention_days` which can
be a positive integer or has the value `Realm.RETAIN_MESSAGE_FOREVER` when
we change the setting to retain message forever.

This change made `to_not_negative_int_or_none` redundant so removed it as
well.

Fixes: #14854
2020-05-08 14:09:31 -07:00
Pragati Agrawal 12504075ee org settings: Rename plan_includes_wide_organization_logo to more generic.
It's a preliminary step to enable message_retention_setting in org settings
UI, which is a non-limited plan only feature. So we require a page_param
property that tells us the limited-plan state of the Zulip realm.
2020-05-08 14:04:21 -07:00
Pragati Agrawal adb41b2e62 org settings: Use `get_input_element_value` in `check_property_changed`.
Logic to find the element value was duplicated in check_property_changed,
which can be replaced by `get_input_element_value`.
2020-05-08 14:04:21 -07:00
Pragati Agrawal fd9b868635 org settings: Use standard "types" in `.get_input_element_value()`.
The reason is to make the hardcoded property type values consistent with
`typeof` operator.
2020-05-08 14:04:21 -07:00
Pragati Agrawal 4eac4542e8 org settings: Return `undefined` in get_input_element_value.
This change makes `.get_input_element_value()` return a `undefined` instead
of `null` when `input_type` is not defined. Which also make sense
logically, as

> null: absence of value for a variable;

> undefined: absence of variable itself;

Source: https://stackoverflow.com/q/5076944/7418550
2020-05-08 14:04:21 -07:00
Tim Abbott e2e0039ffe settings: Expose UI for limiting optional invitations to admins.
This option case is important both for cleaning the UI when
invitations as not required, as well as for some policy situations.

Partially fixes #14859.
2020-05-08 11:09:21 -07:00
Anders Kaseorg b079ba97ff desktop-login: Fix window.open invocation.
window.open expects a string, not a URL object.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-06 13:57:07 -07:00
Steve Howell b46c8d1dc3 typeahead: Avoid tracebacks due to navbar changes.
In our recent navbar changes, we made it so that the
Esc key auto-closed the navbar. Unfortunately,
that code would break other typeaheads with a traceback.

One user-facing symptom was that if you drafted a PM
and started a typeahead on a recipient, then hitting
the Esc key wouldn't close the typeahead.

Now we use an `on_escape` mechanism that is specific
to the navbar typeahead, so that it's both generic and
harder to break for widgets that don't opt in to it.

See bbdc66a214 for
more details on the commit that introduced this
regression.

Note that I only call `tab_bar.exit_search` now.
I don't check the class name of the input element,
since I know that the Esc key is happening in the
context of search.  And I don't blur the input,
since it's going to be hidden.
2020-05-06 13:25:49 -07:00
Steve Howell 026474921a todo widget: Downgrade error to warning.
We were creating errors for task keys that were
from older versions of the widget.  We don't migrate
data for the widgets yet (they're all still considered
to be somewhat beta); instead, we just drop bad data
on the floor.

Rohitt and I re-tested the widget on czo pretty
extensively to verify that these errors don't show
up for newly created widgets.
2020-05-06 09:35:04 -04:00
sahil839 435e231567 click_handlers: Remove click handler for closing stream settings.
The click handler for closing stream settings in click_handlers.js
is removed as overlays.js contains common logic for closing all
overlays.

'exports.close' in subs.js is removed and 'hashchange.exit_overlay'
is used in 'overlays.open_overlay' call.
2020-05-05 21:44:09 -07:00
Rohitt Vashishtha d5576217fe typeaheads: Show tip text for silent mentions.
This addition is prompted by the feedback and discussion at
https://chat.zulip.org/#narrow/stream/137-feedback/topic/silent.20mention.
2020-05-05 15:20:06 -07:00
Tim Abbott b9098a42d4 messages: Allow moving a topic to another stream.
This completes the implementation of support for moving a topic to
another stream by adding a basic UI for it.

Fixes #6427, which was previously the most-upvoted issue request in
Zulip.

There are likely to be a bunch of follow-up UI improvements on top of
this change to fully flesh out the feature.
2020-05-04 10:03:03 -07:00
Hashir Sarwar 55a8e7dff2 settings: Offer hiding presence info from other users.
For privacy-minded folks who don't want to leak the
information of whether they're online, this adds an
option to disable sending presence updates to other
users.

The new settings lies in the "Other notification
settings" section of the "Notification settings"
page, under a "Presence" subheading.

Closes #14798.
2020-05-02 15:09:05 -07:00
Hashir Sarwar 735785f985 stream_topic_history: Track the most recent message in streams.
This adds a way to keep track of max_message_id of a
stream and fetch it using the method get_max_message_id().

This will be useful for sorting streams by most recent
activity which will be implemented in the upcoming commit.

Essentially rewritten by tabbott to have a coherent tracking system,
and provide documentation.

Part of #10794.
2020-05-02 11:16:51 -07:00
jagansivam28 bbf5a5efed invitation: Make Member to see invitations sent by him/her.
Member of the org can able see list of invitations sent by him/her.
given permission for the member to revoke and resend the invitations
sent by him/her and added tests for test member can revoke and resend
the invitations only sent by him/her.

Fixes #14007.
2020-05-01 17:42:49 -07:00
Anders Kaseorg a552c2e5f9 auth: Use the clipboard instead of zulip:// for desktop auth flow.
This does not rely on the desktop app being able to register for the
zulip:// scheme (which is problematic with, for example, the AppImage
format).

It also is a better interface for managing changes to the system,
since the implementation exists almost entirely in the server/webapp
project.

This provides a smoother user experience, where the user doesn't need
to do the paste step, when combined with
https://github.com/zulip/zulip-desktop/pull/943.

Fixes #13613.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-04-30 16:45:00 -07:00
Pranav 41cdf11e16 settings_account: Remove redundant call to loading.make_indicator.
Previously, a spinner was created and this spinner element passed to
do_settings_change function, which also created a spinner, making the
first spinner creation useless. This commit removes the spinner creation
logic and just passes the element where the spinner is to be rendered.
2020-04-30 16:13:49 -07:00
Wyatt Hoodes 5a58b7c549 data exports: Keep deleted export in UI table.
It makes sense to keep a deleted export in the table,
along with the time of deletion, for auditing reasons.
2020-04-30 13:00:59 -07:00
Wyatt Hoodes 2204f33936 data exports: Switch to solely using a status column. 2020-04-30 13:00:59 -07:00
Wyatt Hoodes 82e7ad8e25 data exports: Handle pending and failed exports.
Prior to this change, there were reports of 500s in
production due to `export.extra_data` being a
Nonetype.  This was reproducible using the s3
backend in development when a row was created in
the `RealmAuditLog` table, but the export failed in
the `DeferredWorker`.  This left an entry lying
about that was never updated with an `extra_data`
field.

To fix this, we catch any exceptions in the
`DeferredWorker`, and then update `extra_data` to
encode the failure.  We also fix the fact that we
never updated the export UI table with pending exports.

These changes also negated the use for the somewhat
hacky `clear_success_banner` logic.
2020-04-30 13:00:59 -07:00
Wyatt Hoodes b913478b76 settings_exports: Replace clear_succes_banner logic.
ui_report.js already had the functionality we were
looking for.
2020-04-30 13:00:59 -07:00
Siddharth Varshney de47262518 sidebar: Rename classes for menu icons in sidebars. 2020-04-30 10:56:09 -07:00
Jagan 805ac2475b settings: Redesign edit bot form.
This removes the weird edit-bot sidebar, replacing it with a modal,
matching our edit-user widget (and various similar ones).

Fixes #13644 by removing the buggy code.
2020-04-28 23:08:45 -07:00
Hashir Sarwar 0cbb778af4 ui_init: Fix play button position on video thumbnails.
This fixes a jQuery bug that broke the postion of play
button on video thumbnails particularly when YouTube
images fetched from oembed are displayed.
2020-04-28 22:41:00 -07:00
Aman Agrawal cfe427b3f7 narrow: bugfix: Update stream list height after rendering completes.
When switching from Private Messages narrow to
All messages narrow, stream list max-height was not
correctly updated. Stream list max-height was calculated
 before new height were updated by browser for
All message narrow.

Inshort:
Stream list max-height was being updated before the browser could
render height for `#global_filters`. Calling resize after narrow
completes removes this issue.
2020-04-28 12:32:40 -07:00
Anders Kaseorg a6fee2f18e notifications: Use electron_bridge.new_notification when available.
This will eventually let us delete a bit of annoying compatibility
code from the desktop app’s injected JavaScript.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
Anders Kaseorg 549ed3913c notifications: Use NotificationAPI for permission_state.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
Anders Kaseorg f277eb022c notifications: Use addEventListener to register handlers.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
Anders Kaseorg cb52f4d7fc notifications: Remove weird Firefox code.
Firefox’s notifications are fine, and iconUrl isn’t a thing.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
Anders Kaseorg a16cddf84f notifications: Remove cancel_notification_object wrapper.
Running the close handler won’t break anything; it’s safe to delete
from a Map while iterating through it.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
Anders Kaseorg 0b1c27192f notifications: Remove long-gone webkitNotifications draft API.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
Anders Kaseorg 8138e06935 notifications: Add link for sending a test notification.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
Anders Kaseorg e701f20861 electron_bridge: Use getter and setter interface to mutable properties.
This exists in all versions of the desktop app that we still support,
and will eventually let us delete a bit of annoying compatibility code
from the desktop app’s injected JavaScript.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-26 23:02:05 -07:00
clarammdantas 25c5856988 stream_edit: Remove unnacessary conditionals.
The condition was removed because in either case we
want to have the stream_row and not the sub/unsub
button, so we can always get the stream_row directly.
2020-04-26 22:42:38 -07:00
Steve Howell c11de1e3a7 user profile cards: Fix bug with deactivated user.
We had a user have problems with the user
profile menus that you get when you click
on either sender avatars or mention pills.

If a deactivated user had a long enough email
that we would normally want to un-hide the clipboard
icon for them, we would crash inside of
`init_email_clipboard`, because the icon isn't
there for them.  If the user didn't have the
console open to see the crash, the symptom
became that you would get multiple cards
visible and kind of "stuck".

I chose to fix this by just making the code
defensive with respect to the absence of the
icon, instead of short-circuiting it for
deactivated users.

It's a bit odd that we still have an element
matching `.user_email_popover` in the profile
card for deactivated users, since that element
doesn't actually include an email, but it instead
says "(This user has been deactivated)".  I
considered removing the class, but the CSS
that we use for emails kind of applies here
too.

Testing this is a kind of a pain, as you want
either long emails or to just temporarily hack
this condition to true:

    if (this.clientWidth < this.scrollWidth) {
        // ...
    }

And then test with a deactivated user, of course.

Fixes #14473
2020-04-26 11:12:45 -07:00
rebtung f7fbe3419f api: Improve consistency of reactions API.
Previously, the message and event APIs represented the user differently
for the same reaction data. To make this more consistent, I added a
user_id field to the reaction dict for both messages and events. I
updated the front end to use the user_id field rather than the user
dict. Lastly, I updated front end and back end tests that used user
info.

I primarily tested this by running my local Zulip build and
adding/removing reactions from messages.

Fixes #12049.
2020-04-26 10:35:55 -07:00
Steve Howell df57f8c006 list_render: Move sort functions to module scope.
Moving these to module scope makes it a little
easier to round out our test coverage, plus
it's a bit less clutter in the widget code.
2020-04-24 18:24:12 -04:00
Steve Howell f2ddd31fe6 list_render: Clean up filter-missing errors. 2020-04-24 10:50:08 -04:00
Steve Howell 059ad86967 list_render: Error if opts are missing.
The check here was too late, and it should
have given a blueslip error.  We obviously
don't expect these errors at runtime; this
is a convenience for developers creating
new widgets.
2020-04-24 10:50:08 -04:00
clarammdantas de28c8d238 streams: Correct spinner bug when subscribing.
When clicking on the tick to subscribe to a stream,
an error occurred while trying to find the spinner
location because there are two DOM elements with the
same class, sub_unsub_button, and this made the
selector get the subscribe/unsubscribe button instead
the correct stream_row, where the tick is.

We now check whether the tick or the subscribe/unsubscribe
button was clicked, and if it was the last one we make
sure the stream_row and not the button is being passed
to the sub_or_unsub function.
2020-04-23 17:31:31 -07:00
clarammdantas a3a850b440 streams: Rename row_object to stream_row. 2020-04-23 17:31:31 -07:00
Jagan c69dc720ff admin user list: Replace the buttons with icons.
1. Replaced the deactivate and reactivate buttons with icons.
2. Added (you) near the current user name to denote his/her account in
the entire user list.

Tweaked by tabbott to reuse the (you) formatting from the right
sidebar here for readability and consistency.

Fixes #6313.
2020-04-23 16:49:57 -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
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 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 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
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
YashRE42 f25aacdf66 navbar: Reset searchbox text on calling ".exit_search()".
This commit makes sure that we replace the text in the search box
every time a user calls `exit_search()` eg via the escape hotkey or by
clicking the `x` icon, so that the search box discards any input and
always starts at the current narrow.
2020-04-22 09:40:47 -07:00
vaibhavrajsingh2001 2c0c936e40 stream settings: Correct alignment of filter streams div.
The div containing options for filtering streams was placed in the
centre. Aligned it towards the right. Had to pass a special check
variable in subs.js:540 to add the specific class for this purpose.
This was a specific scenario where this sort of CSS was to be added,
hence had to make a specific case.

Also, fixed the bottom border color of the search streams bar for night
mode.
2020-04-21 16:59:41 -07:00
Rohitt Vashishtha e94b151ff6 composebox_typeahead: Properly populate stream topic data for message edits.
Previously, we would always pick up the stream and topic name from
compose_state. This would work for message edits as well when the
composebox was open.

Now, if we are in a message edit, we get the stream and topic of the
message being edited before falling back on trying to populate using
the composebox state.

Fixes #14545.
2020-04-21 16:15:28 -07:00
sahil839 578ccea220 typeahead: Update for email_address_visibility settings.
This commit changes the code to show user according to emails based
on email_address_visibilty_values and the type of user.

1. email_address_visibility = admins,members and guests

   Typeaheads are shown according to original emails.

2. email_address_visibility = admins only

   Typeaheads are shown according to original email to admins which
   were previously shown according to system-generated email of
   form "user10@zulipdev.com".

   For non-admins, typeaheads are not shown according to emails as
   they are not visible in the typeahead itself to non-admins.

3. email_address_visibility = nobody

   Typeaheads are not shown according to emails for all type of users.
2020-04-20 20:53:39 -07:00
sahil839 821059814e typeahead: Fix broken email address handling in typeahead.
Previously, when email_address_visibility was set to admins only, the
non-admin users were not shown emails in typeaheads, while admins were
shown emails of the form 'user11@zulipdev.com'.

This commit corrects it to show the original emails in typeaheads and
input box of adding subscribers to admins and the behaviour is same
for non-admins.
2020-04-20 20:49:47 -07:00
sahil839 6657cddd7a refractor: Move get_visible_email from popovers.js to people.js.
This commit moves the get_visible_email function to people.js
as this function will be used in other places and people.js seems
relevant file for this.

Tests are added to get full coverage.
2020-04-20 20:48:47 -07:00
Roland Crosby ac7ec426b0 Add stream sorting widget to subscriptions page
This change adds a toggle widget to the "add streams" page that
lets the user change the sort order of the streams list. So far,
this supports sorting by stream name, by number of subscribers,
or by estimated weekly traffic.
2020-04-19 15:07:37 -04:00
jiviteshjain 3da483487a manage streams: Move stream filter to next line.
Previously, in narrow viewports, the "filter"
option would disappear, which was very confusing.

This commit moves the filter streams input to the
next line, making it visible at all viewport widths.

@showell modified the commit message and got Casper
tests passing.

Fixes #12898.
2020-04-19 09:59:11 -04:00
Pranav 3f47c0f8bc click_handlers: Refactor select_message_function.
This uses the early-return pattern to make the main click handler for
opening the compose box more readable.
2020-04-18 22:32:51 -07:00
Pranav ce9f21545a message_list: Use document.getSelection to identify drags.
This removes the messy click-or-drag detection algorithm originally
added in fe8f63c389, which fixed a messy
bug in an earlier algorithm from ~2013, whose sole purpose as to check
whether we're doing a selection and if so, not trigger the
click-on-message-body click handler.

The right fix is of course to do that check correctly.
2020-04-18 22:30:18 -07:00
Pranav d2cf2ba93f drafts: getSelection to differentiate clicks from drags.
We can use getSelection to distinguish between clicks and drags while
accessing the body of a saved draft.  Previously, the draft would be
restored when trying to select draft text to copy/paste.

Fixes #14447.
2020-04-18 22:19:48 -07:00
Pranav 04d55f04ab stream_edit: Replace $this with e.currentTarget.
Replace the '$this' by e.currentTarget to make code clean.
2020-04-18 22:05:39 -07:00
Pranav 3b71e0dbfb stream settings: Fix UI feedback on clicking checkbox to subscribe.
Before this change, on clicking a checkbox to toggle subscription to a
stream no UI feedback was shown and users could toggle the checkbox
multiple times to send multiple requests causing bugs. This commit
initializes a spinner on clicking the checkbox, to provide a UI feedback
to the user. This commit also disables the checkbox once a request for
subscription has been sent and re-enables the checkbox only after a
response.

This change has been accomplished by introducing a div to display the
spinner in subscription.hbs. The corresponding styles for the spinner
have been added in subscriptions.scss. The ajaxSubscribe &
ajaxUnsubscribe functions in subs.js have been updated to show & hide
the spinners for the time the request is in process. An additional
parameter, the concerned stream object is passed to these functions(
through the sub_or_unsub function) to get the location where the spinner
is to be displayed. Finally, the checkbox click handler is updated to
support these changes.

The testing for this has been done by adding a wait of 2 secs in
actions.py for the response. This gives sufficient time to test the
working manually. Also, for error cases an error has been sent from
action.py and the behaviour has been manually observed.

Fixes #14481.
2020-04-18 22:00:02 -07:00
Divyanshu Agrawal a076bcb9f4 file uploads: Internationalize upload status text.
Use i18n to ensure that the status text 'Uploading filename...' is
properly localized.
2020-04-18 21:22:47 -07:00
Divyanshu Agrawal b30da07fd3 file uploads: Remove status text for user cancelled uploads.
Remove the 'Uploading file...' message from the compose box when
the user manually cancels a file upload.
2020-04-18 21:22:47 -07:00
Divyanshu Agrawal 4215386ae3 file uploads: Remove status text for failed server uploads.
Remove the 'Uploading file...' message from the compose box when
file upload fails due to a server side error.
2020-04-18 21:22:47 -07:00
Divyanshu Agrawal 6d7e91b6c7 file uploads: Remove status text for failed frontend uploads.
Some uploads can be rejected in the frontend, like when the file
size is too big, without sending the file to the server. Remove the
'Uploading file...' message from the compose box in such cases.
2020-04-18 21:22:47 -07:00
Abhishek-Balaji b3ce150aac alert settings: Relocate alert_word_settings_item.hbs
Relocating alert_word_settings_item.hbs from templates/ to
templates/settings.
2020-04-18 15:50:04 -07:00
Abhishek-Balaji 2ea8dfb178 alert settings: Move alert words addition form separately.
Now, the system uses word='' and an editing=True for rendering an
form for addition of alert words. This is a very vulnerable
way to implement said feature and this commit fixes that.
The addition form has been moved to alert_word_settings.hbs
thereby rendering it only once but always. Now, we do not have
to manually add an empty word and editing for the form to be
rendered.
As part of refactoring, the editing parameter has also been
removed as there is no purpose left.
2020-04-18 15:50:04 -07:00
Anders Kaseorg 8e93175822 requirements: Upgrade Python-Markdown from 3.1.1 to 3.2.1.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 13:09:51 -07:00
Anders Kaseorg ddcb828349 markdown: Match Python-Markdown code whitespace more closely in JS.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 13:09:51 -07:00
YashRE42 bbdc66a214 typeahead: Close/open typeahead with searchbox.
The todo here is to ensure that we open and close the typeahead as
soon as the navbar search is opened/closed.
2020-04-17 13:37:04 -07:00
YashRE42 eb4a2b9d4e navbar: Improve structure & styling for top navbar.
This updates the logged-in top navbar to display the stream/message
name, number of users, and description. It also replaces the search
bar with a search icon that expands into a full-width search bar.

Co-authored-by: Max Nussenbaum <max@maxnuss.com>

Fixes: #164.
Fixes: #5198.
2020-04-17 13:35:44 -07:00
YashRE42 5fdb8989e5 filter: Use ', ' to separate names in PM title.
This is a prep commit for the navbar redesign.
2020-04-17 13:13:31 -07:00
Tim Abbott 497383cc12 stream_topic_history: Fix incorrectly migrated field name.
In ee0d4541b4, we renamed the topic_date
-> stream_topic_history, and in the process renamed some local object
properties from .name => .topic_name, and accidentally change the
type for the data from the server as well.

The test fixtures were incorrectly migrated in the same way, so we fix
that as well.
2020-04-17 13:11:27 -07:00
vaibhavrajsingh2001 f0c5b1a8d7 design: Use CSS instead of disabled property for non-editable text.
The disabled property actually prevented text selection, so it seems
better to use CSS through the `readonly="readonly"` property.
For this, swapped .prop() with .attr() since .prop() was setting it as
`readonly=""`.
2020-04-17 08:36:21 -07:00
Hashir Sarwar ee0d4541b4 topic_data: Rename `topic_data` module to `stream_topic_history`.
`stream_topic_history` is a more appropriate name as this
module will contain information about last message of a
stream in upcoming commits. Function and variable names
are changed accordingly like:

* topic_history() -> per_stream_history()
* get_recent_names() -> get_recent_topic_names()
* name -> topic_name
2020-04-16 20:11:04 -07:00
Vishnu KS c5eddcb1ca upload: Don't hide upload status if there are errors. 2020-04-16 20:09:19 -07:00
Vishnu KS c06d29d0aa upload: Don't add remaining files if adding a file fails.
If a file cannot be added for upload because of restrictions in frontend
we call cancelAll immediately in 'info-visible' callback. This would
prevent files that are already added to be cancelled but does not cancel
files that are yet to be added. So we use break to prevent any more files
from being added.
2020-04-16 20:09:19 -07:00
Vishnu KS 2f2c384c88 uploads: Don't call cancelAll when upload_files is called with no files.
Existing uploads should not be cancelled if upload_files
is called without any files.
2020-04-16 20:09:19 -07:00
Vishnu KS fc086b7521 uploads: Don't call cancelAll on 'complete' event.
Calling uppy.cancelAll() when a batch of uploads is completed
result in the cancelation of any other batch of uploads that is
in progress. This case happens when a user uploads some files
and then tries to upload another bunch of files before the existing
upload is completed.
2020-04-16 20:09:19 -07:00
Abhishek-Balaji 52e0063deb alert settings: Move alert word form on top and sort alert words.
The form for entering alert words has been moved above the list
of words.
The list of words will be presented alphabetically rather than
time of addition.
2020-04-15 17:56:14 -07:00
Abhishek-Balaji 255fe13151 alert settings: Include the actual alert word in the success message.
The message now says 'Alert word "foo" added successfully!' when
you add "foo" as an alert word.
2020-04-15 17:56:14 -07:00
Kartik Srivastava a060691389 default streams: Change add api to use stream_id.
This refactors add_default_stream in zerver/views/streams.py to
take in stream_id as parameter instead of stream_name.

Minor changes have been made to test_subs.py and settings_streams.js
accordingly.
2020-04-15 15:47:04 -07:00
Jagan 8ae34eaa12 settings UI: Make the settings avatar delete/edit UI slicker.
Added UI support for uploding the new profile picture by
clicking on the avatar rather than a button.
Added new spinner for loading indication while uploading
a new avatar over the avatar area.
Fixes #10255
2020-04-15 15:15:57 -07:00
Steve Howell aa5ffcbd2e admin user: Sort bot owners by name.
The original commit here was sorting bot owners by
id, which is of course meaningless to users:

    444ce74a8e

It was also returning 1/-1 in cases where the bot
owner on both sides of a comparison were missing,
which is a big no-no for sorting algorithms.
2020-04-15 15:13:26 -07:00
Steve Howell 0b71b092b3 admin users: Fix email sort.
The email sort now works correctly for admins in
realms with hidden emails.  (We want to sort on
delivery email.)
2020-04-15 15:13:26 -07:00
Steve Howell cf741e9a11 list_render: Add replace_list_data().
The data() function was used in only one place,
and it can be replaced now with two simple
lines of code.
2020-04-15 15:13:26 -07:00
Steve Howell d406df75b3 list_render: Remove support for jQuery items.
All of our widgets now use templates to turn
items into HTML strings, so we can simplify
the code.
2020-04-15 15:13:26 -07:00
Steve Howell c9d0c6852e admin users: Use plain HTML and static dates.
We want to avoid creating jQuery objects that just
get turned right back into strings by the list
widget, so we now have our template just include
`last_active_date` instead of kludging it in
after the fact, and we return the template
string in `modifier` rather than wrapping it.

To deal with plain HTML we switch to using
`render_now`.

Calling `render_now` leads to a more simple
codepath than `render_date`, beyond just dealing
with text.

The `render_date` function has special-case logic
that only applies to our time dividers in our
message view, which is why we were passing the
strange `undefined` parameter to it before this
fix.

The `render_date` function was also putting
the dates into `update_list` for once-a-day
updates, which is overkill for an admin screen.
We don't use this logic for drafts or attachments
either.  I'm not sure how well tested that logic
is, and it's prone to slow leaks.

This commit sets us up to simplify the list
widget not to have bit-rot-prone code related
to jQuery objects.
2020-04-15 15:13:26 -07:00
sahil839 0d2d7d31e2 admin users: Simplify logic for last active date.
We now:

    - Skip the broken "Never" case.  (The way
      we were distinguishing "Unknown" from
      "Never" was based on brittle checks that
      were just wrong due to bitrot--see Steve
      Shank on czo as an example.  If we want
      to make this distinction rigorous in the
      future, we should have a clear mechanism.
      If somebody's never actually been active,
      we probably want to treat that more like
      a dead-on-arrival login, anyway, and make
      it easy to clean them up.)

    - Use the `presence.last_active_date` instead
      of reaching into private data structures.

    - Avoid the unnecessary intermediate constants
      of LAST_ACTIVE_NEVER and LAST_ACTIVE_UNKOWN.

    - Avoid setting `last_active` in `populate_users`.

This commit was modified by @showell:

    - I cleaned up the commit message.

    - I simplified the diff a bit to avoid
      some renaming and lexical moves.
2020-04-15 15:13:26 -07:00
Steve Howell fad4ad1c7f default streams: Streamline list in settings.
There is no need to wrap these rows in jQuery,
when the list widget is fine with concatenating
strings.
2020-04-15 15:13:26 -07:00
Steve Howell 19cf6d0e04 list_render: Remove data-list-render markup.
We already know which list widget a `<th>`
tag is associated with when we set up the
event handler, so it's silly to read data
from the DOM to find that widget again
when the handler runs.

This commit eliminates a whole class of possible
errors and busy work.
2020-04-15 15:13:26 -07:00
Steve Howell 37eeb90695 list_render: Clean up create/update.
For some widgets we now avoid duplicate redraw
events from this old pattern:

    widget = list_render.create(..., {
    }).init();
    widget.sort(...);

The above code was wasteful and possibly
flicker-y due to the fact that `init` and
`sort` both render.

Now we do this:

    widget = list_render.create(..., {
        init_sort: [...],
    });

For other widgets we just clean up the need
to call `init()` right after `create()`.

We also allow widgets to pass in `sort_fields`
during initialization (since you may want to
have `init_sort` use a custom sort before the
first render.)

Finally, we make the second and third calls
eliminate the prior updates from the previous
widget.  This can prevent strange bugs with
double-reversing columns (although that's
been prevented in a better way with a recent
commit), as well as avoiding double work
with sorting.
2020-04-15 15:13:26 -07:00
Steve Howell 0ff62fc6a2 list_render: Use namespaces for events. 2020-04-15 15:13:26 -07:00
Steve Howell eb1344c41c list_render: Fix filtering/sorting.
This code has always been kind of convoluted
and buggy, starting with the first
sorting-related commit, which put filtering
before sorting for some reason:

    3706e2c6ba

This should fix bugs like the fact that
changing filter text would not respect
reversed sorts.

Now the scheme is simple:

    - external UI actions set `meta` values like
      filter_value, reverse_mode, and
      sorting_function, as needed, through
      simple setters

    - use `hard_redraw` to do a redraw and
      trigger external actions

    - all filtering/sorting/reverse logic on
      the *data* happens in a single, simple
      function called `filter_and_sort`
2020-04-15 15:13:26 -07:00
Steve Howell ec854f4b12 list_render: Remove opts.filter.event logic.
We don't use this anywhere.  You can do
`git grep -A 40 list_render.create` to verify
this (with a little bit of noise in the grep).

A better strategy for generalizing
this code is to extract the useful logic
into a function that callers can use in their
own custom event handlers, which I'll do
in an upcoming commit.
2020-04-15 15:13:26 -07:00
Steve Howell 3aef11dc0e list_render: Extract get_list_scrolling_container().
We put this in `scroll_util` to make it more likely
we will eventually unify this with other scrolling
logic.  (A big piece to move is ui.get_scroll_element,
but that's for another PR.)

And then the other tactical advantage is that we get
100% line coverage on it.

I changed the warning to an error, since I don't
think we ever expect scrolling at the `body` level,
and I don't bother with the preview node.
2020-04-15 15:13:26 -07:00
Steve Howell 839a817d0e linkifier settings: Simplify default sort.
In 3d7b9a1349 we
removed the `reverse` operation from `sort`, so
this code had bit-rotted, and it's simpler to
just sort by pattern.
2020-04-15 15:13:26 -07:00
Rohitt Vashishtha cb85763c78 settings: Extract DropdownListWidget from default_code_language_widget.
We extract a general purpose widget to create dropdown lists with
search. This widget is used for default code block language, but can
be easily extended to cover notifications_stream and similar options.
The current usage is:

```js
const widget = DropdownListWidget({
    setting_name: 'realm_alpha_beta',
    data: [{name: 'hello', value: 'world'}, {...}, ...],
    subsection: 'msg-editing',
    default_text: 'Nothing is selected',
});
```

and

```handlebars
{{> dropdown_list_widget
  setting_name="realm_alpha_beta"
  list_placeholder=(t 'Filter the data')
  reset_button_text=(t '[Unset]')
  label=admin_settings_label.realm_alpha_beta }}
```

This can further be refined by shifting more variables from handlebars
to javascript in the future.
2020-04-14 12:50:10 -07:00
Rohitt Vashishtha 546c6f99a7 settings: Extract some helper functions from build_page.
By taking these functions out of exports.build_page, we can
reuse them for handling other widgets. We also declare
default_code_language_widget after the helper functions to
avoid the linter complaining.
2020-04-14 12:50:10 -07:00
Steve Howell 4e11e7ee5b Revert "list_render: Clean up initialization."
I pushed this risk commit to the end of
a PR that had a bunch of harmless prep
commits at the front, and I didn't make
it clear enough that the last commit (this
one) hadn't been tested thoroughly.

For the list_render widget, we can simplify
the intialization pretty easily (avoid
extra sorts, for example), but the cache aspects
are still tricky on subsequent calls.
2020-04-13 06:22:28 -04:00
Ankita Bansal 2b179143a8 static/js: Fix custom numeric emojis not working in reactions.
Changes .data() Jquery methods to .attr() to prevent unnecessary data
type conversions of the emoji name.

Tested the fix manually and verified the test-js-with-node test suite.

Fixes: #14377
2020-04-12 15:02:56 -07:00
Steve Howell 0681e4ba36 list_render: Clean up initialization.
For some widgets we now avoid duplicate redraw
events from this old pattern:

    widget = list_render.create(..., {
    }).init();
    widget.sort(...);

The above code was wasteful and possibly
flicker-y due to the fact that `init` and
`sort` both render.

Now we do this:

    widget = list_render.create(..., {
        init_sort: [...],
    });

For other widgets we just clean up the need
to call `init()` right after `create()`.

We also allow widgets to pass in `sort_fields`
during initialization (since you may want to
have `init_sort` use a custom sort before the
first render.)
2020-04-12 14:59:32 -07:00
Steve Howell ef749dba31 invite settings: Avoid list_render.get() call.
The get() logic here was broken, because
when you enter the settings panel for invites
on the 2nd or 3rd time, the text filter
would not work.

This commit doesn't intend to fix the problem; it
just simplifies the code for a later commit
that fixes this holistically.

The way that we update `list_render` objects
is janky with respect to events, so we can end
up double-sorting lists (which puts them back
to normal) and strange things like that.
2020-04-12 14:59:32 -07:00
Steve Howell 2b07512d22 list_render test: Split out scrolling/filtering.
We split one test into two simpler ones, and we
no longer bother with the load_count override,
which was only used in tests.
2020-04-12 14:59:32 -07:00
Steve Howell ced5511cdd list_render: Rename __set_events().
I rename it to set_up_event_handlers.

This commit does not attempt to fix any buggy
behavior with how we set up event handlers; it's
purely cosmetic.
2020-04-12 14:59:32 -07:00
Steve Howell 42c2e9c429 list_render: Dedent 200+ lines of code.
This is all cosmetic.

Instead of:

    const.widget = {
        foo: function () = {
        },

        bar: function () {
        },
    };

We have:

    const widget = {};

    widget.foo = function () = {
    };

    widget.bar = function () {
    };
2020-04-12 14:59:32 -07:00
Steve Howell 29b22da1ff list_render: Rename prototype to widget. 2020-04-12 14:59:32 -07:00
Steve Howell 22c8a7ccef invite settings: Fix sorting with multi-user links.
Before this fix, we'd get a traceback if you looked
at invites in the settings (and if one of them was
a multi-user invite link).  This commit fixes
that problem by adding a custom sort.

We also rename the "Email" column to "Invitee",
since it's often the case the invitee isn't an
actually an email, but it's instead a multi-use
link.

Note that the invites UI only works the first time you
enter settings.  Many of the controls break the second
time you enter it.  You can't sort by column header
or use the text filter.

I'll fix that in a subsequent commit.
2020-04-12 14:59:32 -07:00
Steve Howell a06d455228 settings: Extract sort helpers for various lists.
Giving these functions a name and moving them to
the top-level scope has a couple tactical advantages:

    - names show in tracebacks
    - code is less indented
    - setup code is less cluttered
    - will be easier to add unit tests
    - will make some upcoming diffs nicer

These are technically more `compare_foo` than `sort_foo`,
but we already had a naming convention that was sort of
in place.
2020-04-12 14:59:32 -07:00
Steve Howell 888214196c unread: Handle message edits that affect mentions.
We had a bug where if your peer mentioned you in
message, but then edited the message not to mention
you, the latter wouldn't reset your unread counts
for "Mentions".  And the same problem would happen
vice versa.

The fix basically extracts `update_message_for_mention`
and makes sure it handles all combinations of
unread/mentioned flags, instead of assuming
any invariants about which directions of change
are possible.

And then we call that new function from
`message_events.js` whenever we get message
edit events.

Fixes #14544
2020-04-11 12:00:46 -07:00
Anders Kaseorg 99242138a7 static: Serve webpack bundles from the root domain.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 00:48:02 -07:00
Vaibhav Raj Singh ca5ea44123 design: Make non-editable text-box more distinguishable.
Earlier, the non-editable text-boxes(on clicking view source/edit
topic) were not so apparent due to absence of `disabled` attribute.
Adding the `disabled` attribute makes them consistent with the approach
for non-editable text-boxes and text-areas in organization settings
(for non-admins).

Fixes: #14375
2020-04-09 16:45:17 -07:00
Steve Howell 4eb1987c39 transmit: Inline send_message_ajax.
The `send_message_ajax` function was a relic
of us having an alternative way to send messages
(web sockets) to the server, but now the indirection
is more confusing than helpful.
2020-04-09 16:11:57 -07:00
Steve Howell 80489843ee message store: Report type confusion errors.
We also complain if the caller sends us
`undefined`.
2020-04-09 16:11:57 -07:00
Steve Howell 5d58590f14 local echo: Fix resending of local messages.
This also fixes trying to cancel a resend of a
local message.

The problem were was type confusion between
strings and ints.

The function in `rows.js` may feel like overkill,
but I really want to enforce type safety here,
as we usually treat message ids as floats, but
for the local-echo case we're gonna get
strings.  I put it in `rows` because we mostly
do a good job of encapsulating the "zid" role
in the DOM there.

By going directly to the DOM here, we avoid
parsing a string to a float and then converting
it right back to a string, which always make
me queasy about float rounding, so one less
moving part.
2020-04-09 16:11:57 -07:00
Steve Howell 082a2f9c2e local echo: Avoid waiting_for_ack leak.
Due to type confusion, we were silently failing
to delete local_id values for messages that were
being acked by the server.

This used to work when we kept values in our
old Dict data structure, since client_message.id
and message.local_id are really the same value,
just the former is a float and the latter's a
string, and Dict never cared.

We can avoid all this confusion, though, by just
consistently using `local_id`, which I extract
to a local var.
2020-04-09 16:11:57 -07:00
Steve Howell 9fa4ec56bb local echo: Fix type errors for message_send_error.
The function message_send_error was messing up
on calls to message.get when we were passing in
string versions of `local_id`.  Now we pass in
float ids.

This fixes a traceback where we tried to set
`.failed_request` on to an `undefined` value
that we had instead expected to be a locally
echoed message from our message store.
2020-04-09 16:11:57 -07:00
Steve Howell f4f403decb refactor: Have try_deliver_locally() return a message.
This will allow us access to the float version of the
message's id in an upcoming commit, without us having
to do possibly brittle string-to-float translations.
2020-04-09 16:11:57 -07:00
Steve Howell dccbb25a49 minor: Fix duplicate function names in echo.js. 2020-04-09 16:11:57 -07:00
sahil839 65d953b2af settings: Add option to disable video call in org settings.
Option is added to video_chat_provider settings for disabling
video calls.

Video call icon is hidden in two cases-
1. video_chat_provider is set to disabled.
2. video_chat_provider is set to Jitsi and settings.JITSI_SERVER_URL
   is none.

Relevant tests are added and modified.

Fixes #14483
2020-04-09 16:03:30 -07:00
Rohitt Vashishtha f9caf522f0 markdown: Allow setting a default language for code blocks.
This adds a new realm setting: default_code_block_language.

This PR also adds a new widget to specify a language, which
behaves somewhat differently from other widgets of the same
kind; instead of exposing methods to the whole module, we
just create a single IIFE that handles all the interactions
with the DOM for the widget.

We also move the code for remapping languages to format_code
function since we want to preserve the original language to
decide if we override it using default_code_clock_language.

Fixes #14404.
2020-04-09 16:02:02 -07:00
Pranav 326b0e0378 linkifiers: Allow non-admins to filter linkifiers in settings.
The filter-linkifier input box was disabled which prevented users from
filtering through the linkifiers list. Removed the part of code which
caused the input box to be disabled. This allows users to edit the input
and so filter linkifiers.
2020-04-09 15:55:47 -07:00
Tim Abbott 0e57975643 settings: Fix downloading zuliprc files with hidden emails.
With EMAIL_ADDRESS_VISIBILITY_NOBODY (or as a non-admin with
EMAIL_ADDRESS_VISIBILITY_HIDDEN), we were incorrectly generating
zuliprc files containing the shareable email address, which naturally
didn't work.
2020-04-09 13:24:52 -07:00
Vishnu KS a3164a3316 upload: Set the value of file input element to empty after upload.
Otherwise, if a user tries to upload the same file again the on change
event handler would not be called since there is no change in the value.
2020-04-09 12:38:59 -07:00
Tim Abbott c4589718fc settings: Move emoji widget code to settings_emoji.js.
It's the only bit of settings UI specific code that had ended up in
emoji.js.
2020-04-08 14:43:20 -07:00
Tim Abbott fdd47e8560 settings: Don't clear the uploaded file on failure.
Most failures result from invalid emoji names, so this makes it easier
to recover without re-uploading a file.

Previously, this model would have been problematic, but now that we
have the visual preview, this is clearly better behavior.
2020-04-08 14:43:20 -07:00
Abhishek-Balaji 852576db97 settings: Add preview while uploading custom emoji.
This adds a preview of the uploaded emoji image while uploading custom
emoji right below the upload form.

Modified upload_widget.build_widget() to take in the preview
span text and image. In case a parameter isn't passed
for preview text, it defaults to null and the snippets in
build_widgets() related to preview don't run.

Fixes #9229.

Styling tweaked by tabbott.
2020-04-08 14:42:46 -07:00