Commit Graph

1624 Commits

Author SHA1 Message Date
Steve Howell ea581c546c Add filter.is_valid_id_from().
We will use this to find the first id from a list of
message ids that matches a filter.  (This will help us
during narrowing to determine whether we have at least
one good message locally, so that we can render something
useful before waiting for the server.)
2018-05-08 12:13:55 -07:00
Steve Howell a176380df5 refactor: Introduce filter.is_exactly().
This new API replaces some more specific functions that were
only recently introduced:

        is_stream_only
        is_stream_topic_only
        is_pm_with_only
        is_for_only

We use the deterministically sorted "term_type" values for
matching.  (Notably "stream" will come before "topic".)
2018-05-08 12:13:55 -07:00
Steve Howell 60e399f717 Add filter.sorted_term_types. 2018-05-08 12:13:55 -07:00
Steve Howell 081e789405 Add static Filter.sorted_term_types(). 2018-05-08 12:13:55 -07:00
Steve Howell c267d3a6ba Add Filter.term_type. 2018-05-08 12:13:55 -07:00
Yago González 6837fc5d56 i18n: Add missing strings for custom profile fields and fix capitalization.
The "Short/Long Text" option for custom profile fields wasn't properly
capitalized (i.e. "Text" should have been all lowercase), and also
wasn't properly tagged for translation.

For the sake of consistency, the change to proper capitalization has
also been applied to the models and any tests involving this feature.

Due to a bug in Django, it complained about the models having changed
and thus not being consistent with the migrations. That isn't actually
true (since the database stores the numeric values for each key), but
the migrations have been modified to avoid this error. This does not
affect the migrations' behaviour in any way.
2018-05-06 19:44:36 -07:00
Tim Abbott 6e149a7594 lint: Add JS indentation eslint rules for node_tests.
The only difference between this as the main project's lint rules is
that we dont have the OuterIIFE setting.
2018-05-06 19:35:18 -07:00
Tim Abbott ed299feb00 lint: Check eslint indentation for casper tests.
Now we just limit this rule for the node tests themselves.
2018-05-06 19:35:18 -07:00
Tim Abbott d3f8208715 eslint: Add whitespace indentation configuration.
This should help prevent problems with folks introducing new code that
doesn't match our whitespace style.

There's a couple things I don't like about this configuration:

* How it handles multi-line JS lists (i.e. the [] syntax)
* That we ended up having to turn off indentation on a half-dozen
  files that apparently don't use our standard IIFE indentation style.
* That we have it completely turned off for the node tests; ideally,
  we'd just have slightly different rules around the IIFE identation story.

But otherwise, this works pretty well, and should catch a pretty wide
range of indentation regressions.
2018-05-06 19:35:18 -07:00
Tim Abbott 716a4a967d js: Fix indentation issues in casper tests.
Our casper tests now pass eslint cleanly.
2018-05-06 19:35:18 -07:00
Tim Abbott df98fd5cd9 hotkey: Make it possible to use ctrl+K from inside compose.
This works for other text boxes as well, but compose is the main one
that one would want to do a search from.

It's possible we'll find after doing this that "getting back into
compose" becomes a problem, but I guess we can handle that when the
time comes.
2018-05-06 19:30:31 -07:00
Aastha Gupta 66edc003ca hotkey: Make 'Ctrl' hotkeys work with 'CMD' on MacOS.
We only have a couple hotkeys with this model, but they should both
do the correct corresponding thing on MacOS.
2018-05-06 19:21:36 -07:00
Aastha Gupta 19806a0283 keyboard UI: Add Ctrl + k hotkey.
Fixes #8216
This commit binds the Ctrl + k to go to the search bar.
2018-05-06 19:19:00 -07:00
Tim Abbott 384a8f2e9f custom fields: Clean up template logic for field ID.
This makes a few important cleanup changes:
* Using the more standard data-field-id name for the ID value.
* Using $(e.target).closest() rather than `.parent`, which is more
  robust to future changes in markup.
