Commit Graph

92 Commits

Author SHA1 Message Date
Anders Kaseorg 428956c086 zjsunit: Remove set_global side effect from zrequire.
ES6 and TS modules don’t insert themselves into `window`, so our tests
shouldn’t insert them either.  Since the test `window` behaves like
`global` now, we can rely on legacy modules that do insert themselves
to do it themselves.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-13 14:29:17 -08:00
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00
Priyank Patel 73b19672c3 message_fetch: Use user IDs for supported operators.
The approach taken here is basically use user IDs in operator that
support it when sending the request for fetching the messages
(see comments in code for more details).
2019-07-13 11:35:37 -07:00
Hemanth V. Alluri 34db469700 org_settings: Fix error with undefined profile_field in bot settings.
This is a small patch to fix the error message an admin would receive if
they tried to change bot info and owner from the "bots" setting of the
organization settings panel.
2019-04-25 15:56:44 -07:00
Rohitt Vashishtha 5c2e64d6a2 tests: Fix accidental uses of assert() -> assert.equal(). 2019-02-20 10:41:42 -08:00
Hemanth V. Alluri e3aed0f7bc custom profile fields: Markdown rendering for custom profile field values.
This makes it possible it include our standard markdown formatting in
one's custom profile fields, allowing for links, emphasis, emoji, etc.

Fixes #10131.
2019-01-01 21:06:21 -08:00
Hemanth V. Alluri 28d344b4b5 custom profile fields: Pass value as part of a dictionary.
While we're at it, we remove the JSON parsing that was part of the
user field code path, since this function isn't responsible for
rendering user fields.
2019-01-01 21:05:28 -08:00
Yashashvi Dave 53201c5411 statis/js/people.js: Add function `get_user_type`.
Add function `get_user_type`, which returns user
type-"Administrator", "Guest", "Bot" or "Member"
depending on what they are.
2018-11-12 14:57:32 -08:00
Tim Abbott deb29749c2 people: Add a CSS class to label guest users.
This doesn't do anything yet, since we still need to add the actual
CSS, but it should make it easy for someone to just do the design
work.
2018-10-31 10:15:49 -07:00
Steve Howell adf616d3f1 Add pm_perma_link helper. 2018-10-22 12:22:26 -07:00
Rohitt Vashishtha b18f9def06 people.js: Add get_mention_syntax to conditionally get @user|id syntax.
This is intended to replace all function calls for generating mention
syntax for a target user.
2018-10-13 16:42:34 -07:00
Cynthia Lin a11c56f02a people: Format times without leading zeroes. 2018-10-04 17:02:09 -07:00
Rohitt Vashishtha e497816a42 people: Track users with same full names.
This commit exposes the function is_duplicate_full_name()
that can be used to discern if we cannot identify a user
just by their full name in the interface and have to use
his user id as well to distinguish them from other users.
2018-08-31 14:16:47 -07:00
Shubham Dhama 16357fc84a people: Add common function for getting active human users. 2018-07-30 13:48:36 -07: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 0ffcb7fccf search: Remove blueslip warnings for invalid emails in 'pm-with' filter.
Fixes #3380.
The blueslip warning mentioned in #3380 were from paths ending at
people.email_list_to_user_ids_string. Some additional blueslip warnings
were raised after using that function.
Although we can put a validation check somewhere in the call stack of
people.email_list_to_user_ids_string, this function itself is used to
validate the operand by the higher order functions, so it wouldn't make
sense to put a validation check before that. Instead, removing the
blueslip warning altogether was chosen.
people.email_list_to_user_ids_string was replaced by
people.reply_to_to_user_ids_string which is a blueslip-free version
of the same. Other blueslip warnings were removed.
2018-05-30 07:49:59 -04:00
Shubham Padia d9b0ab2ae7 narrow: Show non-existing user message for invalid emails.
Also adds people.is_valid_bulk_emails_for_compose and refactors
narrow_state.set_compose_defaults to use it.
2018-05-28 10:45:42 -07:00
Steve Howell e3b119c010 Add people.safe_full_names. 2018-05-16 09:30:49 -07:00
Steve Howell 42435db492 Add run_test helper for individual tests.
This run_test helper sets up a convention that allows
us to give really short tracebacks for errors, and
eventually we can have more control over running
individual tests.  (The latter goal has some
complications, since we often intentionally leak
setup in tests.)
2018-05-15 08:24:44 -07:00
Tim Abbott 4abbfe9154 people: Fix issues with client_gravatar and upper-case emails.
We weren't properly canonicalizing user email addresses when consuming
gravatar URLs.

