Commit Graph

184 Commits

Author SHA1 Message Date
Steve Howell 3e4326afda refactor: Extract email_for_user_settings.
We want to be able to unit test this value,
since it's conditional on several factors:

    - am I an admin?
    - can non-admins view emails?
    - do we have delivery_email for the user?

I'm mocking show_email in the tests, since the
show_email code is in `settings_org` and
kind of hard to unit test.  It's not impossible,
but it's too much for this commit.  (Either
we need to extract it out to a nice file or
deal with mocking jQuery.  That module is
mostly data-oriented, so it would be nice
to have something like `settings_config` that
is actually pure data.)
2019-12-28 11:22:24 -08:00
Steve Howell 3a95be2f2f refactor: Extract matches_user_settings_search.
This was duplicate code.  I'm moving it to people
for pragmatic reasons--it's hard to unit test stuff
in settings_users.js due to all the jQuery.

It's also nice to have all people-related search
code in one place, just for auditing purposes.
2019-12-28 11:22:24 -08:00
Steve Howell 5e0fc25f74 bug fix: Allow admins to filter users in settings.
It appears c28c3015 caused a regression where we
set `email` to undefined if a user does not have
`delivery_email` set, and this causes filtering
of users to fail for admins doing user settings.

This fixes only one of the issues reported in
issue #13554.

There's probably no easy fix to scrolling taking
long, but I think fixing search will mostly
address that complaint.

The Rust folks seem to agree with me that the
search results are too noisy.  If I search for
"s" I get:

    * names like Steve (good)
    * names like Jesse (noisy)
    * anybody with s in their email (super noisy)

Here is the relevant code:

    return (
        item.full_name.toLowerCase().indexOf(value) >= 0 ||
        email.toLowerCase().indexOf(value) >= 0
    );
2019-12-28 11:22:24 -08:00
Tim Abbott ce474ee8cf bot settings: Fix sorting by owner.
The previous configuration had not been properly updated for the
conversion of how we transmit bot_owner to the frontend to be based on
user IDs.
2019-12-06 12:01:46 -08:00
Gaurav Thapar 2346dc84df bots: Render bot owner name in bots settings as link to show owner profile.
If owner exists, show owner name as link in org. settings which on click
trigger owner profile popup.

Fixes: #13388.
2019-12-06 12:00:07 -08:00
Tim Abbott 44f9ce92e9 bots: Fix rendering of bot owner fields in admin settings.
This fixes two regressions in 1946692f9a.

The first bug was actually introduced much earlier, namely that we
were not sending a `bot_owner_id` field at all for bot users without
an owner.  The correct behavior would have been send `None` for the
owner field.

The second bug was simply that we needed to update the webapp to look
for the `bot_owner_id` field, rather than an old email-address format
`bot_owner` field.

Thanks to Vinit Singh for reporting this bug.
2019-11-08 15:09:44 -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
Anders Kaseorg d17b577d0c js: Purge useless IIFEs.
With webpack, variables declared in each file are already file-local
(Global variables need to be explicitly exported), so these IIFEs are
no longer needed.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-25 13:51:21 -07:00
Thomas Ip 29803db802 org settings: Make deactivated users list sortable. 2019-08-21 16:50:22 -07:00
Thomas Ip 2eba496968 org settings: Make active users list sortable. 2019-08-21 16:50:22 -07:00
Thomas Ip 444ce74a8e org settings: Make bot list sortable. 2019-08-21 16:50:22 -07:00
Pragati Agrawal 693df05ca7 settings_users: Refactor and extract function for last active.
This just done to improves code readability and removes some code too.
2019-08-15 16:54:28 -07:00
Pragati Agrawal c0c11fe226 settings_users: Refactor logic for "last active" column in users table.
This uses "last_active" attribute of `user` (`item`) object and makes code
much more readable.
2019-08-15 16:54:28 -07:00
Pragati Agrawal a3ef8856a8 settings_users: Add last_active to active_users for "users" table.
This is a preliminary step for refactoring the logic for rendering
"last_active" in the users table and later we can use this for sorting the
column.
2019-08-15 16:54:28 -07:00
Pragati Agrawal ba5564fec7 settings_users: Remove `if` condition for showing current user time stamp.
It seems `presence.presence_info[item.user_id]` works fine for the current
user as well and there is no need to hardcode extra condition for the
current user.
2019-08-15 16:54:28 -07:00
Pragati Agrawal 5b324e50ca users: Apply email_address_visibility policy on the users list.
In the emails-hidden case, for non-admins, we should remove the email
field from "Users" list in the organization settings page.

