Commit Graph

6531 Commits

Author SHA1 Message Date
sahil839 da4f80caaa subs: Update hash when unsubscribing from stream settings UI.
Previously, the unsubscribe logic just called
exports.show_subs_pane.nothing_selected() if one had been viewing the
edit UI for a stream that the user just unsubscribed from, which
clears the selection, but didn't update the hash or do other cleanup
logic.

We should instead be calling stream_edit.open_edit_panel_empty(),
which is the appropriate function for this purpose (and has
exports.show_subs_pane.nothing_selected as a subroutine).
2020-06-01 15:38:25 -07:00
sahil9001 328caf1ad5 api: Simplify format of realm_emoji author data.
There's no reason to send data beyond the user `id` of the uploader,
and reason not to, as the previous model was both awkward when
`author=None` and resulted in unecessary parsing complexity for
clients.

Modified by tabbott to add the frontend changes and API documentation.

Fixes #15115.
2020-05-31 17:44:50 -07:00
sahil839 2ab6767b73 events: Update person dict in event for do_change_user_role to send role.
This commit changes the person dict in event sent by do_change_user_role
to send role instead of is_admin or is_guest.

This makes things much more straightforward for our upcoming primary
owners feature.
2020-05-31 17:22:50 -07:00
Clara Dantas 080014abcc settings_users: Fix bot_list_widget not defined.
Fix error thrown when creating a bot if the bot_list_widget
is not defined.
2020-05-30 12:23:49 -07:00
sahil839 9fa60672e6 users: Modify update user API endpoint to accept role as parameter.
This commit changes the update user API endpoint to accept role
as parameter instead of the bool parameters is_guest and is_admin.

User role dropdown in user info modal is also modified to use
"dropdown_options_widget".

Modified by tabbott to document the API change.
2020-05-29 14:29:17 -07:00
Steve Howell 74c61984df Revert "buddy list: Adjust sizing calc for narrow mode."
This reverts commit 9f5725d265.

I was trying to fix how we size the buddy list in
narrow mode, which was off by 10px, but my fix worsened
things for regular mode.

