Commit Graph

81 Commits

Author SHA1 Message Date
Mohit Gupta 487861554f search: Fix searching and search suggestion in Group PM.
Fix the .get_suggestions and .get_suggestions_legacy
to correctly handle search terms in group PM and treat
it as search term by not concatenating it at end of pm-with
email list operand.
2019-06-28 12:45:37 -07:00
Pragati Agrawal 69ec96b63e search suggestion: Hide email under hidden email-address-visibility cases.
This commit hides the email address from the search bar for the email
hidden cases.
2019-05-30 16:22:54 -07:00
Shubham Padia 73e4f3b3fa search: Do not display `All messages` suggestion if bar not empty.
Previously `All messages` was displayed irrespective of the existing
pills. Now the suggestion is displayed only if no pills are present
2018-07-23 11:29:10 -07:00
Shubham Padia 8b153f6452 search: Validate suggestion against existing operators.
After adding search pills, suggestions were based only on the
current input and no validation against the existing pills was done.
operator_subset_suggestions have been removed. Default suggestions
for base_operators have also been removed.
Handle multiple operators:
if `is:starred stream:Ver` was typed without selecting the typeahead
or pressing enter in between i.e search pill for is:starred has not yet
been added, then the description of `is:starred` will act as a prefix
in every suggestion.
Also makes changes re-enabling person suggestions for names with spaces.
2018-07-23 11:29:10 -07:00
Tim Abbott db4f6e278f search: Duplicate get_default_suggestion.
This lets us modify the implementation of this function for the search
pills implementation only.
2018-07-23 11:29:10 -07:00
Tim Abbott 5b0e9b7fe6 search: Duplicate search_suggestions.get_suggestions.
This large function will need to be modified significantly as part of
the pills effort, and copying it lets us preserve behavior in
production until we're ready to cut things over.
2018-07-23 11:29:10 -07:00
Armaan Ahluwalia 6d255efe4c app: Prepare JS files for consumption by webpack.
This commit prepares the frontend code to be consumed by webpack.

It is a hack: In theory, modules should be declaring and importing the
modules they depend on and the globals they expose directly.

However, that requires significant per-module work, which we don't
really want to block moving our toolchain to webpack on.