Tweaked by tabbott to correctly handle the bots and deactivated users pages.
2019-08-02 15:28:36 -07:00
Anders Kaseorg db0b33842c templates: Replace templates.render with require calls.
This removes an unnecessary layer of indirection and allows webpack to
catch filename mistakes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:14 -07:00
Anders Kaseorg 3c3471b720 templates: Rename *.handlebars ↦ *.hbs and - ↦ _.
Tweaked by tabbott to avoid accidentally disabling the linter for
handlebars templates.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:03 -07:00
Yashashvi Dave 6fddc86cf2 org settings: Remove strikethrough from deactivated-user setting.
Remove strickethrough and append text to user role.
2019-07-09 13:07:35 -07:00
Yashashvi Dave 1880075f81 static/js/settings_users: Remove unnecessary function from page load. 2019-07-09 13:07:35 -07:00
Yashashvi Dave 5a3f1e20ec static/js/settings_users: Replace logic with existing function. 2019-07-09 13:07:35 -07:00
Joshua Pan c28c301506 org_settings: Display delivery_email to admins always is admin UI.
Mostly rewritten by Tim Abbott to ensure it correctly implements the
desired security model.

Administrators should have access to users' real email address so that
they can contact users out-of-band.
2019-05-20 18:13:31 -07:00
Anders Kaseorg 01613e71fb ui: Replace set_up_scrollbar with data-simplebar attribute.
With perfectScrollbar, we needed to call a function from JavaScript to
enable a scrollbar on a new element, but simplebar has a much simpler
default API one can do by using data-simplebar attributes in the HTML.

So we can delete all the scrollbar creation/deletion code.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-05-19 18:06:38 -07:00
Hemanth V. Alluri c192327a37 settings_account: Fix small typo in initialize_custom_user_type_fields. 2019-04-25 15:56:44 -07:00
Shubham Dhama 238885ca86 settings_users: Remove meta.current_deactivate_user_modal_row workaround.
The removes meta.current_deactivate_user_modal_row workaround by a more
readable and clear way.
2019-03-20 22:34:57 -07:00
Shubham Dhama 7ab0c26bda settings_users: Refactor some code for deactivate button. 2019-03-20 22:34:57 -07:00
Shubham Dhama 41140f2e46 settings_users: Use update_view_on_deactivate to update deactivate view.
This removes the function update_button_on_success as the action performed
by it can be done by update_view_on_deactivate.
2019-03-20 22:34:57 -07:00
Shubham Dhama f0c069a316 settings_users: Make update_view_on_reactivate function generic.
This also remove:
- meta.current_bot_element: As usage of meta has been wrongly exploited, we
  should refrain us from using meta this way i.e. to share variable between
  function using the global variable, as they reduce code readability.

- update_view_on_deactivate_reactivate_failure: Again to deduplicate the the
  code we're compromising with readability which isn't worth it here, also
  we need to this because we have removed above meta key.
2019-03-20 22:34:57 -07:00
Shubham Dhama 53abbd9408 settings_users: Remove redundant usage of `.user-admin-settings`.
No class with this name exist in codebase.
2019-03-20 22:34:57 -07:00
Shubham Dhama 42d19ababe settings_users: Fix update_view_on_deactivate to take row as an argument.
We should pass row as an argument to update_view_on_deactivate because we
update deactivate view of a row when the user get activated/deactivated by
the event system.

This also removes a redundant data variable.
2019-03-20 22:34:57 -07:00
Shubham Dhama 96aac91119 settings_users: Fix misleading comment.
This fixes a misleading comment as we want to change the view for both bots
    and users, whose active state is changed.
