Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
popovers: Add "Manage this user" option to user info popover.
Sahil Batrab23df8dc9b3c
diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.jsindex beccc14244b..122ec484b40 100644--- a/frontend_tests/node_tests/popovers.js+++ b/frontend_tests/node_tests/popovers.js@@ -199,6 +199,7 @@ test_ui("sender_hover", ({override, mock_template}) => {user_mention_syntax: "@**Alice Smith**",date_joined: undefined,spectator_view: false,+ show_manage_user_option: false,});return "content-html";});diff --git a/static/js/popovers.js b/static/js/popovers.jsindex 3f79b88a6c9..c011e21e421 100644--- a/static/js/popovers.js+++ b/static/js/popovers.js@@ -43,6 +43,7 @@ import * as reminder from "./reminder";import * as resize from "./resize";import * as rows from "./rows";import * as settings_data from "./settings_data";+import * as settings_users from "./settings_users";import * as stream_popover from "./stream_popover";import * as user_groups from "./user_groups";import * as user_status from "./user_status";@@ -243,6 +244,7 @@ function render_user_info_popover(user_mention_syntax: people.get_mention_syntax(user.full_name, user.user_id),date_joined,spectator_view,+ show_manage_user_option: page_params.is_admin && !is_me,};if (user.is_bot) {@@ -1277,6 +1279,12 @@ export function register_click_handlers() {last_scroll = date;});}++ $("body").on("click", ".sidebar-popover-manage-user", (e) => {+ hide_all();+ const user_id = elem_to_user_id($(e.target).parents("ul"));+ settings_users.show_edit_user_info_modal(user_id, true);+ });}export function any_active() {diff --git a/static/js/settings_users.js b/static/js/settings_users.jsindex cbce9b70c5a..48faf27899a 100644--- a/static/js/settings_users.js+++ b/static/js/settings_users.js@@ -514,7 +514,7 @@ function handle_reactivation(tbody, status_field) {});}-export function show_edit_user_info_modal(user_id, status_field) {+export function show_edit_user_info_modal(user_id, from_user_info_popover, status_field) {const person = people.get_by_user_id(user_id);if (!person) {@@ -573,8 +573,23 @@ export function show_edit_user_info_modal(user_id, status_field) {profile_data: JSON.stringify(profile_data),};- settings_ui.do_settings_change(channel.patch, url, data, status_field);- dialog_widget.close_modal();+ if (!from_user_info_popover) {+ settings_ui.do_settings_change(channel.patch, url, data, status_field);+ dialog_widget.close_modal();+ return;+ }++ channel.patch({+ url,+ data,+ success() {+ dialog_widget.close_modal();+ },+ error(xhr) {+ ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $("#dialog_error"));+ dialog_widget.hide_dialog_spinner();+ },+ });}dialog_widget.launch({@@ -582,6 +597,7 @@ export function show_edit_user_info_modal(user_id, status_field) {html_body,on_click: submit_user_details,post_render: set_role_dropdown_and_fields_user_pills,+ loading_spinner: from_user_info_popover,});}@@ -590,7 +606,7 @@ function handle_human_form(tbody, status_field) {e.stopPropagation();e.preventDefault();const user_id = Number.parseInt($(e.currentTarget).attr("data-user-id"), 10);- show_edit_user_info_modal(user_id, status_field);+ show_edit_user_info_modal(user_id, false, status_field);});}diff --git a/static/styles/popovers.css b/static/styles/popovers.cssindex b7384f19561..7e95599c5c3 100644--- a/static/styles/popovers.css+++ b/static/styles/popovers.css@@ -161,6 +161,10 @@ ul {max-height: 200px;overflow-y: auto;}++ &.info_popover_actions i.fa-edit {+ vertical-align: middle;+ }}.user_popover {diff --git a/static/templates/user_info_popover_content.hbs b/static/templates/user_info_popover_content.hbsindex 9ca96bd2e81..8a75bc279cb 100644--- a/static/templates/user_info_popover_content.hbs+++ b/static/templates/user_info_popover_content.hbs@@ -182,5 +182,12 @@</a></li>{{/if}}+ {{#if show_manage_user_option}}+ <li>+ <a tabindex="0" class="sidebar-popover-manage-user">+ <i class="fa fa-edit" aria-hidden="true"></i> {{#tr}}Manage this user{{/tr}}+ </a>+ </li>+ {{/if}}{{/if}}</ul>