So we expose the modules by setting window.varName = varName; as
needed in the js files.
2018-07-05 10:53:36 +02:00
Shubham Padia 1364971a17 search: Extract phrase_match to common.js.
Extracts phrase_match to common.js so it can be used by other
components like integrations search.
2018-06-26 20:38:47 -04:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04:00
Shubham Padia f6f4a3f50a browser-support: Replace occurrences of `.includes` in static/js/*.
Fixes #9649.
`.includes` is not supported in Internet Explorer.
Replace `.includes` with `.indexOf() !== -1`.
2018-06-03 14:30:22 -07:00
Shubham Padia 561c9d7368 search: Add format_as_suggestion to search_suggestions.js.
`format_as_suggestion` formats a list of operators into a
suggestion using the Filter.describe and Filter.unparse methods.
This change aims to increase readability.
2018-06-03 11:53:34 -07:00
Shubham Padia c92e909980 search: Add check_validity to search_suggestions.js.
Refactors search_suggestions.js to use check_validity to check if
last operator is valid and none of the previous operators is invalid.
2018-06-03 11:53:34 -07:00
Shubham Padia 5d750a5d44 search: Respect spaces in person name in new suggestions only.
Fixes #6515.
New suggestions for `sender:King ha` will respect spaces and the new
suggestion will be `Sent by King Hamlet <email>` instead of `Sent by King,
search for ha`. But if first term of sender operand is a valid user email,
tokens will be seperated by spaces. e.g `sender:hamlet@zulip.com abc`
will show `Sent by King Hamlet <email>, search for abc`.
2018-05-25 09:03:27 -07:00
Shubham Padia e5b3fb332b search: Do not show default suggestion for `is` operator.
Fixes #9492.
Default suggestion e.g `abc messages` as a suggestion for `is:abc`
is not shown in a new suggestion. But if the is operator is already
present before any other operator, the default message text will be
used. e.g `is:abc sender:abc@zulipchat.com` will have all the suggestions
with the prefix `abc messages, sent by abc@zulipchat.com`.
2018-05-22 18:16:02 +05:30
Shubham Padia 4a78c00397 search: Rank "messages sent by" above "PMs with".
Fixes #9313.
2018-05-21 22:38:57 -07:00
Shubham Padia 17d4908667 search: Show negated suggestions for sent by me filters. 2018-05-21 22:38:14 -07:00
Shubham Padia d5976e9501 search: Show negated suggestions for stream filters.
Fixes #9461.
Adds negated suggestions for stream filters when the query is negated
which were previously being returned empty.
2018-05-21 22:38:14 -07:00
Shubham Padia 3d545abf9d search: Remove redundant get_containing_suggestions function.
`get_containing_suggestions` was used to get the operand suggestions
for the `has` operator. `get_special_filter_suggestions` is now used
to get both the operand and operator suggestions for `has`.
2018-05-21 22:38:14 -07:00
Shubham Padia 547f2ccae6 search: Show negated suggestions for category wise filters.
Partially fixes #9461.
Negated suggestion for both operand and operators are handle in
get_special_filter_suggestions. A bug is get_operator_suggestions
causing the removal of `-` symbol from the operand was also fixed.
2018-05-21 22:38:14 -07:00
Shubham Padia d478c6399c search: Show category-wise operator suggestions for has operator.
When suggesting operators to chose, category wise suggestions are
shown instead of a single default suggestion. e.g suggestions for
all the categories of has operator will be show instead of `Messages
with one or more` suggestion which did not make sense.
2018-05-18 14:18:26 -07:00
Shubham Padia 2945062b79 search: Do not show default suggestion for `has` operator.
Fixes #9384.
Default suggestion e.g `messages with one or more abc` as a suggestion
for `has:abc` is not shown in a new suggestion. But if the has operator
is already present before any other operator, the default message text
will be used. e.g `has:abc sender:abc@zulipchat.com` will have all the
suggestions with the prefix `messages with one or more abc, sent by
abc@zulipchat.com`.
2018-05-18 14:18:26 -07:00
Tim Abbott 4d0e64ee41 js: Fix some invalid whitespace.
These were detected using eslint.
2018-05-06 12:38:44 -07:00
Tim Abbott 0db715d222 search_suggestion: Add escaping for email addresses.
This is probably unnecessary, but makes me feel better about every
code path in this file doing proper escaping to avoid XSS issues.
2018-04-12 09:47:01 -07:00
Tim Abbott 65b9d9e0f3 CVE-2018-9990: Fix XSS issue with stream names in topic typeahead.
Zulip's search typeahead had a security bug, where when autocompleting
a specially crafted stream name, and then hitting space, code within
the stream name would be executed.

Zulip was doing HTML escaping correctly in the main code path using
Filter.describe to describe a narrow, but the escaping function was
not called in a few parallel code paths.  We fix this in a way that
should protect all of these code paths, by making Filter.describe
return properly escaped HTML, rather than depending on its callers to
do so.

Thanks to w2w for reporting this issue.
2018-04-12 09:46:54 -07:00
Rishi Gupta 191f8f1b39 left sidebar: Change Home to All messages.
We made this change because users often unnecessarily click "Home"
first in their use of Zulip, because it seems appealing.  While "All
messages" isn't quite precise (it doesn't include muted streams), it
does describe relatively simply the interleaved view that this
represents.

This commit leaves everything as "home" in the code, and only changes
user-visible strings and docs. Changing the code will be a big project;
there are hundreds of relevant occurrences in variable names, etc.

Further, we'll probably want to convert those various variable names
in different ways.

Tweaked by tabbott to extend the commit message and update a few comments.
2017-11-28 15:42:58 -08:00
Tim Abbott 82b708b721 eslint: Add and enforce space-in-parens lint rule. 2017-10-06 12:36:59 -07:00
Cory Lynch a90eda0154 Add 'group-pm-with' to operator autocomplete.
As you're typing this new keyword, it should be suggested
via get_operator_suggestions. Added relevant test.
2017-09-24 13:56:33 -04:00
Abhijeet Kaur 2bf3324395 frontend: Add ability to search by "group-pm-with" search operator.
This allows user to view all group private conversation messages
with a specific user. That is, it views all the the group private
messages from groups which include the given user.

Add search suggestion for group-pm-with. Add operator name
and description in "Search operators" tab.

Add change in tab name to "Group Messages" when using this operator.
Add frontend_tests for group-pm-with search operator.

Fixes: #3882.
2017-09-24 11:58:48 -04:00
Steve Howell bc0761b22b Extract topic_data.js.
This new module tracks the recent topic names for any given
stream.

The code was pulled over almost verbatim from stream_data.js,
with minor renames to the function names.

We introduced a minor one-line function called stream_has_topics.
2017-07-27 14:26:22 -07:00
Steve Howell b95e785335 recent topics: Extract get_recent_topic_names().
We now have all of our callers into recent_topics code just
receive a list of topic names from get_recent_topic_names().

This is more encapsulated than handing off tiny little
structures to the three callers, two of whom immediately
mapped the objects to names, and one of whom needlessly
used the now defunct name canon_subject field.

The consolidation here removes some "subject" references, and
now all lookup are by stream id, not stream name.

The diff here is a bit daunting, but it's mostly simplification
of tests and calling code.  Two of the callers now need to look
up stream ids, but they are otherwise streamlined.

The main change here is to stream_data.js, and we replace the
`canon_subject` and `subject` fields with `name`.
2017-07-27 14:26:22 -07:00
Cory Lynch 1dba70ca0d search_suggestion: Fix highlighting for multi-word streams.
I deleted a test case that involved a highlighted stream, but
the query was empty. This produces kind of a weird result with
typeahead_helper.highlight_with_escaping, but this function already
has coverage in node_tests/typeahead_helper.js, so the check here
was essentially redundant anyway. Specifically, the highlighter
wraps every character individually with <strong>, and looks really
messy in html.
2017-07-14 17:33:09 -07:00
Cory Lynch 2ce7a20237 search_suggestion: Support autocompleting operator names.
Fixes #5399
2017-07-07 20:54:54 -07:00
Cory Lynch 75617d07de search_suggestions: Prioritize recent huddles.
Fixes #5612. What this specifically does is that if you are
typing a group PM, this logic iterates through the possible
search suggestions for the next autocomplete. If that suggestion
contains a group PM that already exists, then prioritize it with
the most recent one on top.
2017-07-07 12:12:30 -07:00
Cory Lynch 7efba29b0c search_suggestions: Hide own name in huddle suggestions. 2017-07-07 12:12:30 -07:00
Cory Lynch 8abbb6d781 search: Remove in:all token from suggestions. 2017-07-01 12:19:52 -04:00
Cory Lynch 090d7487cf search_suggestion: Use person matching function from people.js.
Instead of having a custom (duplicate) matching function in
search suggestion, it was refactored to use the function in
people.js. This also gets the diacritic-ignoring feature
of the function in people.js.

Fixes #5315.
2017-06-23 08:29:20 -04:00
Cory Lynch 58a2ffbe1d Add search suggestion support for is:unread. 2017-06-19 06:51:13 -04:00
Cory Lynch 11a7a476d7 search_suggestion: Add negation support for 'has' operator. 2017-06-15 02:32:00 -07:00
Cory Lynch da4e2954fe search_suggestion: Remove is:private as default suggestion. 2017-06-15 02:20:50 -07:00
Cory Lynch 89b8d07420 Make search suggestion messages more concise.
This involves updating filter.js, mostly. The
tests were updated appropriately for this change,
which also involved changing a caspar test for
narrowing.
2017-06-14 22:34:46 -07:00
Cory Lynch ab5b0e938d Add support for "has" operator in search_suggestions.
This was never a feature in the old search_suggestions
version, so a new helper function for it was added.

Relevant tests were also added, maintaining 100% coverage.
2017-06-14 22:34:46 -07:00
Cory Lynch a7ec8cd1f3 Improve topic in search_suggestion.js.
Also added some additional testing to handle
some edge cases that I'd like to make sure
don't break down.
2017-06-14 22:34:46 -07:00
Cory Lynch 7cda7c4782 Improve stream in search_suggestions.js. 2017-06-14 22:34:46 -07:00
Cory Lynch 69e8074d14 Improve person/group in search_suggestions.js.
The get_person_suggestions and get_group_suggestions functions
were updated to the new system. Support for negation is also
added in the new system.

Relevant tests were also updated. Also, note that the function
get_private_suggestions was removed, as it was rendered
obsolete by these updates.
2017-06-14 22:34:46 -07:00
Cory Lynch c8d4eff8aa Improve sent_by_me in search_suggestions.js.
Added appropriate tests.
2017-06-14 22:34:46 -07:00
Cory Lynch 79d56c94dc Improve default and special_filter in search_suggestion.js.
Special filter was updated to work even when it is not the first
token in a search query. Furthermore, the default query was
moved around to work with the changes to come for the new
suggestion system.

A test also had to be modified to work with the new system.
2017-06-14 22:34:46 -07:00
Steve Howell 8eb86335b9 Extract narrow_state.js.
Despite the length of this commit, it is a very straightforward
moving of code from narrow.js -> narrow_state.js, and then
everything else is just s/narrow.foo()/narrow_state.foo()/
(with a few tiny cleanups to remove some code duplication
in certain callers).

The only new functions are simple setter/getters that
encapsulate the current_filter variable:

    narrow_state.reset_current_filter()
    narrow_state.set_current_filter()
    narrow_state.get_current_filter()

We removed narrow.predicate() as part of this, since it was dead
code.

Also, we removed the shim for narrow_state.set_compose_defaults(),
and since that was the last shim, we removed shim.js from the app.
2017-04-25 09:57:32 -07:00
Elliott Jin 9b854c62bc search_suggestion: Suggest multiple people in `pm-with` searches.
Currently, searching for group private messages requires typing each
person's email individually.  This change improves the typeahead
suggestions for group `pm-with` searches by suggesting additional people
whenever a comma is entered.

Fixes: #3575
2017-02-07 14:13:29 -08:00
Steve Howell 2af0302ed0 refactor: Use people.my_current_email() in search_suggestion.js. 2017-01-21 21:45:12 -08:00