discourse/app/assets/javascripts/admin/addon/templates/users-list-show.hbs

365 lines
12 KiB
Handlebars

<AdminPageSubheader @titleLabelTranslated={{this.title}}>
<:actions as |actions|>
{{#if this.canCheckEmails}}
{{#if this.showEmails}}
<actions.Default
@action={{this.toggleEmailVisibility}}
@label="admin.users.hide_emails"
class="admin-users__subheader-hide-emails"
/>
{{else}}
<actions.Default
@action={{this.toggleEmailVisibility}}
@label="admin.users.show_emails"
class="admin-users__subheader-show-emails"
/>
{{/if}}
{{/if}}
</:actions>
</AdminPageSubheader>
<PluginOutlet @name="admin-users-list-show-before" />
<div class="d-admin-filter admin-users-list__controls">
<div class="admin-filter__input-container admin-users-list__search">
<input
class="admin-filter__input"
type="text"
dir="auto"
placeholder={{this.searchHint}}
title={{this.searchHint}}
{{on "input" this.onListFilterChange}}
/>
</div>
{{#if this.displayBulkActions}}
<div class="bulk-actions-dropdown">
<DMenu @autofocus={{true}} @identifier="bulk-select-admin-users-dropdown">
<:trigger>
<span class="d-button-label">
{{i18n "admin.users.bulk_actions.title"}}
</span>
{{dIcon "angle-down"}}
</:trigger>
<:content>
<DropdownMenu as |dropdown|>
<dropdown.item>
<DButton
@translatedLabel={{i18n
"admin.users.bulk_actions.delete.label"
}}
@icon="trash-can"
@action={{this.openBulkDeleteConfirmation}}
class="bulk-delete btn-danger"
/>
</dropdown.item>
</DropdownMenu>
</:content>
</DMenu>
</div>
{{/if}}
</div>
<LoadMore
@selector=".directory-table .directory-table__cell"
@action={{action "loadMore"}}
class="users-list-container"
>
{{#if this.users}}
<ResponsiveTable
@className={{concat-class "users-list" this.query}}
@aria-label={{this.title}}
@style={{html-safe
(concat
"grid-template-columns: minmax(min-content, 2fr) repeat("
(html-safe this.columnCount)
", minmax(min-content, 1fr))"
)
}}
>
<:header>
<div class="directory-table__column-header-wrapper">
<DButton
class="btn-flat bulk-select"
@icon="list-check"
@action={{this.toggleBulkSelect}}
/>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="username"
@labelKey="username"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
class="directory-table__column-header--username"
/>
</div>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="email"
@labelKey="email"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
class={{if
this.showEmails
"directory-table__column-header--email"
"hidden"
}}
/>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="last_emailed"
@labelKey="admin.users.last_emailed"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
/>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="seen"
@labelKey="last_seen"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
/>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="topics_viewed"
@labelKey="admin.user.topics_entered"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
/>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="posts_read"
@labelKey="admin.user.posts_read_count"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
/>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="read_time"
@labelKey="admin.user.time_read"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
/>
<TableHeaderToggle
@onToggle={{this.updateOrder}}
@field="created"
@labelKey="created"
@order={{this.order}}
@asc={{this.asc}}
@automatic={{true}}
/>
<PluginOutlet
@name="admin-users-list-thead-after"
@outletArgs={{hash order=this.order asc=this.asc}}
/>
{{#if this.siteSettings.must_approve_users}}
<div class="directory-table__column-header">{{i18n
"admin.users.approved"
}}</div>
{{/if}}
<div class="directory-table__column-header">&nbsp;</div>
</:header>
<:body>
{{#each this.users as |user|}}
<div
class="user
{{user.selected}}
{{unless user.active 'not-activated'}}
directory-table__row"
data-user-id={{user.id}}
>
<div class="directory-table__cell username">
{{#if this.bulkSelect}}
{{#if user.can_be_deleted}}
<input
type="checkbox"
class="directory-table__cell-bulk-select"
checked={{eq (get this.bulkSelectedUsersMap user.id) 1}}
data-user-id={{user.id}}
{{on "click" (fn this.bulkSelectItemToggle user.id)}}
/>
{{else}}
<DTooltip
@identifier="bulk-delete-unavailable-reason"
@placement="bottom-start"
>
<:trigger>
<input
type="checkbox"
class="directory-table__cell-bulk-select"
disabled={{true}}
/>
</:trigger>
<:content>
{{#if user.admin}}
{{i18n
"admin.users.bulk_actions.admin_cant_be_deleted"
}}
{{else}}
{{i18n
"admin.users.bulk_actions.too_many_or_old_posts"
}}
{{/if}}
</:content>
</DTooltip>
{{/if}}
{{/if}}
<a
class="avatar"
href={{user.path}}
data-user-card={{user.username}}
>
{{avatar user imageSize="small"}}
</a>
<LinkTo @route="adminUser" @model={{user}}>
{{user.username}}
</LinkTo>
{{#if user.staged}}
{{d-icon "far-envelope" title="user.staged"}}
{{/if}}
</div>
<div
class="directory-table__cell email
{{if this.showEmails '' 'hidden'}}"
>
<span class="directory-table__value">
{{~user.email~}}
</span>
</div>
{{#if user.last_emailed_at}}
<div
class="directory-table__cell last-emailed"
title={{raw-date user.last_emailed_at}}
>
<span class="directory-table__label">
<span>{{i18n "admin.users.last_emailed"}}</span>
</span>
<span class="directory-table__value">
{{format-duration user.last_emailed_age}}
</span>
</div>
{{else}}
<div class="directory-table__cell last-emailed">
<span class="directory-table__label">
<span>{{i18n "admin.users.last_emailed"}}</span>
</span>
<span class="directory-table__value">
{{format-duration user.last_emailed_age}}
</span>
</div>
{{/if}}
<div
class="directory-table__cell last-seen"
title={{raw-date user.last_seen_at}}
>
<span class="directory-table__label">
<span>{{i18n "last_seen"}}</span>
</span>
<span class="directory-table__value">
{{format-duration user.last_seen_age}}
</span>
</div>
<div class="directory-table__cell topics-entered">
<span class="directory-table__label">
<span>{{i18n "admin.user.topics_entered"}}</span>
</span>
<span class="directory-table__value">
{{number user.topics_entered}}
</span>
</div>
<div class="directory-table__cell posts-read">
<span class="directory-table__label">
<span>{{i18n "admin.user.posts_read_count"}}</span>
</span>
<span class="directory-table__value">
{{number user.posts_read_count}}
</span>
</div>
<div class="directory-table__cell time-read">
<span class="directory-table__label">
<span>{{i18n "admin.user.time_read"}}</span>
</span>
<span class="directory-table__value">
{{format-duration user.time_read}}
</span>
</div>
<div
class="directory-table__cell created"
title={{raw-date user.created_at}}
>
<span class="directory-table__label">
<span>{{i18n "created"}}</span>
</span>
<span class="directory-table__value">
{{format-duration user.created_at_age}}
</span>
</div>
<PluginOutlet
@name="admin-users-list-td-after"
@outletArgs={{hash user=user query=this.query}}
/>
{{#if this.siteSettings.must_approve_users}}
<div class="directory-table__cell">
<span class="directory-table__label">
<span>{{i18n "admin.users.approved"}}</span>
</span>
<span class="directory-table__value">
{{i18n-yes-no user.approved}}
</span>
</div>
{{/if}}
<div
class={{concat-class
"directory-table__cell"
"user-role"
(if
(not
(or user.admin user.moderator user.second_factor_enabled)
)
"--empty"
)
}}
>
<span class="directory-table__label">
<span>{{i18n "admin.users.status"}}</span>
</span>
<span class="directory-table__value">
{{#if user.admin}}
{{d-icon "shield-halved" title="admin.title"}}
{{/if}}
{{#if user.moderator}}
{{d-icon "shield-halved" title="admin.moderator"}}
{{/if}}
{{#if user.second_factor_enabled}}
{{d-icon "lock" title="admin.user.second_factor_enabled"}}
{{/if}}
</span>
<PluginOutlet
@name="admin-users-list-icon"
@connectorTagName="div"
@outletArgs={{hash user=user query=this.query}}
/>
</div>
</div>
{{/each}}
</:body>
</ResponsiveTable>
{{else if (not this.refreshing)}}
<p>{{i18n "search.no_results"}}</p>
{{/if}}
<ConditionalLoadingSpinner @condition={{this.refreshing}} />
</LoadMore>