From f366c509135bb6f781a2e07d816374abc402fe30 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Wed, 29 May 2019 09:29:53 +0530 Subject: [PATCH] user_info: Add bot owner to the user info popover. This includes all the changes on the frontend side to include the bot owner in the popover. Includes the bot owner name as a link which opens the full profile of the bot owner. For bots without any owner (such as Notification Bot or Welcome Bot) in place of bot owner name, 'System Bot' appears for cross realm bots and 'Bot' for in-realm bots. Fixes #10844. --- static/js/popovers.js | 17 +++++++++++++++++ static/styles/popovers.scss | 9 +++++++++ .../user_info_popover_content.handlebars | 18 +++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/static/js/popovers.js b/static/js/popovers.js index a2ab03fcf3..f4ac5c058e 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -128,6 +128,17 @@ function render_user_info_popover(user, popover_element, is_sender_popover, priv status_text: user_status.get_status_text(user.user_id), }; + if (user.is_bot) { + var is_cross_realm_bot = user.is_cross_realm_bot; + var bot_owner_id = user.bot_owner_id; + if (is_cross_realm_bot) { + args.is_cross_realm_bot = is_cross_realm_bot; + } else if (bot_owner_id) { + var bot_owner = people.get_person_from_user_id(bot_owner_id); + args.bot_owner = bot_owner; + } + } + popover_element.popover({ content: templates.render('user_info_popover_content', args), // TODO: Determine whether `fixed` should be applied @@ -773,6 +784,12 @@ exports.register_click_handlers = function () { }); }); + $('body').on('click', '.bot-owner-name', function (e) { + var user_id = $(e.target).attr('data-bot-owner-id'); + var user = people.get_person_from_user_id(user_id); + exports.show_user_profile(user); + }); + $('body').on('click', '#user-profile-modal #name #edit-button', function () { exports.hide_user_profile(); }); diff --git a/static/styles/popovers.scss b/static/styles/popovers.scss index 21f00dab06..d0a3d00e21 100644 --- a/static/styles/popovers.scss +++ b/static/styles/popovers.scss @@ -136,6 +136,15 @@ ul.remind_me_popover .remind_icon { margin-right: 5px; } +.bot-owner-name { + text-decoration: underline; + + &:hover { + cursor: pointer; + color: rgb(0, 136, 204); + } +} + .user_popover .popover-title { padding: 0; } diff --git a/static/templates/user_info_popover_content.handlebars b/static/templates/user_info_popover_content.handlebars index 9c163dd8f2..ee2f73d8b6 100644 --- a/static/templates/user_info_popover_content.handlebars +++ b/static/templates/user_info_popover_content.handlebars @@ -32,7 +32,23 @@
  • {{ user_time }} {{#tr this}}Local time{{/tr}}
  • {{/if}} -
  • {{ user_type }}
  • + {{#if is_bot}} + {{#if bot_owner}} +
  • {{#tr this}}Owner{{/tr}}: + + {{bot_owner.full_name}} + +
  • + {{else}} + {{#if is_cross_realm_bot}} +
  • {{#tr this}}System bot{{/tr}}
  • + {{else}} +
  • {{#tr this}}Bot{{/tr}}
  • + {{/if}} + {{/if}} + {{else}} +
  • {{ user_type }}
  • + {{/if}} {{#if is_me}}