See http://en.gravatar.com/site/implement/hash/ for the specification.

Fixes #9357.
2018-05-10 12:35:20 -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
Rohitt Vashishtha c5d9a052c0 zblueslip: Convert node_tests/people.js to zblueslip. 2018-05-03 16:27:05 -07:00
Tim Abbott dfac0302fc people: Extract small_avatar_url_for_person.
This is intended to be used in places like compose typeahead to
display users' avatars.
2018-04-09 12:12:44 -07:00
YJDave 11c995b70f custom profile data: Send event to active user on update.
On update of custom profile fields, send an event to all
active users of realm.
2018-03-21 16:08:12 -07:00
YJDave b404d0e156 custom profile data: Set custom field's values in user setting page on load.
Set realm custom field's values for current user in user setting page
when page gets load.
2018-03-21 16:08:12 -07:00
Rohitt Vashishtha b22e8dc2b7 lint: Replace 'return undefined;' with 'return;'.
Also adds a custom rule to eslint. Since the recommended way of extending
eslint is to create plugins as standalone npm packages, the separate rule
is published as 'eslint-plugins-empty-returns'.

Fixes #8669.
2018-03-13 08:22:42 -04:00
Steve Howell 3a1bf04a56 compose: Add pills for typing in PM recipients.
@brockwhittaker wrote the original prototype for having
pills in the recipient box when users compose PMs (either
1:1 or huddle).  The prototype was test deloyed on our
main realm for several weeks.

This commit includes all the original CSS and HTML from
the prototype.

