bots: Disable edit button for system bots.

Disabled "Edit bot" and "Deactivate" action buttons
for system bots as they cannot be edited or deactivated.

Fixes #24425.
This commit is contained in:
Ujjawal Modi 2023-02-26 16:49:08 +05:30 committed by Tim Abbott
parent 6582374178
commit d2db71fdf4
2 changed files with 12 additions and 6 deletions

View File

@ -230,6 +230,8 @@ function bot_info(bot_user_id) {
info.is_current_user = false;
info.can_modify = page_params.is_admin;
info.cannot_deactivate = bot_user.is_system_bot;
info.cannot_edit = bot_user.is_system_bot;
// It's always safe to show the real email addresses for bot users
info.display_email = bot_user.email;

View File

@ -43,13 +43,17 @@
{{#if can_modify}}
<td class="actions">
<span class="user-status-settings">
<button class="button rounded small btn-warning open-user-form" {{#unless is_active}}style="display: none;"{{/unless}} title="{{#if is_bot}}{{t 'Edit bot' }}{{else}}{{t 'Edit user' }}{{/if}}" data-user-id="{{user_id}}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
<span {{#if (and is_bot cannot_edit)}}class="tippy-zulip-tooltip"{{/if}} {{#if (and is_bot cannot_edit)}}data-tippy-content="{{t 'This bot cannot be edited.'}}"{{/if}}>
<button class="button rounded small btn-warning open-user-form" {{#unless is_active}}style="display: none;"{{/unless}} title="{{#if is_bot}}{{#unless cannot_edit}}{{t 'Edit bot' }}{{/unless}}{{else}}{{t 'Edit user' }}{{/if}}" data-user-id="{{user_id}}" {{#if cannot_edit}}disabled="disabled"{{/if}}>
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
</span>
{{#if is_active}}
<button title="{{t 'Deactivate' }}" class="button rounded small deactivate btn-danger" {{#if cannot_deactivate}}disabled="disabled"{{/if}}>
<i class="fa fa-user-times" aria-hidden="true"></i>
</button>
<span {{#if (and is_bot cannot_deactivate)}}class="tippy-zulip-tooltip"{{/if}} {{#if (and is_bot cannot_deactivate)}}data-tippy-content="{{t 'This bot cannot be deactivated.'}}"{{/if}}>
<button title="{{#unless (and is_bot cannot_deactivate) }}{{t 'Deactivate' }}{{/unless}}" class="button rounded small deactivate btn-danger" {{#if cannot_deactivate}}disabled="disabled"{{/if}}>
<i class="fa fa-user-times" aria-hidden="true"></i>
</button>
</span>
{{else}}
<button title="{{t 'Reactivate' }}" class="button rounded small reactivate btn-warning">
<i class="fa fa-user-plus" aria-hidden="true"></i>