2019-03-20 22:34:57 -07:00
Shubham Dhama 060eacc980 settings_users: Move update_view_on_reactivate up.
This is done just to make code more readable.
2019-03-20 22:34:57 -07:00
Pragati Agrawal 9037ef56dc org_settings: Disable `Deactivate` button for yourself in Users tab.
This disables the Deactivate button for the current user in the Users tab,
so that it becomes hard to deactivae yourself accidently from Users tab.

Fixes #10427.
2019-03-18 22:41:09 -07:00
okmanl ec869f51b9 admin: Display email addresses in user-edit widget.
When the user logs in as an admin, and clicks on the 'edit user'
button under the url path #organization/user-list-admin, the modal
that was displayed didn't contain the user's email address under the
list of information. This commit adds the email input as a readonly
element, which at the very least provides helpful confirmation that
you have the right user.

Fixes part of #11453.
2019-03-04 09:17:05 -08:00
Yashashvi Dave b53857b168 settings: Add admin UI for editing users' custom profile fields.
This commits add UI which will allow admin to edit every user's
custom profile field data from admin settings.

Fixes #10161
2019-01-15 15:34:35 -08:00
Jeswin 03d66abd9e settings: Add success messages for deactivation/reactivation.
This adds the same style of "Saving"/"Saved" loading spinners we use
elsewhere in our settings.

Tweaked significantly by tabbott to fix issues with the notifications
being on the wrong screen for reactiving/deactivating users; this was
done by introducing the get_status_field helper function and using it
everywhere.
2019-01-15 15:05:41 -08:00
Jeswin 17a5d6c1f7 settings: Improve status messages styling on "users" changes.
The legacy "Updated Successfully" message shown after saving changes,
is removed, and replaced with our standard "Saving" spinner and
animation.

Fixes: #11177.
2019-01-15 14:50:17 -08:00
Steve Howell 82e453d9fe ui: Fix scrollbar regressions.
In between releases, the following commit introduced
a bug where we agressively scroll to the top every
place we call `ui.update_scrollbar`:

    092b73d0b7

The main symptoms were that the left and right sidebars
would go to the top for things like selecting a topic,
getting activity updates from the server, and resizing
the window.  It was very jarring.

The recent commit looked innocuous--the root of the problem
was the original API expressed an intent to scroll to the
top, but didn't actually do it, so it was a bug in hiding.

There are **some** occasions where it's actually appropriate
to scroll to the top, mostly around search filtering, and
in those places we now call the new `ui.reset_scrollbar`
function.

This is a bit of an emergency fix, so particularly with
the settings stuff, we may get more reports of glitches here.

The important thing here is that you almost never want to
reset the scrollTop for sidebars.
2019-01-09 09:15:45 -08:00
Tim Abbott bdb3da4504 eslint: Add key-spacing linter rule.
Apparently, we didn't have one of these, and thus had a moderate
number of generally very old violations in the codebase.  Fix this and
clear the ones that exist..
2018-12-18 10:41:06 -08:00
Rishi Gupta ef8113556a settings: Update dropdown in user roles modal. 2018-10-30 10:48:06 -07:00
Pragati Agrawal d5df0377cc settings_users: Support guest user in admin-user-table.
This supports guest user in the user-info-form-modal as well as in the
role section of the admin-user-table.

