Commit Graph

2969 Commits

Author SHA1 Message Date
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 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
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
Priyank Patel 60fa848aea puppetter: Add a waitForNavigation call before asserting the url.
Since we are doing a assert call checking a url without no page.waitForSelector
or similar calls, we add this to avoid flakes where the assert is called
when we are in process of navigation to the page. Also, we use Promise.all
here, and call page.waitForNavigation first, to avoid race conditions where
form is submitted quickly and navigation occurs and then we are stuck waiting
for a navigation. There were no flakes in the CI related to this issue, but
I expect someone with a slow hardware would probably stumble upto this in future.
2020-05-27 12:53:17 -07:00
Priyank Patel 60c92b69c5 puppeteer: Make the subdomain input field visible before typing into it.
We were missing the step for clicking the checkbox to show the subdomain
input field. There was a flake because of this issue in CI where the
"testsubdomain" input was getting typed into the name field. This fixes
that flake.
2020-05-27 12:53:17 -07:00
Priyank Patel 9d982d3c0e puppeteer: Fix test flake in 01-login.js.
There were two reason there were flakes in login tests. One problem was
that the assert call for checking that the login page url was happening
too early in rare cases. To fix this issue we wait for email input field
element in the login page. The second issue was the sometimes the url was
/login/ instead of /accounts/login/. The time between the redirect were
super close here too (around ~10ms) so I am suprised this didn't occur flake
locally more often.

