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.
This commit is contained in:
Vaibhav 2019-05-29 09:29:53 +05:30 committed by Tim Abbott
parent 20d4aa96a9
commit f366c50913
3 changed files with 43 additions and 1 deletions

View File

@ -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();
});

View File

@ -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;
}

View File

@ -32,7 +32,23 @@
<li>{{ user_time }} {{#tr this}}Local time{{/tr}}</li>
{{/if}}
<li>{{ user_type }}</li>
{{#if is_bot}}
{{#if bot_owner}}
<li>{{#tr this}}Owner{{/tr}}:
<span class="bot-owner-name" data-bot-owner-id='{{ bot_owner.user_id }}'>
{{bot_owner.full_name}}
</span>
</li>
{{else}}
{{#if is_cross_realm_bot}}
<li>{{#tr this}}System bot{{/tr}}</li>
{{else}}
<li>{{#tr this}}Bot{{/tr}}</li>
{{/if}}
{{/if}}
{{else}}
<li>{{ user_type }}</li>
{{/if}}
</div>
{{#if is_me}}