Commit Graph

6524 Commits

Author SHA1 Message Date
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
Rohitt Vashishtha fa9431c0a4 markdown: Extract rendered_markdown.js to update dynamic elements.
Previously, we handled this code only in message_list_view.js.
Now we support rendering stream descriptions and some dynamic
elements can be rendered in them, so we extract this new module
and use it in both the places.
2020-05-21 12:32:52 -07:00
Rohitt Vashishtha 88367a129c markdown: Disable tex and latex for math rendering.
We now parse tex and latex as regular languages, highlighting them
with pygments. We only allow 'math' to trigger latex rendering,
which is in line with the documentation.
2020-05-21 12:30:27 -07:00
Rohitt Vashishtha 52c25a9301 markdown-timestamp: Use data-timestamp attribute.
This commit shifts our timestamp syntax to be of the form:

    <span class="timestamp data-timestamp="123456"></span>

since value is not a valid attribute of span elements.
2020-05-20 14:28:08 -07:00
Rohitt Vashishtha b062e8332f markdown: Add timestamp syntax to markdown processors.
This adds support for syntax like: !time(Jun 7 2017, 6:30 PM) so that
everyone sees the time in their own local timezone. This can be used
when scheduling online meetings, etc.

This adds some hardcoded values for timezones, because of there
being no sureshot way of determining the timezone easily. However,
since the main way of using the feature should be a typeahead for
entering the time, this shouldn't be cause of much concern.

Fixes #5176.
2020-05-20 14:23:55 -07:00
Rohitt Vashishtha 22537602d2 minor: Update comment in feature_flags.
The earlier version of the comment implied that we want to remove
the features and not the flags that hide those features.
2020-05-20 13:51:54 -07:00
Rohitt Vashishtha 1091615b17 edit-bot: Show dropdown list widget for selecting owner.
This commit removes user_dropdown in favor of the common
dropdown_list_widget for our bot edit forms.
2020-05-20 09:51:38 -07:00
Rohitt Vashishtha 4d14ba41ba dropdown-list-widget: Properly handle disabled state.
We wrap the [reset] anchor tag in a button so that we can set 'disabled'
attribute on it. We change the styles to hide the [reset] button and the
pencil icon when the widget is disabled.

We also need to call `e.preventDefault()` in the event handler since now
the anchor tag behaves as a button.
2020-05-20 09:51:38 -07:00