2018-05-05 15:40:16 -07:00
Yashashvi Dave 06e63af4b4 custom fields: Add UI for choice type custom fields. 2018-05-05 11:59:08 -07:00
Yashashvi Dave 512ab5dbaf js/settings_account.js: Remove hard-coded field no, clean template context. 2018-05-05 11:59:08 -07:00
Steve Howell 320425fde3 node tests: Add tests for message_list_data. 2018-05-05 06:31:51 -07:00
Steve Howell 264dcb6f40 refactor: Extract MessageListData class.
Most of this was straightforward.

Most functions that were grabbed verbatim and whole from
the original class still have one-line wrappers.

Many functions are just-the-data versions of functions that
remain in MessageList:  see add, append, prepend, remove as
examples.  In a typical pattern the MessageList code becomes
super simple:

    prepend: function MessageList_prepend(messages) {
        var viewable_messages = this.data.prepend(messages);
        this.view.prepend(viewable_messages);
    },

Two large functions had some minor surgery:

    triage_messages =
            top half of add_messages +
            API to pass three lists back

    change_message_id =
            original version +
            two simple callbacks to list

For the function update_muting_and_rerender(), we continue
to early-exit if this.muting_enabled is false, and we copied
that same defensive check to the new function
named update_items_for_muting(), even though it's technically
hidden from that codepath by the caller.
2018-05-05 06:31:51 -07:00
Rohitt Vashishtha 7fef91a405 zblueslip: Convert node_tests/settings_user_groups.js to zblueslip. 2018-05-03 16:27:05 -07:00
Rohitt Vashishtha 22ca18f59c zblueslip: Convert node_tests/pm_list.js to zblueslip. 2018-05-03 16:27:05 -07:00
Rohitt Vashishtha c5d9a052c0 zblueslip: Convert node_tests/people.js to zblueslip. 2018-05-03 16:27:05 -07:00
Rohitt Vashishtha 8219d2dcf4 zblueslip: Convert node_tests/messge_store.js to zblueslip. 2018-05-03 16:27:05 -07:00
Rohitt Vashishtha f51e151e62 zblueslip: Convert node_tests/markdown.js to zblueslip.
Also allows comparing in zblueslip using toString() for cases like
comparing an `Error('hello')` object and a `'hello'`.
2018-05-03 16:27:05 -07:00
Rohitt Vashishtha cba2c529f9 zblueslip: Convert node_tests/activity.js to zblueslip. 2018-05-03 16:27:05 -07:00
Steve Howell a68fa980d3 Add starred messages to our new API for unread ids.
Even though starred messages are never unread, it's useful
for us to have helper functions for them.

This change makes it so that clicking on "Starred Messages"
takes you to the last read message immediately, without a
server delay.
2018-05-03 14:36:34 -07:00
Steve Howell 3e19efca36 Change narrow.get_first_read_id -> get_first_read_info.
This function, which is only used in tests so far, needs
to return something more meaningful than undefined when
we don't find an id.
2018-05-03 12:44:30 -07:00
Steve Howell 4eb033964e Add fetch_status.has_found_newest(). 2018-05-03 12:44:30 -07:00
Shubham Dhama 9f78540bd0 org settings: Make save-discard widget look better.
This fixes some minor glitches with buttons:
* Movement of the organization-settings-parent block on the
  appearance of widgets.
* Large and odd look of save button.
* Use of fadeIn and fadeOut rather than changing opacity as
  opacity don't actually remove them.
2018-05-03 10:32:34 -07:00
Tim Abbott 0ada5fa9d8 stream_data: Fix exception when notifications_stream is private.
If notifications_stream is private and the current user has never been
subscribed, then we would throw an exception when trying to look up
notifications_stream.  In this situation, we should just treat it like
the stream doesn't exist for the purposes of this user.
2018-05-03 08:33:07 -07:00
Steve Howell 6bab68ff6a node tests: Fix flaws with narrow_activate tests.
The original version of this function was simulating kind
of an illogical code path, where -1 was sort of pointing to
a real message, which doesn't make sense.

