Commit Graph

241 Commits

Author SHA1 Message Date
Anders Kaseorg 175dd999ac dropdown_list_widget: Separate setup method from constructor.
This refactoring is required so the next commit can reorder the
constructor.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-27 22:09:10 -07:00
yogesh sirsat c5bb9cb08a settings_users: Confirmation modal for "Reactivate" user.
The implementation closely follows `handle_deactivation()`.

Using the same existing reactivate confirmation modal.

Also, this commit will also lead to open confirmation modal
to reactivate bots in settings > bots, and currently there is no
existing confirmation modal for deactivating bots.

This commit is a follow-up of #21436.
2022-03-24 12:39:12 -07:00
Sahil Batra 630abf57d9 settings: Remove bot from "Active bots" list on changing owners.
On changing bot owner, "delete" event is sent to the previous
owner if previous owner is not an admin. We were ignoring the
"delete" event in webapp previously, but now we update the
bots page in personal settings to delete the bot. Note that
we do not remove the bot from the organization list of bots
currently, since list_widget does not support removing a
row as of now.

In case of previous owner being an admin, the previous owner
receives "update" event and thus the bots list is updated
from that event.

The code for ignoring "delete" event was added in fba2708bbc,
to basically avoid failed lookup for id in the organization
list of bots. I have tested and there cannot be a case of
a failed lookup in the list as per current code for list_widget
module and we are anyways safe after a reload or after closing the
overlay as the list will be updated correctly.

Discussion thread -
https://chat.zulip.org/#narrow/stream/321-settings-system/topic/List.20render.20.2315033

Fixes #20856.
2022-03-22 15:38:43 -07:00
yogesh sirsat 8d40199729 settings_users: Display error inside deactivate user modal.
Currently, when deactivating a user, we have a "Saving..." loading
indicator and any error message displayed in the heading area of the
users table.

Migrate this to instead do the loading indicator and error message
inside the modal, where it's more in context.
2022-03-22 11:14:48 -07:00
yogesh sirsat 0d31781aed popovers: Support reactivating users from user profile popover.
If the target user is deactivated, `Reactivate this user` will be
shown as one of the options in the small user profile popover, where
`Manage this user` would usually be.

We rename `show_manage_user_option` to `can_manage_user` because now
it will also be used as the common condition for whether the current
user has administrative permission to active or deactivate the target
user.

The implementation closely follows the existing deactivation modal.

Fixes #21428.

chat.zulip.org discussion:
design > reactivate user from user popover
2022-03-18 15:19:13 -07:00
yogesh sirsat 84cdf03bb2 settings_users: Help center link in deactivate confirmation modal. 2022-03-18 14:54:01 -07:00
Anders Kaseorg 6aec27e646 js: Fix no-jquery/no-parse-html-literal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 13:16:34 -07:00
Anders Kaseorg f84a2c08d5 js: Prefix jQuery object variable names with $.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-16 12:52:07 -07:00
Anders Kaseorg 513207523c js: Fix various sloppy uses of String#replace.
Prefer a regexp match over using String#replace to strip expected
prefixes and suffixes because (a) it implicitly verifies that the
input has the expected format and (b) it won’t unexpectedly strip from
the middle of the string.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-04 12:26:49 -08:00
Sahil Batra dc478ee091 settings_users: Remove unused code from update_user_data.
Previously, update_user_data was called when deactivating
bots, but it was removed in 58b612a4f0.

Now, update_user_data is only called for 'type="realm", op="update"'
events, but these events are not sent when deactivating or
reactivating a user or bot, so this code is not used.
2022-02-25 14:55:44 -08:00
Sahil Batra 6a64e1c442 settings_users: Call update_view_on_deactivate from server_events_dispatch.
This commit changes the code to call update_view_on_deactivate function
from server_events_dispatch.js on receiving the user/bot remove event
instead of having it repeatedly in the success_continuation method
of click handlers.

We also add check to make sure we return early if the relevant settings
page is not opened yet.
2022-02-25 14:55:44 -08:00
Sahil Batra 9b7dcd11ae settings_users: Pass user_id instead of row to update_view_on_deactivate. 2022-02-25 14:55:44 -08:00
Sahil Batra cec8191bfa popovers: Add option to deactivate user to "Manage user" modal.
This commit adds option to deactivate user to "Manage user" modal.
A modal is opened on clicking the option to confirm the deactivation
and the "Manage user" modal is closed.
The error from the server, if any, is shown in the modal itself
and in case deactivation is done successfully, the modal is closed.