Server logs that show the redirect:
2020-05-26 18:55:27.065 INFO [zr] 127.0.0.1       GET     200  36ms (db: 5ms/2q) (+start: 14ms) /accounts/login/ (unauth@zulip via ?)
2020-05-26 18:55:27.074 INFO [zr] 127.0.0.1       GET     200  28ms (db: 3ms/2q) (+start: 23ms) /login/ (unauth@zulip via ?)
2020-05-27 12:53:14 -07:00
Priyank Patel 0b698d1173 puppeteer: Take screenshot on failure.
To take a screenshot on failure where we have our common error
handling code in common.run_test method we need to have access to
the Page instance. Currently, we create a new Page in the test method
we pass into run_test, so we pass in a new Page instance to that method
so the test and the run_test method have access to the same Page. And,
then we take a screenshot on failure. It will be saved as `failure-${num}`
in var/puppeteer directory.
2020-05-27 12:50:22 -07:00
Steve Howell 9ce220aca6 buddy_data test: Move huddle_fraction_present test.
This is mostly just moving code from the `activity.js`
tests, but I also now explicitly cover the "100%"
use case (i.e. all four folks in the huddle are present).
2020-05-27 11:02:18 -04: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 aa912ef759 mdiff: Convert formatter, aliases from object to Map.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Anders Kaseorg c440fc714d node_tests: Remove pointless reassignment of ‘dropdown_list_widget’.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 23:33:40 -07:00
Anders Kaseorg 0423e6b7cc zjsunit: Remove pointless reassignment of ‘module’.
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 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
Tim Abbott 5f498f788f node: Fix test failures due to removed zulip-limited-section. 2020-05-26 21:59:27 -07:00
Anders Kaseorg 3c7c163d7f casper_tests: Adjust for the addition of Desdemona.
Commit 9b78a73e36 (#15005) made some of
our poorly written Casper tests fail.  Now they’re just as poorly
written but passing again.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-26 21:49:09 -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 be831e0085 free trial: Hide free trial message during payment processing. 2020-05-26 17:01:32 -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
Steve Howell a3e265f5b8 people tests: Move test users to top of file.
I consolidate most of our users toward the top
of the file, so that we don't have to clutter
up individual tests.  This also avoids some
confusion where charles/maria got repeated
in different tests with different ids.

I also introduce a couple four-digit ids to
try to expose more bugs related to sorting.

Note that it's still easy to keep tests
isolated here, as we have always been able
to cheaply re-initialize `people.js` and then
add individual users back.

There are still some tests where it makes
sense to just declare users locally, especially
if we are mutating their data.

There are a few minor incidental cleanups here,
mostly involving replacing hard coded ids
with things like `maria.user_id`.
2020-05-26 17:21:43 -04:00
Steve Howell ea0810e13f search tests: Create users up front.
This creates a little bit of noise in some
tests where we don't care about users, but
it's worth avoiding confusion about which
users exist at which time.  Also the noisy
aspects here may actually catch regressions.

Finally, if the noise gets annoying, we can
do things like rename "Ted" not to collide
with the "Test" stream.
2020-05-26 10:47:59 -04:00
Steve Howell 0cc5a8e185 search tests: Add a "myself" user.
Using "bob" as the current user was a bad
choice, as our convention is to use "me" or
"myself" or "alice" for the current user.

It also particularly complicated the tests
around Group PMs.

Now we have both "bob" and "myself", which
makes the intentions of the tests a little
more clear.
2020-05-26 10:47:59 -04: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
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 2efe9f7942 rendered_markdown: Add tests for emoji.
This brings test coverage for rendered_markdown to 100%.
2020-05-21 12:37:32 -07:00
Rohitt Vashishtha 0cbb05c5bc rendered_markdown: Add tests for stream-links. 2020-05-21 12:37:30 -07:00
Rohitt Vashishtha 0c260e014a rendered_markdown: Add tests for user-group-mention. 2020-05-21 12:37:26 -07:00
Rohitt Vashishtha 1a454e2137 rendered_markdown: Add tests for user-mention.
We also add a hacky jquery array creator because zjquery doesn't
support $().each() yet.
2020-05-21 12:37:23 -07:00
Rohitt Vashishtha 84b2952606 zjquery: Support empty find results. 2020-05-21 12:32:52 -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 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 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
Aman Agrawal 370d1b6ca7 recent-topics: Handle topic and topic's stream edit updates.
* Implementation and logic similar to recent_sender.process_topic_edit.
2020-05-20 09:44:50 -07:00
Aman Agrawal 04cdc89681 recent_topics: Handle mute/unmute update to topic.
* We don't remove topic data when it's muted. We will filter it
before rendering.
2020-05-20 09:44:50 -07:00
Aman Agrawal 76b0c6de86 recent-topics: Add module.
Add methods to extract recent topics from received messages.
Process new messages as they are received.
Use new messages received from the server to extract recent_topics.
Node tests added.
2020-05-20 09:44:50 -07:00
Priyank Patel b2f566f53e puppeteer: Add screenshot method to common module.
This will be useful for debugging purposes and we'll use it to take
a screenshot on failure.
2020-05-19 15:58:04 -07:00
Priyank Patel 1f367ed537 puppeteer: Rename run functions to something more descriptive. 2020-05-19 15:58:04 -07:00
Priyank Patel d0a7540534 puppeteer: Add run_test method to common.
This method does all error handling and removes ~5-6 lines of try/catch
block across each test file.
2020-05-19 15:58:04 -07:00
Priyank Patel 41447a0d5c puppeteer: Add a common module for resuable code.
In common.js, we now have a single browser instance for the whole
test. When we update the test-js-with-puppetter to spawn a single
node process, like we do for node tests, we will save time on having
to open an new browser for every test + puppetter start up cost.

We will also add some more helpers here like a method for
filling out a form easily etc.
2020-05-19 15:58:04 -07:00
Dinesh ab64d7936f puppeteer_tests: Remove explicit redirect from confirmation page.
Before fixing `test-js-with-puppeteer` to to use the right webpack
setup, redirects weren't happening properly. The line this commit
removes did a redirect to the register page. This line is removed
as the redirect will happen automatically as expected with fixing
`test-js-with-puppeteer`.
2020-05-19 15:54:00 -07:00
Dinesh 49f7355f40 tests: Create login test using puppeteer. 2020-05-19 15:52:26 -07:00
Rohitt Vashishtha 96638f5bd4 dropdown-list-widget: Use null-value when no value is specified.
Previously, we tried to read the value from page_params, which was just
a hack to make the calling code look cleaner. We now remove that hack
and thus, our dependency on page_params existing. Now, if the caller
does not specify a default value, we'll use the null-value.

This also creates a new init() function to cleanly wrap the code that
makes changes to the opts passed to the widget.
2020-05-19 15:13:28 -07:00
Rohitt Vashishtha aeb247f528 dropdown-list-widget: Rename setting_name -> widget_name.
This change is another in a series of commits that allows us to use
DLW outside of realm_settings.
2020-05-19 15:13:28 -07:00
Rohitt Vashishtha 6528226a80 dropdown_list_widget: Add basic tests. 2020-05-16 14:51:19 -07:00
Rohitt Vashishtha c76648c3d4 zjquery: Do not run JSON.parse on data-* attrs.
JSON.parse behaves as we want for numbers but for strings, we would
throw an error like 'unexpected token at position 0'. This meant we
couldn't read back the value set by `$input.data('val', 'text')`.
2020-05-16 14:51:19 -07:00
Rohitt Vashishtha a6a1858272 dispatch: Replace broken call to settings_org.
We had removed this function from the codebase when we switched to
using dropdown_list_widget. This was accidentally left as it is when
making that change.
2020-05-16 14:51:19 -07:00
Rohitt Vashishtha 6a3e245fe3 settings_org: Handle dropdown list widget updates inside module.
Previously, we handled these updates in server_events_dispatch
and could accidentally call widget.render() before initializing
the widget.

Original report: https://chat.zulip.org/#narrow/near/875608.

The sync_realm_settings function ensures that if the settings are
not open, any updates are a noop.
2020-05-13 10:08:51 -07:00
Rohitt Vashishtha e2b0a4cba1 list-widget: Rename settings_list_widget => dropdown_list_widget.
We want to use this widget outside of the settings panels as well.
2020-05-13 10:08:51 -07:00
clarammdantas 7e9024a39c popovers.js: Add version to user avatar request.
When a user changes its avatar image, the user's avatar in popovers
wasn't being correctly updated, because of browser caching of the
avatar image.  We added a version on the request to get the image in
the same format we use elsewhere, so the browser knows when to use the
cached image or to make a new request to the server.

Edited by Tim to preserve/fix sort orders in some tests, and update
zulip_feature_level.

Fixes: #14290
2020-05-12 11:09:01 -07:00
Aman Agrawal 5443b2f635 recent_senders: Update data structures for stream/topic edits.
* Remove old topic and reprocess both old and new topic to ensure
that we are correctly storing the last_msg_id of users in the
topic. Also, Handle topic's stream (& topic) edit updates.
* Add function to get all messages in a topic in message_utils.js.
* Send topic edit event to recent_senders.
* Add func get sorted list of recent_senders to topic.
The function will be useful to handle topic edits in Recent Topic UI.
2020-05-12 00:15:26 -07:00
Vishnu KS 8fb1f2af58 billing: Support downgrading plan from /billing page. 2020-05-11 17:20:54 -07:00
Vishnu KS f74e2b69f0 billing: Pass numeric_inputs as an argument to create_ajax_request. 2020-05-11 17:20:54 -07:00
Steve Howell c4d0e4c9f9 bot_data: Eliminate all uses of `bot.owner` (email).
We now use `bot.owner_id` for everything internally.
2020-05-11 16:16:58 -07:00
Steve Howell 5c16bb9c99 bot settings: Load bots independently.
We no longer use `/json/users` in the codepath
for bot settings (admin side).

We also specifically don't load human users when
we load bots, so you no longer have to pay for
the server round trip as a side effect of loading
bots.  Instead, there is a dedicated `set_up_bots`
entry point.

We also get the bot ids directly from `bot_data` now.

This commit, to some degree, builds on the prior commit
that had us hydrate data from `people.js` instead
of the payload from `/json/users`.
2020-05-11 16:16:58 -07:00
Steve Howell be064e6104 list_render: Add get_item option.
We want to move toward having list consumers
pass us in a list of ids that we hydrate later
in the process.  This should help live-update
scenarios.  The next commit will describe the
benefits in a bit more detail, using the
concrete example of our bot settings table
in the org settings.

A slightly longer-term goal here is to be
able to ask `list_render` to re-render a particular
id, and this moves us closer to that.  But even
before that, this change should eliminate a class
of bugs dealing with stale data, such as when
you manually patch a list (with direct jQuery
hacks) but then later go to sort/filter the rows.
We will now re-hydrate the items in those scenarios.
2020-05-11 16:16:58 -07:00
Steve Howell 155f6da8ba bots: Add owner_id to bot-related payloads.
For the below payloads we want `owner_id` instead
of `owner`, which we should deprecate.  (The
`owner` field is actually an email, which is
not a stable key.)

    page_params.realm_bots

    realm_bot/add

    realm_bot/update

IMPORTANT NOTE: Some of the data served in
these payloads is cached with the key
`bot_dicts_in_realm_cache_key`.

For page_params, we get the new field
via `get_owned_bot_dicts`.

For realm_bot/add, we modified
`created_bot_event`.

For realm_bot/update, we modified
`do_change_bot_owner`.

On the JS side, we no longer
look up the bot's owner directly in
`server_events_dispatch` when we get
a realm_bot/update event. Instead, we
delegate that job to `bot_data.js`.
I modified the tests accordingly.
2020-05-11 16:16:58 -07:00
Steve Howell 63154b335e bot_data test: Remove is_admin noise.
We no longer use `is_admin` in `bot_data`.
2020-05-10 16:20:41 -04:00
Steve Howell f9e2e357bf bot_data test: Clean up test people.
The prior version of "me" confusingly had the same
user_id as one of our bots, so I fixed that.

I also avoid using a test email of 'owner@zulip.com',
which is confusing for earlier tests where I haven't
established "me" as the actual owner of any bots.
2020-05-10 16:20:41 -04:00
Steve Howell 7c1f64d4e5 bot_data: Remove get_bot_owner_email. 2020-05-10 16:20:41 -04:00
Anders Kaseorg 83a0006602 clean_user_content_links: Show the full URL in the title.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-09 16:32:40 -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 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
Tim Abbott 50b74f7101 casper: Fix invalid check in 00-realm-creation.
We shouldn't be checking for #zfilt here, since we haven't done
anything that should cause #zfilt to load.  Instead, we verify whether
messages have loaded into the DOM (the condition we actually want) by
checking whether at least one message row is in the DOM.
2020-05-06 10:54:48 -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
Aman Agrawal beaa88a97b casper: Increase default timeout to avoid indeterministic CI failure.
Test fails at default timeout value indeterministically
because we have to wait for the server to start and the
above tests to pass, which takes more than the Default Timeout
of this test.
Hence, 4 x Default timeout value is kept.
2020-05-02 10:33:32 -04:00
sahil839 1f809f338b node tests: Add test_realm_boolean test for default_twenty_four_hour_time.
This adds missing test in dispatch.js.
2020-04-30 16:15:52 -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 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 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 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
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 b29c44ed94 list_render test: Test replace_list_data.
This gets us to 100% line coverage for
list_render, so we remove its exemption.
2020-04-24 18:24:12 -04:00
Steve Howell 0365db5ac4 list_render test: Test custom sorting.
In passing, we also get coverage for
list_render.get.

This test also implicitly demonstrates that
you can call `widget.sort` directly from some
external event handler; in other words, you
are not locked into the widget's conventions
for setting up <th> tags.
2020-04-24 18:24:12 -04:00
Steve Howell 47c9f463db list_render test: Split out no-filtering test. 2020-04-24 18:24:12 -04:00
Steve Howell 2cded3f3df list_render test: Check for bad modifier types. 2020-04-24 18:24:12 -04: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 d9166e2ab1 zblueslip: Simplify broken error message.
We were reporting 1 of 1 when 0 messages were
seen.
2020-04-24 18:24:12 -04:00
Steve Howell 62e9a29064 list_render test: Test reverse sorts.
This also cleans up our `sort_button` helper
a bit.
2020-04-24 10:50:08 -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
Steve Howell 5308f892d8 list_render test: Test clear_event_handlers. 2020-04-24 10:50:08 -04:00
Steve Howell 37314cfaee list_render test: Improve filter coverage.
This covers how we wire up the filter, and it
covers using `filterer` instead of `predicate`.

I also go away from the strange length-based
predicate that I had in the original test.
The intention behind the original test was
to show that filters could be more than simple
string-matching, but that was just a strange
way to demonstrate it.
2020-04-24 10:50:08 -04:00
Steve Howell c193751e9b list_render test: Exercise sort handler.
We now make sure that `set_up_event_handlers`
wires up our sort handlers correctly.
2020-04-24 10:50:08 -04:00
Steve Howell 9628cbf922 list_render test: Extract make_scroll_container.
The diff is a little noisy due to renaming a few
poorly named variables, but there aren't any
logic changes here inside the functions.
2020-04-24 10:50:08 -04: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 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