mirror of https://github.com/zulip/zulip.git
user settings: Flatten template data.
We now no longer have to remember that `is_guest` is on `user` but `is_current_user` is in `..`. And we no longer have to remember that `full_name` is on `user` but `display_email` is in `..`.
This commit is contained in:
parent
71c2bde665
commit
2df183142c
|
@ -198,26 +198,25 @@ function reset_scrollbar($sel) {
|
|||
|
||||
function bot_info(bot_user) {
|
||||
const info = {};
|
||||
const user = {};
|
||||
|
||||
user.is_bot = true;
|
||||
user.is_admin = false;
|
||||
user.is_guest = false;
|
||||
user.is_active = bot_user.is_active;
|
||||
user.user_id = bot_user.user_id;
|
||||
user.full_name = bot_user.full_name;
|
||||
user.bot_owner_id = bot_user.bot_owner_id;
|
||||
info.is_bot = true;
|
||||
info.is_admin = false;
|
||||
info.is_guest = false;
|
||||
info.is_active = bot_user.is_active;
|
||||
info.user_id = bot_user.user_id;
|
||||
info.full_name = bot_user.full_name;
|
||||
info.bot_owner_id = bot_user.bot_owner_id;
|
||||
|
||||
// Convert bot type id to string for viewing to the users.
|
||||
user.bot_type = settings_bots.type_id_to_string(bot_user.bot_type);
|
||||
info.bot_type = settings_bots.type_id_to_string(bot_user.bot_type);
|
||||
|
||||
const bot_owner = people.get_bot_owner_user(bot_user);
|
||||
|
||||
if (bot_owner) {
|
||||
user.bot_owner_full_name = bot_owner.full_name;
|
||||
info.bot_owner_full_name = bot_owner.full_name;
|
||||
} else {
|
||||
user.no_owner = true;
|
||||
user.bot_owner_full_name = i18n.t("No owner");
|
||||
info.no_owner = true;
|
||||
info.bot_owner_full_name = i18n.t("No owner");
|
||||
}
|
||||
|
||||
info.is_current_user = false;
|
||||
|
@ -226,9 +225,6 @@ function bot_info(bot_user) {
|
|||
// It's always safe to show the fake email addresses for bot users
|
||||
info.display_email = bot_user.email;
|
||||
|
||||
// TODO: We want to flatten this.
|
||||
info.user = user;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -243,15 +239,14 @@ function get_last_active(user) {
|
|||
|
||||
function human_info(person) {
|
||||
const info = {};
|
||||
const user = {};
|
||||
|
||||
user.is_bot = false;
|
||||
user.is_admin = person.is_admin;
|
||||
user.is_guest = person.is_guest;
|
||||
user.is_active = person.is_active;
|
||||
user.user_id = person.user_id;
|
||||
user.full_name = person.full_name;
|
||||
user.bot_owner_id = person.bot_owner_id;
|
||||
info.is_bot = false;
|
||||
info.is_admin = person.is_admin;
|
||||
info.is_guest = person.is_guest;
|
||||
info.is_active = person.is_active;
|
||||
info.user_id = person.user_id;
|
||||
info.full_name = person.full_name;
|
||||
info.bot_owner_id = person.bot_owner_id;
|
||||
|
||||
info.can_modify = page_params.is_admin;
|
||||
info.is_current_user = people.is_my_user_id(person.user_id);
|
||||
|
@ -264,9 +259,6 @@ function human_info(person) {
|
|||
info.last_active_date = get_last_active(person);
|
||||
}
|
||||
|
||||
// TODO: We want to flatten this.
|
||||
info.user = user;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
{{#with user}}
|
||||
<tr class="user_row{{#unless is_active}} deactivated_user{{/unless}}" data-user-id="{{user_id}}">
|
||||
<td>
|
||||
<span class="user_name" >{{full_name}} {{#if ../is_current_user}}<span class="my_user_status">{{t '(you)' }}</span>{{/if}}</span>
|
||||
<span class="user_name" >{{full_name}} {{#if is_current_user}}<span class="my_user_status">{{t '(you)' }}</span>{{/if}}</span>
|
||||
<i class="fa fa-ban deactivated-user-icon" title="{{t 'User is deactivated' }}" {{#if is_active}}style="display: none;"{{/if}}></i>
|
||||
</td>
|
||||
{{#if ../display_email}}
|
||||
{{#if display_email}}
|
||||
<td>
|
||||
<span class="email">{{../display_email}}</span>
|
||||
<span class="email">{{display_email}}</span>
|
||||
</td>
|
||||
{{/if}}
|
||||
{{#unless is_bot}}
|
||||
|
@ -37,14 +36,14 @@
|
|||
</td>
|
||||
{{else if is_active}}
|
||||
<td class="last_active">
|
||||
{{ ../last_active_date }}
|
||||
{{ last_active_date }}
|
||||
</td>
|
||||
{{/if}}
|
||||
{{#if ../can_modify}}
|
||||
{{#if can_modify}}
|
||||
<td class="actions">
|
||||
<span class="user-status-settings">
|
||||
{{#if is_active}}
|
||||
<button title="{{t 'Deactivate' }}" class="button rounded small deactivate btn-danger" {{#if ../is_current_user}}disabled="disabled"{{/if}}>
|
||||
<button title="{{t 'Deactivate' }}" class="button rounded small deactivate btn-danger" {{#if is_current_user}}disabled="disabled"{{/if}}>
|
||||
<i class="fa fa-user-times" aria-hidden="true"></i>
|
||||
</button>
|
||||
{{else}}
|
||||
|
@ -59,4 +58,3 @@
|
|||
</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/with}}
|
||||
|
|
Loading…
Reference in New Issue