Fixes #18944.
2022-02-24 15:59:58 -08:00
Sahil Batra 0a27c38af7 settings: Pass handle_confirm function as argument to confirm_deactivation.
We pass handle_confirm function as an argument to confirm_deactivation
because we will use confirm_deactivation to deactivate the user from
user-info popover and the popover case will have a different handle_confirm
function (which is called after clicking "Confirm" button of the modal)
since error handling in that case will be different as there will be no
overlay in the background.
2022-02-24 15:59:58 -08:00
Anders Kaseorg b0ce4f1bce docs: Fix many spelling mistakes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-02-07 18:51:06 -08:00
Sahil Batra df58a0740a settings: Show user name in heading of deactivation modal.
We show user name in heading of the deactivation confirmation
modal instead of email, since there can be a case when admin
does not have access to real email and we already show email,
if accessible, in the content of the modal.
2022-01-11 15:42:51 -08:00
Ganesh Pawar c1f639d115 org edit_bot_modal: Fix dropdown styling issue.
This makes use of the existing CSS present for the personal
edit_bot_modal.
2022-01-11 09:15:06 -08:00
Sahil Batra 2eb1f0195d settings: Show only real email in user deactivation modal.
We show email of the user being deactivated only if real email is
accessible and not the fake email generated using user id.
2022-01-04 14:42:19 -08:00
Sahil Batra 1ce869f16c settings_users: Fix comment in bot_info function. 2021-12-07 21:42:24 -08:00
Sahil Batra b23df8dc9b popovers: Add "Manage this user" option to user info popover.
This commit adds "Manage this user" option in the user-info popover
which simply opens the administrative user-info modal.

We show a spinner on submit button in this case as modal
is not closed immediately and thus we need some indicator
to show that the task is in progress. There is no spinner
on submit button in the modal opened from "Users" section
of organization settings.

Error handling for this case is different than when the
modal is opened from "Users" section of organization
settings because there is no overlay in the background
of modal in this case.

In this case, we show error inside the modal and do not
close it and in case the change is completed successfully
we just close the modal without showing any message.

Fixes part of #18944.
2021-12-01 12:13:06 -08:00
Sahil Batra 2836879767 settings: Extract code for opening user-info edit modal into a function. 2021-12-01 12:13:06 -08:00
Sahil Batra 2c70302e19 settings: Change heading of modal used to edit user info.
This commit changes the heading of modal used by admins to
edit user info to "Manage user".
2021-12-01 12:13:06 -08:00
Sahil Batra 2105b5eda8 settings: Add user-id column to bot list. 2021-11-08 18:10:25 -08:00
Sahil Batra 36c1a1f1ee settings: Add user-id column in active and deactivated users list. 2021-11-08 18:10:25 -08:00
Ganesh Pawar 6a07a90499 dialog_widget: Remove the `fade` parameter.
A user wouldn't differentiate between a "normal" modal and a "settings"
modal. If one shows up instantly, one would expect all the others to do
the same. The difference between Bootstrap fade and non-fade is pretty
noticeable (300 ms for fading).

This is a prep commit for the Micromodal migration which will have 120ms
as the animation time which wouldn't feel slow.
2021-10-26 18:20:17 -07:00
Ganesh Pawar e6e601077f dialog_widget: Append dialog_widget to the body element.
We attach the DOM for the modal to the body element
to avoid style interference from other elements and having to choose
a separate parent element for every single dialog_widget.
2021-10-26 18:20:17 -07:00
Ganesh Pawar fe7a1c0722 dialog_widget: Extract out `close_modal()`. 2021-10-22 16:08:26 -07:00
Ganesh Pawar 3051b1afa3 dialog_widget: Use $t_html for html_heading. 2021-10-22 16:08:25 -07:00
Gaurav Pandey 1c1a1e2cad api: Remove encoding of string in update_user endpoint.
* Remove unnecessary json_validator for full_name parameter.
* Update frontend to pass the right parameter.
* Update documentation and note the change.

Fixes #18409.
2021-10-18 19:03:43 -07:00
aryanshridhar 5c2bafc6b0 dropdown_list_widget: Refactor dropdown_list_widget to constructor function.
This is a prep commit for adding the support of Multiselect
dropdown list widget by prototypal inheritance.

The following change actually revamps the dropdown list widget
into a constructor function, due to which the widget is now to
be initialized with the `new` keyword (which adds a property
to __proto__ object that links to the constructor function's
prototype object).

Example-
const foo = new DropdownListWidget({....});

Due to the above change, this commit also modifies the declaration
of dropdown_list_widget across all our instances.
2021-07-29 10:09:03 -07:00
sahil839 711aca3fde settings: Show correct email in user-info form.
This commit fixes the bug of showing custom email to admin in
the user-info form even when email_address_visibility is set
to admins only.

This commit fixes it to show the correct email according to
email_address_visibility values.
2021-07-15 14:26:40 -07:00
sahil839 fd55df9f7c settings: Use dialog_widget for bot-edit form and remove edit_fields_modal.
This commit changes the bot-edit modal to use dialog_widget instead of
edit_fields_modal.

