mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 20:41:46 +00:00
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:
@@ -198,26 +198,25 @@ function reset_scrollbar($sel) {
|
|||||||
|
|
||||||
function bot_info(bot_user) {
|
function bot_info(bot_user) {
|
||||||
const info = {};
|
const info = {};
|
||||||
const user = {};
|
|
||||||
|
|
||||||
user.is_bot = true;
|
info.is_bot = true;
|
||||||
user.is_admin = false;
|
info.is_admin = false;
|
||||||
user.is_guest = false;
|
info.is_guest = false;
|
||||||
user.is_active = bot_user.is_active;
|
info.is_active = bot_user.is_active;
|
||||||
user.user_id = bot_user.user_id;
|
info.user_id = bot_user.user_id;
|
||||||
user.full_name = bot_user.full_name;
|
info.full_name = bot_user.full_name;
|
||||||
user.bot_owner_id = bot_user.bot_owner_id;
|
info.bot_owner_id = bot_user.bot_owner_id;
|
||||||
|
|
||||||
// Convert bot type id to string for viewing to the users.
|
// 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);
|
const bot_owner = people.get_bot_owner_user(bot_user);
|
||||||
|
|
||||||
if (bot_owner) {
|
if (bot_owner) {
|
||||||
user.bot_owner_full_name = bot_owner.full_name;
|
info.bot_owner_full_name = bot_owner.full_name;
|
||||||
} else {
|
} else {
|
||||||
user.no_owner = true;
|
info.no_owner = true;
|
||||||
user.bot_owner_full_name = i18n.t("No owner");
|
info.bot_owner_full_name = i18n.t("No owner");
|
||||||
}
|
}
|
||||||
|
|
||||||
info.is_current_user = false;
|
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
|
// It's always safe to show the fake email addresses for bot users
|
||||||
info.display_email = bot_user.email;
|
info.display_email = bot_user.email;
|
||||||
|
|
||||||
// TODO: We want to flatten this.
|
|
||||||
info.user = user;
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,15 +239,14 @@ function get_last_active(user) {
|
|||||||
|
|
||||||
function human_info(person) {
|
function human_info(person) {
|
||||||
const info = {};
|
const info = {};
|
||||||
const user = {};
|
|
||||||
|
|
||||||
user.is_bot = false;
|
info.is_bot = false;
|
||||||
user.is_admin = person.is_admin;
|
info.is_admin = person.is_admin;
|
||||||
user.is_guest = person.is_guest;
|
info.is_guest = person.is_guest;
|
||||||
user.is_active = person.is_active;
|
info.is_active = person.is_active;
|
||||||
user.user_id = person.user_id;
|
info.user_id = person.user_id;
|
||||||
user.full_name = person.full_name;
|
info.full_name = person.full_name;
|
||||||
user.bot_owner_id = person.bot_owner_id;
|
info.bot_owner_id = person.bot_owner_id;
|
||||||
|
|
||||||
info.can_modify = page_params.is_admin;
|
info.can_modify = page_params.is_admin;
|
||||||
info.is_current_user = people.is_my_user_id(person.user_id);
|
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);
|
info.last_active_date = get_last_active(person);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We want to flatten this.
|
|
||||||
info.user = user;
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
{{#with user}}
|
|
||||||
<tr class="user_row{{#unless is_active}} deactivated_user{{/unless}}" data-user-id="{{user_id}}">
|
<tr class="user_row{{#unless is_active}} deactivated_user{{/unless}}" data-user-id="{{user_id}}">
|
||||||
<td>
|
<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>
|
<i class="fa fa-ban deactivated-user-icon" title="{{t 'User is deactivated' }}" {{#if is_active}}style="display: none;"{{/if}}></i>
|
||||||
</td>
|
</td>
|
||||||
{{#if ../display_email}}
|
{{#if display_email}}
|
||||||
<td>
|
<td>
|
||||||
<span class="email">{{../display_email}}</span>
|
<span class="email">{{display_email}}</span>
|
||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#unless is_bot}}
|
{{#unless is_bot}}
|
||||||
@@ -37,14 +36,14 @@
|
|||||||
</td>
|
</td>
|
||||||
{{else if is_active}}
|
{{else if is_active}}
|
||||||
<td class="last_active">
|
<td class="last_active">
|
||||||
{{ ../last_active_date }}
|
{{ last_active_date }}
|
||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if ../can_modify}}
|
{{#if can_modify}}
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<span class="user-status-settings">
|
<span class="user-status-settings">
|
||||||
{{#if is_active}}
|
{{#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>
|
<i class="fa fa-user-times" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
@@ -59,4 +58,3 @@
|
|||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</tr>
|
</tr>
|
||||||
{{/with}}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user