Also, somebody reported a traceback related to my fix.
I didn't fully research the traceback,
but I suspect it was related to some media-query settings
for small screens or due to a put-buddy-list-in-left-pane
setting.  (Basically, `$('#right-sidebar').position()` may
be undefined in some cases, and I wasn't handling that.)

After reverting this, we still have the original
off-by-10px bug that I was trying to fix, but I will
attempt to do that more cleanly in a separate commit.

This should make it so that in normal situations where
the buddy list is in the right sidebar, we will be
able to see the "Invite more users" link again.

I am still a little puzzled how I didn't catch this in
testing, but it was toward the end of a long PR, so
it could easily just be simple human error.

Fortunally, this regression was only on master for a
couple days, and users could still invite users via
the gear menu.
2020-05-29 15:36:42 -04:00
Mateusz Mandera 88d501515e presence: Fix "Last active:" in buddy list when last presence is idle.
Restored old behavior accidentally removed in
1ae07b93d8 (diff-e353fab8bea58b8746ec68c83aa39b36L48)

The server only remembers the most recent presence status update per
device. Meaning that, for instance, if the user only uses one client and
that client's last status update was IDLE, then the server only knows
that, doesn't know anything about the user's last ACTIVE time. Thus the
"active_timestamp" the server will serve about this user to the webapp
will be "undefined".
The old behavior was that for the sake of the "Last active: x ago"
status in buddy list popover, the latest status timestamp was used,
whether IDLE or ACTIVE.
The change linked about changed that to only pay attention to
ACTIVE. Thus, if the server doesn't remember any ACTIVE statuses, webapp
would show "Last active: More than 2 weeks ago", which was incorrect.

We restore the old behavior and further improvements can be made on top
of this.
2020-05-29 13:26:34 -04:00
Rohitt Vashishtha fba2708bbc settings_bots: Explicitly ignore delete event from live updates. 2020-05-28 17:10:51 -04:00
Rohitt Vashishtha 58b612a4f0 settings-users: Rerender bot rows on data change.
Previously, we fiddled with the existing HTML to update the
state. Now, we can use list_render.render_item() to render
the complete item properly.
2020-05-28 17:10:51 -04:00
Rohitt Vashishtha a114b6a1b1 list-render: Allow re-rendering individual list items.
Previously, we had to fiddle with the generated HTML to update
individual values. Now, we can simply ask the widget to rerender
the row that we updated.

This is done by passing an html_selector function that returns
a selector for the rendered item.

If:
  - we do not provide html_selector function
  - item is not currently rendered
  - new html is not a string.
then the render_item() call is a noop.
2020-05-28 17:10:51 -04:00
Rohitt Vashishtha 2cfead7601 list_render: Add validate_opts function.
We do not shift much of the validation logic here just
yet. This function has been declared at the top of the
file to act as usage docs for the widget as well, in
terms of what combinations of opts are valid and what
are not.
2020-05-28 17:10:51 -04:00
Steve Howell 43e5b2d28b right sidebar: Remove "GROUP PMs" section.
We remove the "GROUP PMs" section that used
to be in the lower right sidebar.

Most of this is straightforward code removal.

A couple quick notes:

    - The message fetching code now just
      calls `huddle_data.process_loaded_messages`,
      which we still need for search suggestions.
      We removed `activity.process_loaded_messages`.

    - The `huddle_data.process_loaded_messages`
      function no longer needs to return `need_resize`.

    - In `resize.js` we now just calculate
      `res.buddy_list_wrapper_max_height` directly
      from `usable_height`.
2020-05-27 17:57:50 -07:00
Steve Howell 9f5725d265 buddy list: Adjust sizing calc for narrow mode.
This fixes the calculation for how far from the
top of the viewport we think #right_sidebar's
top is.  To fully explain this commit requires
some background info.

Normally `#right-sidebar` has 50px of top margin
and 0px of top padding.  And our `resize.js`
calculations have been accurate for the normal
case.

But when you are in the so-called `.expanded` mode
(i.e. when you're in a narrow window) we split up the
50px as follows:

    - 40px margin
    - 10px padding

Why don't I make the CSS just be more consistent here?

    - If you go to 50px in the "expanded" mode
      you mostly cover up the right scrollbar,
      except for the 10px gutter that is below
      the 40px-tall `.header` section.  To fully
      cover it we apparently want the padding;
      otherwise you see a small, unusable remnant
      of the scrollbar which just looks funny.

    - If we were to make the "regular" right sidebar
      just always have the 40/10 split, then we
      would start to diverge from the left sidebar,
      which is currently 50/0 as well.

    - If we went to make both the left and the right
      sidebars 40/10 split, well, that's just an
      even riskier change.

So instead I fix the resize calculation:

    I just calculate the actual `top` position.

Is any of this actually user-facing?

    Yes.  Now if a user is a narrow window and
    they open the buddy list, we will make
    the buddy list 10px smaller to account for
    the padding. This makes it less likely for
    the invite link to get squeezed out.
2020-05-27 17:57:50 -07:00
Steve Howell 87c36cdb26 resize: Resize sidebars when toggling user search.
It's possible we want to do the same for the stream
search, but this PR is highly focused on the buddy
list and GROUP PMs widget.
2020-05-27 17:57:50 -07:00
Steve Howell 7ed47e83fe resize: Extract resize_sidebars().
We'll use this in the next commit.

Note that there's a minor change in the order
in which we apply new heights--we now
do sidebars before bottom whitespace.
2020-05-27 17:57:50 -07:00
Steve Howell 9489960b73 dead code: Remove useless resize calls.
We had a bunch of places where we
were calling `resize.resize_bottom_whitespace`
with no arguments, which has been a no-op
since the below commit that removed support
for our `autoscroll_forever` option:

    fa44d2ea69

With the `autoscroll_forever` options things
like opening/closing the compose box could
alter how much bottom whitespace you'd want,
but we stopped supporting that feature in
2017.

Since then bottom_whitespace has just always
been 40% of the viewport size.  So we only need
to change it on actual resize events.

It's worth noting that we still call
`resize_bottom_whitespace` indirectly in many
places, via `resize_page_components`, and
the latter actually causes
`resize_bottom_whitespace` to do real work,
but that work is redundant for most of those
codepaths, since they're not triggered by
changes to the viewport.  So there are other
opportunities for cleanup.
2020-05-27 17:57:50 -07:00
Steve Howell ac3de453fb resize: Remove dead code.
The `buddy_list_wrapper` has zeros margins, so it's
just noise in the current calculations.  You can
verify this pretty easily with console statements,
as well as looking at the code.  I tried it with
various permutations of narrow windows and display
settings.
2020-05-27 17:57:50 -07:00
Steve Howell fefcaad027 resize: Avoid hard-coding 10px for header padding. 2020-05-27 17:57:50 -07:00
jagansivam28 12fd515831 settings org: Trigger realm icon upload by clicking on realm icon element.
Trigger realm icon upload by clicking on realm icon element itself
rather than having a big upload button and to match our user avatar UI.
Added new spinner over the icon element itself to show while
uploading realm icon.
2020-05-27 17:15:14 -07:00
jagansivam28 0c70365034 settings org: Replace realm icon delete button with X icon.
Replacing delete button for `realm icon` with "X" icon in the
right corner of the icon image to match "user profile" avatar UI.
2020-05-27 17:15:14 -07:00
Tim Abbott d4dfeb57fd lint: Add i18n linter rule for invalid i18n.t tags.
After seeing yet another contributor accidentally try to add i18n tags
that don't work using this pattern, it's time for a lint rule.
2020-05-27 14:09:56 -07:00
Anders Kaseorg 62fcf98b6f js: Use hasOwnProperty correctly or not at all.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Anders Kaseorg 080abf4a1e emoji: Abstract all name_to_codepoint, codepoint_to_name accesses.
Computed indexes into these raw objects should be guarded with
Object.prototype.hasOwnProperty; make our accessors do this
automatically and use them consistently.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Anders Kaseorg e5e1a05e74 stream_data: Convert orders from object to Map.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Anders Kaseorg e6dd1911c7 rows: Convert valid_table_names from object to Set.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Anders Kaseorg 0ad8fff35d lightbox_canvas: Clear canvas with less obfuscation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Ryan Rehman a7aae94e64 navbar: Update searchbox event listeners behaviour.
These are some UI and UX changes mainly related for when to
display the search pills and when to dispay the narrow description
in the search bar.
2020-05-26 22:04:36 -07:00
Ryan Rehman c4e59309e4 navbar: Refactor `#searchbox`.
Along with various style fixes for the search pills
enabled case, this de-duplicates the css.
2020-05-26 22:04:36 -07:00
Ryan Rehman 4cdd7aed2b css: Narrow the gap between searchbox and searchbox_legacy.
This is a prep commit which combines the previous `#searchbox`
block with the newly updated `#searchbox_legacy` block which
contains the modifications related to the new navbar display.

This only consists of changes to `#searchbox` and is still broken.
But it integrates the searchbox with the new tab_bar changes so that
only one searchbox is shown (instead of two, previously).
2020-05-26 22:04:36 -07:00
Ryan Rehman e2417b5b37 search: Don't create search pills on paste.
This is helpful because if the user pastes multiple queries in the
searchbox and there are invalid search operators, then it is visible
through the typeahead.
2020-05-26 22:04:36 -07:00
Ryan Rehman 02ab48a61e search: Simplify `narrow_or_search_for_term` code path.
The main reasoning for this change is as follows:

    * When the search bar contains multiple search queries
        but no search results, the last search operand does
        not get displayed.

        This happens due to the fact that filter object
        contained 2 terms having the operator key value as
        "search" instead of a single term where operator is
        "search" and operand is a single string containing
        the space seperated search queries. This condition
        occurs for search_pills_enabled case only because
        we used to Filter.parse the query twice
        (once for the `base_operators` and once for the
        `suggestion_operator instead of doing both at once).

        Thus the `search_query` value inside the
        `narrow.show_search_query` function which only
        selected the operands of the first term displayed
        an incomplete result.

    * Another benefit of this commit is to display the narrow
        operators in the URL fragment the same way as when
        search_pills_enabled = False.

        For example, On entering the queries in the mentioned
        order -> 'is: starred', 'abc', 'def', 'is: private',
        'ghi'. This is the URL:

        Previously:
        /#narrow/is/starred/is/private/search/abc.20def/search/ghi

        Now (same as pills disabled case):
        /#narrow/is/starred/is/private/search/abc.20def.20ghi

    * We are also able to de-duplicate the non-typeahead search
        query code path.
2020-05-26 22:04:36 -07:00
Ryan Rehman d3f2bbc4bb input pills: Delete char instead of pill for backspace.
As mentioned in the comment for `KEY.BACKSPACE` event
in `input_pills.js`, we do normal character deletion
if there is input present. However this wasn't the case
if spaces were present. Also the input wasn't cleared
after the last pill was removed.

Thus `trim()` is removed from the input length check and
the new pill is still created from the trimmed value.
2020-05-26 22:04:36 -07:00
Ryan Rehman 9e221977c4 search pills: Narrow when typeahead is not used.
We can remove the typeahead by clicking outside the search box
after we have entered the search string to be filtered and then
focus on the searchbox  and press enter or just by pressing enter
on an empty string.

Previously, the narrow would just deactivate for the above condition
as the searchbox value which was passed as the raw_operators parameter
to the narrow.activate function was empty.
This happened because we called the activate function on pressing
enter for the keyup event, while the keydown event in the parent
container made a pill from the text and cleared the input. (as
mentioned in the comment for `KEY.ENTER` case in `input_pill.js`)
2020-05-26 22:04:36 -07:00
clarammdantas de00c3cd6a people.js: Add non_active_user_dict bucket. 2020-05-26 21:41:54 -07:00
clarammdantas aae7c79c00 people.js: Rename add() to add_active_user(). 2020-05-26 21:41:54 -07:00
clarammdantas c90c8c0b19 people.js: Create new add_cross_realm_user function.
The people.js tests were using _add_user function to add
cross realm bots. The problem is that _add_user function
doesn't properly simulates the adding process as it doesn't
add the user in cross_realm_dict as well.

To solve this and eliminate the need of calling
people.initialize(), which means the params obj needs to be
defined, we extracted the whole logic of adding a cross realm
user into a separete function, add_cross_realm_user.
2020-05-26 21:41:54 -07:00
Steve Howell e040721090 refactor: Extract huddle_data.js.
This makes it so that search_suggestion.js
does not depend on activity.js.

That dependency hasn't really been "elegant"
for quite some time, but it will become particularly
unnecessary when we go to remove the "Group PMs"
section from the right sidebar.

This commit introduces a temporary wart
where we have these two functions with the
same name in a sort of unnecessarily
complicated code stack:

    activity.process_loaded_messages
    huddle_data.process_loaded_messages

But we will eliminate the former function
very soon, and our message-related codepaths
will just call the `huddle_data` version
directly.

TESTING NOTES:

Now that `huddle_data` is a tiny leaf
module, it's super easy to just use the
real implementation of what was formerly
called `activity.get_huddles()` (and is
now in `huddle_data`).

When I first wrote this commit, introducing
the real implementation of `get_huddles` exposed
some bugs that I fixed in the immediately
prior commits to this.

When the tests were originally written,
I believe `activity.js` had some annoying
`jQuery` dependencies that made it hard
to unit test against.  We've slimmed it over
time to be mostly just a "controller" module.
But even in its current state it would have
been a bit of a bloated dependency.

The other friction for using the actual
version of `get_huddles` was setting up
the message data, but that's pretty minor.
2020-05-26 21:26:11 -07:00
Steve Howell ede709f75c bug fix: Fix sorting for group-pm edge cases.
If you have a group PM where some users have
three-digit user_ids and some with four-digit
user_ids (or similar), a huddle could effectively
be ignored when determining the order of
search search suggestions.

Basically, we need a way to canonically sort
user_ids in "huddle" strings, and it's somewhat
arbitrary whether you sort lexically or sort
numerically, but you do need to be consistent
about it.

And JS is not exactly helpful here:

    > [99, 101].sort()
    [ 101, 99 ]

This is a pretty obscure bug with pretty low
user-facing consequences, and it was never
reported to us as far as I know, but the fix
here is pretty straightforward.

We have had similar bugs of slightly more consequence
in the past.  The reason this bug has shown
up multiple times in our codebase is that every
component that deals with huddles has slightly
different forces that determine how it wants
to serialize the huddle.  It's just one of those
annoying things.  Plus, bugs with group PMs
do tend to escape detection, since most people
spend most of their time either on streams
or in 1:1 PMs.
2020-05-26 21:26:11 -07:00
Steve Howell 4803a12416 search: Extract people.huddle_concat().
This is a pure code extraction.  The current
code is buggy with respect to user_ids with
different lengths of digits, i.e. it does
a naive lexical sort instead of a numerical
sort.  We'll fix that in the next commit.
2020-05-26 21:26:11 -07:00
Vishnu KS 8784539d53 free trial: Send users to /upgrade after realm creation. 2020-05-26 17:01:32 -07:00
Ryan Rehman 77a26d41ae message view: Show indicator while fetching new messages.
We already have a loading indicator for fetching older
messages. Thus it makes sense to implement the same
for displaying newer messages.

We set the display of `bottom-messages-logo` to none,
to prevent displaying two loading indicators during
the initial message load.

Fixes #15060.
2020-05-26 15:21:42 -07:00
Ryan Rehman 9c733b42df minor: Rename loading_more_messages_indicator.
`loading_more_messages_indicator` is renamed to
`loading_older_messages_indicator`.

This is a prep commit to introduce
`loading_newer_messages_indicator`.
2020-05-26 15:21:42 -07:00
YashRE42 669f482b0d icons: Switch from text-o to code-o for view source / edit topics.
This commit replaces fa-file-text-o with fa-file-code-o which is a
better signal for the "view source" action. It also deletes a single
line comment that had suggested the change once we moved into font
awesome 4, which Aditya Bansal <adi.bansal241996@gmail.com> helped
out in doing, first via
91962aa6ab and most recently via
75ae94e459 with several commits in
between.
2020-05-25 16:19:50 -07:00
sahil839 2af4ef6c6d message_events: Fix live update of message edit history.
This commit adds code to live update the message edit history.
Message edit history is fetched and rendered again if the edit
history modal is open.

This also adds 'data-message-id' attribute to 'message-history'
when opening history modal element which is used for checking
whether the history modal opened is of the message which is
edited.

Fixes #15051.
2020-05-25 15:51:01 -07:00
Sanskar Bajpai 3aa74b67a0 stream_color: Rename the color picker button to confirm.
Tweaked by tabbott to add i18n tags.

Fixes part of #15039.
2020-05-25 15:42:34 -07:00
Pragati Agrawal 55db6ed1e3 stream settings: Fix "Saving" widget for Muted streams.
"Saving" widget was working for all personal stream settings but "Mute
notifications". This was because the change to the "Mute" property follows
a slightly different path.
2020-05-24 16:32:36 -07:00
Tim Abbott 1058c08623 narrow: Fix a typo in the then_select_id comment. 2020-05-21 12:41:55 -07:00
Rohitt Vashishtha 648307ef33 rendered_markdown: Add rendering functions for timestamps.
This code generates the timestamp string to be shown to the user
from the given timestamp in unix format using moment.js.

We also render the timestamp in a pill.
2020-05-21 12:37:37 -07:00
Rohitt Vashishtha 44afcb8d64 rendered_markdown: Add comment explaining the use of this module. 2020-05-21 12:37:34 -07:00
Rohitt Vashishtha bb579742a2 markdown: Move helper function to rendered_markdown.js. 2020-05-21 12:32:52 -07:00