With some fixes by Tim Abbott and Shubham Dhama.
2018-10-29 12:33:35 -07:00
Pragati Agrawal cc0ac4d340 settings_users: Change "role" column text on updation.
This reflects the newly selected value of role in "role" column under
active-users section and deletes the redundant admin-icon updation code(
As we already removed bolt admin-icon)
2018-10-19 15:51:12 -07:00
Shubham Dhama 4a53560106 settings_users: Change users "Make admin" button to dropdown.
This is done taking "Guest user" into account as we're soon
gonna support that.
2018-08-02 15:55:50 -07:00
Shubham Dhama 338acb1008 settings_users: Change class name for "Save changes" button. 2018-08-02 15:55:50 -07:00
Shubham Dhama 7776fa0d05 settings_user: Move "Make admin" button to user-info-form modal. 2018-08-02 15:55:50 -07:00
Shubham Dhama 4206314184 settings_users: Update admin_icon with admin change event. 2018-08-02 15:55:50 -07:00
Shubham Dhama 5fafddaef5 settings_user: Use `person` as an argument in open_user_info_form_modal. 2018-08-01 10:39:03 -07:00
Shubham Dhama 4186ebe56a settings_user: Don't render bot_owner_select for user list.
This optimize the case when the user-info-form modal is opened
in user-list by not rendering bot_owner_select handlebar.
This bug is before changing form to modal.
2018-07-30 13:48:36 -07:00
Shubham Dhama 8f115c8291 settings_user: Refactor `open-user-form` click handler. 2018-07-30 13:48:36 -07:00
Shubham Dhama 5506f74084 settings_user: Remove redundant verbose check of owner value. 2018-07-30 13:48:36 -07:00
Shubham Dhama e08daf9a00 settings_user: Add modal for user info and roles form.
Advantages of changing it to modal is that now it doesn't render
form for every row i.e. form is rendered only for row edit button
is clicked.
2018-07-30 13:48:36 -07:00
Shubham Dhama 2bcd21aeca org settings: Use people.get_active_human_persons to get active humans. 2018-07-30 13:48:36 -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
Yashashvi Dave 317a2fff2a bots settings: Improve API for editing bot owners to refer to users by ID.
Fixes #9502
2018-06-23 12:47:50 -07:00
Shubham Dhama 2aba7c239f list_render: Make list creation logic as an export in list_render module.
This changes how we create lists i.e.
    from `list_render($container, list, opts)`
        to `list_render.create($container, list, opts)`
2018-06-22 09:21:47 -04:00
Shubham Dhama cc03f9fb8f eslint: Enable space-infix-ops rule.
More about rule at  https://eslint.org/docs/rules/space-infix-ops
2018-06-05 00:47:35 +05:30
Harshit Bansal 6ee32ee512 minor: Add a comment explaining the need of `stopPropagation()`. 2018-05-23 14:07:30 -07:00
Yashashvi Dave 2e6d04797a static/js/settings_users.js: Remove unused function.
Remove function `get_email_for_user_row`. As we already store email
as data-attribute of row, can directly access with .attr() method.
2018-05-18 15:20:43 -07:00
Yashashvi Dave 4162e61f33 /json/users: Replace email with user_id in API to reactivate user. 2018-05-18 15:20:43 -07:00
Yashashvi Dave 06e7e933cc /json/users: Replace email with user_id in API to update/remove users. 2018-05-18 15:20:43 -07:00
Yashashvi Dave d6e2f9fc88 /json/bots: Replace email with user_id in API to update bots. 2018-05-15 16:34:17 -07:00
Yashashvi Dave 80beb51836 edit bot: Fix error on updating no-owner-bots name.
When org admin tries to change only bots name of no-owner-bot,
It update bots name but returns error, "No such bot owner".
Cause frontend pass `null` value in `bot-owner`.
2018-05-15 10:35:19 -07:00
Tim Abbott 7ab8a8e820 js: Fix a bunch of indentation issues found by eslint.
This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
2018-05-06 16:25:02 -07:00
Tim Abbott 3d900a733f settings_users: Fix sending queries to /json/bots endpoint.
Apparently, since 1948cb6a89, we've been
sending requests by an administrator to change a user's name to the
/json/bots endpoint, which would end up changing the "bot owner" of
these objects to some random user.

We fix this by re-splitting the views code.
2018-04-02 18:48:55 -07:00
Shubham Dhama eb0da20b78 settings: Clean up repeating code in error callbacks.
This cleans repeating code in error callback in settings.
We made a generic function in `ui_report.js` which require two
arguments `xhr` and `btn`; we preferred `btn` over `row` as argument
because a row may have more than one buttons.

Fixes: #8788.
2018-03-25 10:40:40 -07:00
YJDave b358fb2c42 org settings: Hide table-list-data until page gets load.
Until page gets load, table lists are empty. Which results in
showing empty-data-text("No data match to search query") in
setting page parallel to loading spinner.