After some things changed with the codebase after the initial
test deployment, I made the following changes:

    * In prior commits I refactored out a module called
      `user_pill.js` that implemented some common functions
      against a more streamlined version of `input_pill.js`,
      and this commit largely integrates with that.

    * I made changes in a prior commit to handle Zephyr
      semantics (emails don't get validated) and tested
      this commit with zephyr.

    * I fixed a reload bug by extracting code out to
      `compose_pm_pill.js` and re-ordering some
      calls to `initialize`.

There are still two flaws related to un-pill-ified text in the
input:

    * We could be more aggressive about trying to pill-ify
      emails when you blur or tab away.

    * We only look at the pills when you send the message,
      instead of complaining about the un-pill-ified text.
      (Some folks may consider that a feature, but it's
      probably surprising to others.)
2018-03-07 15:53:11 -08:00
Steve Howell 99695da799 node tests: Use zrequire in people.js. 2017-11-08 12:24:17 -08:00
Steve Howell e0fa317be1 node_tests: Remove unneeded var statements.
Variables like Dict/_/assert are already globally defined.
2017-11-08 12:24:17 -08:00
Steve Howell f105c480b3 Calculate gravatar hashes on the webapp client.
This change prepares us to have the server send avatar_url
of None when somebody wants a gravatar avatar (as opposed
to a user-uploaded one).

Subsequent commits will change behavior on both the server
and client to have this happen.  So this commit has no-op
code for now, but it will soon use the fallback-to-gravatar
logic.
2017-11-07 10:36:02 -08:00
Steve Howell 02a011d627 Add people.report_late_add().
We want to know when users are added after page load, as it can
be a symptom of stray messages leaking in or live-update problems,
etc.

Fixes #7120
2017-11-07 09:51:10 -08:00
Steve Howell aebfdaa8ed refactor: Use early-return in extract_people_from_message(). 2017-11-07 09:51:10 -08:00
Steve Howell 294a1fb8f8 refactor: Extract people.maybe_incr_recipient_count().
This logic used to be in extract_people_from_message(), but
we are deprecating extract_people_from_message(), whereas
the maybe_incr_recipient_count() function has logic that we
want to keep.
2017-11-07 09:51:10 -08:00
Steve Howell 5271241b24 Read page_params.realm_non_active_users() at page load.
This change is the first step in making it so that we load
non-active users at page load time in the webapp.

Before this change, we would reactively handle deactivated
users when we saw them as senders in messages.  Subsequent
changes will make it a warning if we see unknown senders
in messages.
2017-11-07 09:51:10 -08:00
Steve Howell b492f3569a tests: Extract node_tests/people_errors.js.
This is mostly a pure extraction, but we needed to duplicate
a bit of setup from people.js, and I added an assertion
for warning about "No user_id provided".
2017-11-07 09:51:10 -08:00
Steve Howell df03e30d68 popovers: Fix is-active checks for popovers.
We were incorrectly reporting active bots as non-active in
popovers, and we had no test coverage for cross-realm bots.

We also rename the function to is_active_user_for_popover,
since the old name, realm_user_is_active_human_or_bot, suggested
the wrong semantics for cross-realm bots.

Last but not least, we only do a blueslip warning if a user id
is not found.  When lookups fail, we are pretty confident that
the user is not active, so an error is overkill.  We can change
that as part of issue #7120.

Fixes #7153
2017-10-26 13:56:32 -07:00
Steve Howell f8f4d9cb63 people.js: Rename realm_get -> get_active_user_for_email.
We rename this function to be more clear, and we also remove
a stray function name for `realm_get` that was for the wrong
exported function.
2017-10-26 09:52:42 -07:00
Steve Howell 2699a6aac9 refactor: Extract people.is_valid_email_for_compose().
It's easier to unit test logic inside of people.js than compose.js.

We allow users to compose emails to any of our cross-realm bots.
Someday we may tighten up which cross-realm bots are valid targets,
since it's not necessarily the case that those bots do anything
useful when you send them messages.
2017-10-26 09:45:08 -07:00
Steve Howell 646bd356a3 Rename get_realm_human_user_ids -> get_active_user_ids.
The function name `get_realm_human_user_ids` was a lie--it
includes active bots as well.

The only user of this function is `activity.js`, which wasn't
impacted by the misleading name, because we eventually filter
out bots in the `info_for` function.

It's possible that we actually want to include bots in the right
sidebar, since they can be difficult to discover in other parts
of the UI.  Or, if we want to keep the right sidebar as all
human users, we may eventually want to make the logic to exclude
bots happen higher in the stack (but for real, this time).
2017-10-26 09:17:43 -07:00
Tim Abbott b1301cdfec node_tests: Restore 100% coverage on people.js. 2017-10-24 16:24:03 -07:00
Tim Abbott 11eba1173c popovers: Don't show bots as deactivated in user popovers.
Apparently this is a bug that slipped in when we started showing
normal users as deactivated in the user popovers: all bot users were
treated that way as well.

We'll want to do #7153 as a follow-up to get things fully working how
we want them.
2017-10-24 15:59:51 -07:00
Brock Whittaker 4f088292ee popovers: Hide user email and PM feature for deactivated users.
This hides the emails of deactivated users from the popovers along
with the link to send a PM to them.
2017-10-18 00:06:12 -07:00
Steve Howell 6888255153 Add people.get_realm_user_ids().
This saves us from doing an unnecessary map() in
activity.js.
2017-10-08 12:01:59 -07:00
Steve Howell e3ee0245c4 Change userid -> user_id in people.js. 2017-10-07 12:16:45 -07:00
Cory Lynch 0da74f4d6d filter.js: Add test coverage for group-pm-with.
Added one little additional test in
people.js to get up to 100% coverage.
2017-09-24 15:13:58 -04:00
Steve Howell b446d96ed6 Add people.pm_lookup_key 2017-08-02 09:40:47 -07:00
Cory Lynch df83cee86b people.js: Ignore diacritics in search bar.
Fixes #5315
2017-06-21 19:13:44 -04:00
Joshua Pan 3905602da5 node tests: Test user timezone functions in people.js. 2017-06-02 06:30:40 -06:00
Joshua Pan 52518fbc29 node tests: Get people.js to 100% node coverage. 2017-06-01 20:27:58 -07:00
Joshua Pan fd57fcbc1c node tests: Add coverage for blueslip errors in people.js.
This covers all blueslip errors and warnings
in people.js. These do not need to be tested
to rigorously and just need to be covered to
get people.js to 100% coverage.
2017-05-31 16:04:49 -06:00