Now we pass in an explicit then_select_id.
2018-05-03 07:52:15 -07:00
Aditya Bansal 898c281692 public_archives: Add styling to the public topics. 2018-05-02 15:23:33 -07:00
Steve Howell 66cd2edee4 Add narrow_state.get_first_unread_id(). 2018-05-02 13:34:54 -07:00
LuisFSilva a072b2a153 right-sidebar: Fix group PMs online indicator.
People found it confusing that it would show up at light-green when
the users in the thread were idle.

Fixes #8242.
2018-05-02 12:41:01 -07:00
Shubham Dhama c67897ba5b upload: Make progress bar for each file independent.
Here `file.lastModified` is unique for each upload so it is used
to track each upload individually.
Also, we have used `uploadStarted` function because it is
called for each file during an upload.

Fixes: #9068.
2018-05-02 12:32:13 -07:00
Steve Howell 230ecb24ed Add narrow_state.get_unread_ids(). 2018-05-02 11:23:58 -07:00
Steve Howell ceee49c075 Add filter.is_for_only(operand). 2018-05-02 11:23:58 -07:00
Steve Howell 7bc95efb41 Add unread.get_msg_ids_for_mentions(). 2018-05-02 11:23:58 -07:00
Steve Howell 9987ea525f Add unread.get_msg_ids_for_private(). 2018-05-02 11:23:58 -07:00
Steve Howell 7222dbd99b refactor: Simplify narrow_state.is_for_stream_id().
This takes advantage of the new function narrow_state.stream_id().

We now assume the incoming stream_id is a valid stream_id, so we
no longer need to test some of the error checking.  (It's possible that
the incoming stream_id may no longer be for a stream you subscribe
to, but the nice benefit of working more in "id space" is that if
it doesn't match the narrow's stream id, we know false is a safe
return value.)
2018-05-02 09:16:24 -07:00
Steve Howell a62c85c015 Add narrow_state.stream_sub() and narrow_state.stream_id(). 2018-05-02 09:16:24 -07:00
Steve Howell 0232e92038 Add filter.is_pm_with_only(). 2018-05-02 09:16:24 -07:00
Steve Howell 2a70f0dba4 Add filter.is_stream_topic_only(). 2018-05-02 09:16:24 -07:00
Steve Howell 08307c0e87 Add filter.is_stream_only(). 2018-05-02 09:16:24 -07:00
Steve Howell 0150c01027 Add unread.get_msg_ids_for_person(). 2018-05-02 09:16:24 -07:00
Steve Howell 2b35f26b88 Add unread.get_msg_ids_for_stream(). 2018-05-02 09:16:24 -07:00
Steve Howell c432acb436 Add unread.get_msg_ids_for_topic().
This will be useful for some narrowing related changes.
2018-05-02 09:16:24 -07:00
Steve Howell 76b97d8b54 refactor: Add util.sorted_ids().
We borrowed this from typing_data.js and gave it a slightly
different name (sorted -> sorted_ids).
2018-05-02 09:16:24 -07:00
Shubham Padia 23e82315b5 stream-settings: Remove redundant actually_filter_streams function call.
After adding a newly created stream to the top of the stream list,
call to actually_filter_streams in stream_events.mark_subscribed
rerendered the filter_table and the stream list was refreshed.  The
call to actually_filter streams was introduced to rerender the
subscriber list but stream_edit.rerender_subscribers_list takes care
of it already.

Fixes #9033.
2018-04-30 11:38:47 -07:00
Rohitt Vashishtha 639fa0db77 zblueslip: Convert node_tests/narrow_state.js to zblueslip. 2018-04-30 10:12:55 -07:00
Rohitt Vashishtha a87123ec23 zblueslip: Convert node_tests/input_pill.js to zblueslip. 2018-04-30 10:12:55 -07:00