Hide table-list and show loading spniner until
setting page and table-list gets load.
2018-03-07 13:34:50 -08:00
YJDave f46d925208 org settings: Fix issue, loading spinners are not visible.
In org settings, loading spinners are not visible, currently
because their size is very small.

Fix this, by increasing width and height of spinners and
adding spinner text, to make spinners more visible.
Fixes #8502
2018-03-07 13:34:50 -08:00
YJDave 105093e3f4 org settings: Fix bug in edit user-name-form in active user setting.
In active user settings, when user click on user-name-form to edit
user's full name, we don't set any default value for full-name
input field, which results in garbage or falsy value in input field.

Set true value of selected user's full name in input field by default
in user-name-form.
2018-02-21 09:16:45 -08:00
YJDave 4119eb342d org settings: Display error message on top of active user setting page.
Currently, an error message on active user setting is showing at
the row of edited user profile in user-profiles-list-table.
Instead, show error message on top of setting page.

Tweaked by tabbott to also remove the HTML element.
2018-02-21 09:11:53 -08:00
YJDave dc2b505acb org settings: Fix bug in error reporting on active users setting.
In active users setting, an errors occurred on editing user
profiles, are not reported correctly because there is missing
argument in call of ui_report.error() function.
Fix the issue by passing proper arguments in ui_report.error()
function call.
2018-02-21 09:11:46 -08:00
Robert Hönig 4cc8c74aaa frontend: Internally refer to bots by ID.
This is done by using a bot's ID instead of email in
the handler methods for bot_data.bots and bot_data.services,
and updating all code paths involved.
2018-01-23 07:29:00 -05:00
Steve Howell 2b6fee3c53 i18n: Translate deactivation errors in the webapp. 2017-11-07 09:52:20 -08:00
Brock Whittaker 981e6e6836 settings: Display "Never" over "Invalid Date" for inactive users.
This shows the text "Never" for users who are part of a realm but
have never been active, rather than a more vague JavaScript output
of "Invalid Date" due to the fact that their last presence
evaluates to NaN.
2017-10-23 13:57:11 -07:00
Brock Whittaker 5331e52f6d settings: Convert tables to use perfectScrollbar.
This converts tables in the organization section to use
perfectScrollbar.
2017-09-26 22:54:20 -07:00
Tim Abbott eb781de78d settings: Fix buggy use of JavaScript regular expressions.
Using weird characters when filtering options items in these various
settings pages would throw exceptions whenever they didn't form a
valid regular expression.
2017-08-24 18:32:01 -07:00
Abhijeet Kaur 14fdc2aea6 bots: Add 'Bot type' column to bots list in organization settings. 2017-06-20 23:04:46 -04:00
David fcf97660db testing-coverage: add node tests for timerender.js.
Initial set of tests for the timerender.js module.

Fixes #4819.
2017-05-29 08:51:28 -07:00
Brock Whittaker 8c715a79b9 Change admin active users list to render progressively. 2017-05-05 14:14:37 -07:00
Brock Whittaker 1a8a8b6d0c Change admin bots list to render progressively. 2017-05-05 14:14:37 -07:00
Brock Whittaker 6c3606cf36 Change admin deactivated users table to render progressively. 2017-05-05 14:14:37 -07:00
Tim Abbott 03b7be17a6 settings: Fix unnecessary/ugly exclamations in error messages.
The previous code would produce errors of the form "Failed!: ...".
2017-05-01 14:50:20 -07:00
Steve Howell 22e21cddcb admin/settings: Lazy-load Organization sections.
We now wait to load Organization sections until you
click on the section (or virtually click by using arrow
keys).

Some of the sections are coupled in terms of their setup,
so some sections will already be loaded if you had clicked
on a related section.
2017-04-17 20:55:42 -07:00
Abhijeet Kaur 3f0e33e498 Organization settings: "Users" tab view-only support.
This changes the layout of "organization settings" for
non-administrators such that they can view "Users" (Actions are not
visible).
2017-04-16 12:21:30 -07:00
Steve Howell 70afb59cff Extract settings_users.js.
This affects three admin sections:

    * Users
    * Deactivated users
    * Bots
2017-04-13 10:39:39 -07:00