This commit also removes edit_fields_modal module as it is no longer used.
2021-07-14 13:02:26 -07:00
sahil839 0b21ca725e settings: Use dialog_widget for edit-user-info modal.
This commit changes the edit-user-info modal to use
dialog_widget instead of edit_fields_modal.
The edit_fields_modal module will be removed in
further commits to avoid code duplication.
2021-07-14 13:02:26 -07:00
sahil839 dff374a48b frontend: Remove html_submit_button paramter passed to dialog_widget.
We used html_submit_button to pass text to be present in the modal
submit button. There are only two possible options as of now -
"Confirm" and "Save changes" and the correct one can be determined
using is_confirm_modal parameter. So, we remove this paramter for
now and we can add it later if we have more type of modals using
this widget.
2021-07-14 13:02:25 -07:00
sahil839 055d7113f2 confirm_dialog: Rename html_yes_button to html_submit_button.
This commit renames the html_yes_button parameter of confirm
dialog widget to html_submit_button and also all the related
variables in confirm_dialog.js.
This will help in keeping a general name when deduplicating
the code for confirm_dialog and edit_fields_modal.
2021-07-06 15:15:50 -07:00
sahil839 19362f393e edit_fields_modal: Rename modal_body_html and modal_label.
This commit renames modal_body_html and modal_label to
html_body and html_heading respectively. This change
will help us easily deduplicating the confirm_dialog
and edit_fields_modal code.
2021-07-06 15:15:50 -07:00
sahil839 1cb72c77fe settings_users: Rename user-name-form to edit-user-form.
This commit renames user-name-form to edit-user-form as
the modal for which this id is used, is used to edit all
the user properties, not only name.
2021-06-28 22:11:24 -07:00
sahil839 0b8b7c4441 settings: Use edit_fields_modal framework for user-info edit modal.
This commit modifies the user-info edit modal to use newly added
edit_fields_modal framework.

Fixes a part of #18417.
2021-06-24 16:55:23 -07:00
sahil839 3da636a20e settings: Use edit_fields_modal framework for admin bot form.
This commit modifies the modal for editing bot information to
use edit_fields_modal framework.

We also change the id of form element of this modal such that
it makes sense with the actual use of modal and there is no
problem with this change as styling of this modal is not
affected.
2021-06-24 16:55:23 -07:00
aryanshridhar 4549cbe48c settings_users: Move and rename the deactivation_user modal.
Moved `deactivation_user` modal to the `confirm_dialog`
folder within `/static/templates` and renamed the modal to
to `confirm_deactivate_user.hbs` to follow the
common naming convention.
2021-06-21 10:36:35 -07:00
Ganesh Pawar d9d7c55006 user_deactivation: Move modal_parent one level up in the DOM.
The user deactivate button is also present in the "Deactivated users"
tab, a sibling element of the current modal_parent, #admin-user-list.
Adding the confirm_dialog modal to #admin-user-list won't have any
effect in the "Deactivated users" tab.
Move it one level up, i.e. to the parent element of #admin-user-list
and #admin-deactivated-users-list.

Fixes #18928.
2021-06-21 10:22:33 -07:00
Ganesh Pawar 6e4735a4e9 confirm_dialog: Make Bootstrap `fade` class optional.
It would be better to load non-setting modals instantly.

This was previously reverted in
7bfa607d0a due to a rebase conflict.
2021-06-10 12:15:55 -07:00
aryanshridhar 418c40b2ea settings_users: Refactor user_deactivation modal to confirm_dialog module.
The "email" span in the old modal was not used for styling, just to
support updating the field visually.
2021-06-08 17:57:27 -07:00
sahil839 c09e3fd845 settings_users: Directly use role value in sort_role.
There is no need to write a custom function for sorting
the users table by role since role values are according
to hierarchy of roles already.
2021-06-03 18:45:28 -07:00
sahil839 357e3c7135 settings_users: Fix the sorting of owner and admin in users list.
We were not considering the owner role in `sort_role` function
which was leading to improper sorting when sorting the users
list according to role. This commit fixes this bug by considering
role in `sort_role` function.
2021-05-05 09:02:59 -07:00
sahil839 730c0493b3 users: Show user role as 'moderator' in frontend for realm moderators.
This commit modifies the code to show "Moderator" correctly for
realm moderators.

As, we show role using settings_config.user_role_values object and
the same is used for showing options in changing role dropdown, this
commit also adds the moderator option in that dropdown and thus allows
the user to change role to moderator and from moderator to any other
role from frontend.
But the code for live updating page_params.is_moderator and
person.is_moderator will be in further commit.
2021-04-29 15:18:49 -07:00
sahil839 f9503a4681 settings: Use role value directly to set user-role-select dropdown.
Since, we now have role value in the person objects sent from server
we can directly use that to set the value of dropdown used for
changing user role, instead of using multiple if-else conditions
for checking is_admin, is_owner, etc.
2021-04-29 15:18:49 -07:00
sahil839 77499589f9 users: Use role value directly to display user role text in frontend.
Since, we now get role value in person objects sent from server, we
can simply user user_role_map to display role in different places
instead of having multiple if-else conditions to check flags like
is_admin, is_guest, etc.
2021-04-29 15:18:49 -07:00
sahil839 4f354e28eb settings_users: Remove is_admin and is_guest fields from bot_info.
The is_admin and is_guest fields were used only by users and not
bots.
2021-04-29 15:18:49 -07:00
aryanshridhar 8c43c4a9aa template: Move `admin_user_list` template to `settings` folder.
Moved `admin_user_list` template to `/templates/settings/` folder as
earlier, it was inaccurately placed within the `/templates` folder
rather than the `/templates/settings` folder.

Fixes #18227
2021-04-26 09:37:34 -07:00