DEV: refactoring admin user index (#6927)

This commit is contained in:
Joffrey JAFFEUX 2019-01-22 16:44:55 +01:00 committed by GitHub
parent 31a700daf8
commit fc710de3ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 376 additions and 283 deletions

View File

@ -3,7 +3,8 @@ import CanCheckEmails from "discourse/mixins/can-check-emails";
import { propertyNotEqual, setting } from "discourse/lib/computed";
import { userPath } from "discourse/lib/url";
import { popupAjaxError } from "discourse/lib/ajax-error";
import computed from "ember-addons/ember-computed-decorators";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { fmt } from "discourse/lib/computed";
export default Ember.Controller.extend(CanCheckEmails, {
adminTools: Ember.inject.service(),
@ -64,24 +65,22 @@ export default Ember.Controller.extend(CanCheckEmails, {
.join(", ");
},
userFields: function() {
const siteUserFields = this.site.get("user_fields"),
userFields = this.get("model.user_fields");
@computed("model.user_fields.[]")
userFields(userFields) {
const siteUserFields = this.site.get("user_fields");
if (!Ember.isEmpty(siteUserFields)) {
return siteUserFields.map(function(uf) {
let value = userFields ? userFields[uf.get("id").toString()] : null;
return { name: uf.get("name"), value: value };
return siteUserFields.map(uf => {
const value = userFields ? userFields[uf.get("id").toString()] : null;
return { name: uf.get("name"), value };
});
}
return [];
}.property("model.user_fields.[]"),
@computed("model.username_lower")
preferencesPath(username) {
return userPath(`${username}/preferences`);
return [];
},
preferencesPath: fmt("model.username_lower", "%@/preferences"),
@computed("model.can_delete_all_posts", "model.staff", "model.post_count")
deleteAllPostsExplanation(canDeleteAllPosts, staff, postCount) {
if (canDeleteAllPosts) {
@ -120,9 +119,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
groupAdded(added) {
this.get("model")
.groupAdded(added)
.catch(function() {
bootbox.alert(I18n.t("generic_error"));
});
.catch(() => bootbox.alert(I18n.t("generic_error")));
},
groupRemoved(groupId) {
@ -133,9 +130,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
this.set("originalPrimaryGroupId", null);
}
})
.catch(function() {
bootbox.alert(I18n.t("generic_error"));
});
.catch(() => bootbox.alert(I18n.t("generic_error")));
},
actions: {
@ -201,13 +196,11 @@ export default Ember.Controller.extend(CanCheckEmails, {
},
clearPenaltyHistory() {
let user = this.get("model");
return ajax(`/admin/users/${user.get("id")}/penalty_history`, {
type: "DELETE"
})
.then(() => {
user.set("tl3_requirements.penalty_counts.total", 0);
})
const user = this.get("model");
const path = `/admin/users/${user.get("id")}/penalty_history`;
return ajax(path, { type: "DELETE" })
.then(() => user.set("tl3_requirements.penalty_counts.total", 0))
.catch(popupAjaxError);
},
@ -225,7 +218,6 @@ export default Ember.Controller.extend(CanCheckEmails, {
target_user: this.get("model.username")
});
},
showFlagsReceived() {
this.get("adminTools").showFlagsReceived(this.get("model"));
},
@ -245,10 +237,9 @@ export default Ember.Controller.extend(CanCheckEmails, {
const oldUsername = this.get("model.username");
this.set("model.username", newUsername);
return ajax(`/users/${oldUsername.toLowerCase()}/preferences/username`, {
data: { new_username: newUsername },
type: "PUT"
})
const path = `/users/${oldUsername.toLowerCase()}/preferences/username`;
return ajax(path, { data: { new_username: newUsername }, type: "PUT" })
.catch(e => {
this.set("model.username", oldUsername);
popupAjaxError(e);
@ -260,13 +251,9 @@ export default Ember.Controller.extend(CanCheckEmails, {
const oldName = this.get("model.name");
this.set("model.name", newName);
return ajax(
userPath(`${this.get("model.username").toLowerCase()}.json`),
{
data: { name: newName },
type: "PUT"
}
)
const path = userPath(`${this.get("model.username").toLowerCase()}.json`);
return ajax(path, { data: { name: newName }, type: "PUT" })
.catch(e => {
this.set("model.name", oldName);
popupAjaxError(e);
@ -276,15 +263,11 @@ export default Ember.Controller.extend(CanCheckEmails, {
saveTitle(newTitle) {
const oldTitle = this.get("model.title");
this.set("model.title", newTitle);
return ajax(
userPath(`${this.get("model.username").toLowerCase()}.json`),
{
data: { title: newTitle },
type: "PUT"
}
)
const path = userPath(`${this.get("model.username").toLowerCase()}.json`);
return ajax(path, { data: { title: newTitle }, type: "PUT" })
.catch(e => {
this.set("model.title", oldTitle);
popupAjaxError(e);
@ -303,9 +286,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
bufferedIds
.filter(id => !currentIds.includes(id))
.forEach(id => {
this.groupAdded(availableGroups.findBy("id", id));
});
.forEach(id => this.groupAdded(availableGroups.findBy("id", id)));
currentIds
.filter(id => !bufferedIds.includes(id))
@ -317,21 +298,15 @@ export default Ember.Controller.extend(CanCheckEmails, {
},
savePrimaryGroup() {
const self = this;
const primaryGroupId = this.get("model.primary_group_id");
const path = `/admin/users/${this.get("model.id")}/primary_group`;
return ajax("/admin/users/" + this.get("model.id") + "/primary_group", {
return ajax(path, {
type: "PUT",
data: { primary_group_id: this.get("model.primary_group_id") }
data: { primary_group_id: primaryGroupId }
})
.then(function() {
self.set(
"originalPrimaryGroupId",
self.get("model.primary_group_id")
);
})
.catch(function() {
bootbox.alert(I18n.t("generic_error"));
});
.then(() => this.set("originalPrimaryGroupId", primaryGroupId))
.catch(() => bootbox.alert(I18n.t("generic_error")));
},
resetPrimaryGroup() {
@ -339,30 +314,26 @@ export default Ember.Controller.extend(CanCheckEmails, {
},
regenerateApiKey() {
const self = this;
bootbox.confirm(
I18n.t("admin.api.confirm_regen"),
I18n.t("no_value"),
I18n.t("yes_value"),
function(result) {
result => {
if (result) {
self.get("model").generateApiKey();
this.get("model").generateApiKey();
}
}
);
},
revokeApiKey() {
const self = this;
bootbox.confirm(
I18n.t("admin.api.confirm_revoke"),
I18n.t("no_value"),
I18n.t("yes_value"),
function(result) {
result => {
if (result) {
self.get("model").revokeApiKey();
this.get("model").revokeApiKey();
}
}
);

View File

@ -1,58 +1,80 @@
<section class="details {{unless model.active 'not-activated'}}">
<div class='user-controls'>
<div class="user-controls">
{{#if model.canViewProfile}}
{{#link-to 'user' model class="btn btn-default"}}
{{#link-to "user" model class="btn btn-default"}}
{{d-icon "user"}}
{{i18n 'admin.user.show_public_profile'}}
{{i18n "admin.user.show_public_profile"}}
{{/link-to}}
{{/if}}
{{#if model.can_view_action_logs}}
{{d-button action=(action "viewActionLogs") class="btn-default" actionParam=model.username icon="list-alt" label="admin.user.action_logs"}}
{{d-button
action=(action "viewActionLogs")
class="btn-default"
actionParam=model.username
icon="far-list-al"
label="admin.user.action_logs"}}
{{/if}}
{{#if model.active}}
{{#if currentUser.admin}}
{{d-button class="btn-default" action=(action "logOut") icon="power-off" label="admin.user.log_out"}}
{{d-button
class="btn-default"
action=(action "logOut")
icon="power-off"
label="admin.user.log_out"}}
{{/if}}
{{/if}}
{{plugin-outlet name="admin-user-controls-after" args=(hash model=model) tagName="" connectorTagName=""}}
{{plugin-outlet
name="admin-user-controls-after"
args=(hash model=model)
tagName=""
connectorTagName=""}}
</div>
<div class='display-row username'>
{{admin-editable-field name='user.username.title'
<div class="display-row username">
{{admin-editable-field name="user.username.title"
value=model.username
action=(action 'saveUsername')
action=(action "saveUsername")
editing=editingUsername}}
</div>
<div class='display-row'>
{{admin-editable-field name='user.name.title'
<div class="display-row">
{{admin-editable-field name="user.name.title"
value=model.name
action=(action 'saveName')
action=(action "saveName")
editing=editingName}}
</div>
{{plugin-outlet name="admin-user-below-names" args=(hash user=model) tagName='' connectorTagName=''}}
{{plugin-outlet
name="admin-user-below-names"
args=(hash user=model)
tagName=""
connectorTagName=""}}
{{#if canCheckEmails}}
<div class='display-row email'>
<div class='field'>{{i18n 'user.email.primary'}}</div>
<div class='value'>
<div class="display-row email">
<div class="field">{{i18n "user.email.primary"}}</div>
<div class="value">
{{#unless model.active}}
<div class='controls'>{{i18n 'admin.users.not_verified'}}</div>
<div class="controls">{{i18n "admin.users.not_verified"}}</div>
{{/unless}}
{{#if model.email}}
<a href="mailto:{{unbound model.email}}">{{model.email}}</a>
{{else}}
{{d-button class="btn-default" action=(route-action "checkEmail") actionParam=model icon="envelope-o" label="admin.users.check_email.text" title="admin.users.check_email.title"}}
{{d-button
class="btn-default"
action=(route-action "checkEmail")
actionParam=model icon="far-envelope"
label="admin.users.check_email.text"
title="admin.users.check_email.title"}}
{{/if}}
</div>
</div>
<div class='display-row secondary-emails'>
<div class='field'>{{i18n 'user.email.secondary'}}</div>
<div class="display-row secondary-emails">
<div class="field">{{i18n "user.email.secondary"}}</div>
<div class='value'>
<div class="value">
{{#if model.email}}
{{#if model.secondary_emails}}
<ul>
@ -61,13 +83,13 @@
{{/each}}
</ul>
{{else}}
{{i18n 'user.email.no_secondary'}}
{{i18n "user.email.no_secondary"}}
{{/if}}
{{else}}
{{d-button action=(route-action "checkEmail")
class="btn-default"
actionParam=model
icon="envelope-o"
icon="far-envelope"
label="admin.users.check_email.text"
title="admin.users.check_email.title"}}
{{/if}}
@ -75,58 +97,70 @@
</div>
<div class="display-row bounce-score">
<div class='field'><a href="{{model.bounceLink}}">{{i18n 'admin.user.bounce_score'}}</a></div>
<div class='value'>{{model.bounceScore}}</div>
<div class='controls'>
<div class="field"><a href="{{model.bounceLink}}">{{i18n "admin.user.bounce_score"}}</a></div>
<div class="value">{{model.bounceScore}}</div>
<div class="controls">
{{#if model.canResetBounceScore}}
{{d-button class="btn-default" action=(action "resetBounceScore") label="admin.user.reset_bounce_score.label" title="admin.user.reset_bounce_score.title"}}
{{d-button
class="btn-default"
action=(action "resetBounceScore")
label="admin.user.reset_bounce_score.label"
title="admin.user.reset_bounce_score.title"}}
{{/if}}
{{model.bounceScoreExplanation}}
</div>
</div>
<div class='display-row associations'>
<div class='field'>{{i18n 'user.associated_accounts.title'}}</div>
<div class='value'>
<div class="display-row associations">
<div class="field">{{i18n "user.associated_accounts.title"}}</div>
<div class="value">
{{#if associatedAccountsLoaded}}
{{associatedAccounts}}
{{else}}
{{d-button class="btn-default" action=(route-action "checkEmail") actionParam=model icon="envelope-o" label="admin.users.check_email.text" title="admin.users.check_email.title"}}
{{d-button
class="btn-default"
action=(route-action "checkEmail")
actionParam=model icon="far-envelope"
label="admin.users.check_email.text"
title="admin.users.check_email.title"}}
{{/if}}
</div>
</div>
{{/if}}
<div class='display-row'>
<div class='field'>{{i18n 'user.avatar.title'}}</div>
<div class='value'>{{avatar model imageSize="large"}}</div>
<div class="display-row">
<div class="field">{{i18n "user.avatar.title"}}</div>
<div class="value">{{avatar model imageSize="large"}}</div>
<div class="controls">
{{{i18n "admin.user.visit_profile" url=preferencesPath}}}
</div>
</div>
<div class='display-row'>
{{admin-editable-field name='user.title.title'
<div class="display-row">
{{admin-editable-field name="user.title.title"
value=model.title
action=(action 'saveTitle')
action=(action "saveTitle")
editing=editingTitle}}
</div>
<div class='display-row last-ip'>
<div class='field'>{{i18n 'user.ip_address.title'}}</div>
<div class='value'>{{model.ip_address}}</div>
<div class='controls'>
<div class="display-row last-ip">
<div class="field">{{i18n "user.ip_address.title"}}</div>
<div class="value">{{model.ip_address}}</div>
<div class="controls">
{{#if currentUser.staff}}
{{d-button class="btn-default" action=(action "refreshBrowsers") label="admin.user.refresh_browsers"}}
{{d-button
class="btn-default"
action=(action "refreshBrowsers")
label="admin.user.refresh_browsers"}}
{{ip-lookup ip=model.ip_address userId=model.id}}
{{/if}}
</div>
</div>
<div class='display-row registration-ip'>
<div class='field'>{{i18n 'user.registration_ip_address.title'}}</div>
<div class='value'>{{model.registration_ip_address}}</div>
<div class='controls'>
<div class="display-row registration-ip">
<div class="field">{{i18n "user.registration_ip_address.title"}}</div>
<div class="value">{{model.registration_ip_address}}</div>
<div class="controls">
{{#if currentUser.staff}}
{{ip-lookup ip=model.registration_ip_address userId=model.id}}
{{/if}}
@ -134,40 +168,47 @@
</div>
{{#if showBadges}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.badges.title'}}</div>
<div class='value'>
{{i18n 'badges.badge_count' count=model.badge_count}}
<div class="display-row">
<div class="field">{{i18n "admin.badges.title"}}</div>
<div class="value">
{{i18n "badges.badge_count" count=model.badge_count}}
</div>
<div class='controls'>
{{#link-to 'adminUser.badges' model class="btn"}}{{d-icon "certificate"}}{{i18n 'admin.badges.edit_badges'}}{{/link-to}}
<div class="controls">
{{#link-to "adminUser.badges" model class="btn"}}
{{d-icon "certificate"}}
{{i18n "admin.badges.edit_badges"}}
{{/link-to}}
</div>
</div>
{{/if}}
<div class='display-row'>
<div class='field'>{{i18n 'user.second_factor.title'}}</div>
<div class='value'>
<div class="display-row">
<div class="field">{{i18n "user.second_factor.title"}}</div>
<div class="value">
{{#if model.second_factor_enabled}}
{{i18n "yes_value"}}
{{else}}
{{i18n "no_value"}}
{{/if}}
</div>
<div class='controls'>
<div class="controls">
{{#if canDisableSecondFactor}}
{{d-button class="btn-default" action=(action "disableSecondFactor") icon="unlock-alt" label="user.second_factor.disable"}}
{{d-button
class="btn-default"
action=(action "disableSecondFactor")
icon="unlock-alt"
label="user.second_factor.disable"}}
{{/if}}
</div>
</div>
</section>
{{#if userFields}}
<section class='details'>
<section class="details">
{{#each userFields as |uf|}}
<div class='display-row'>
<div class='field'>{{uf.name}}</div>
<div class='value'>
<div class="display-row">
<div class="field">{{uf.name}}</div>
<div class="value">
{{#if uf.value}}
{{uf.value}}
{{else}}
@ -181,107 +222,154 @@
{{plugin-outlet name="admin-user-details" args=(hash model=model)}}
<section class='details'>
<h1>{{i18n 'admin.user.permissions'}}</h1>
<section class="details">
<h1>{{i18n "admin.user.permissions"}}</h1>
{{#if showApproval}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.users.approved'}}</div>
<div class='value'>
<div class="display-row">
<div class="field">{{i18n "admin.users.approved"}}</div>
<div class="value">
{{#if model.approved}}
{{i18n 'admin.user.approved_by'}}
{{#link-to 'adminUser' model.approvedBy}}{{avatar model.approvedBy imageSize="small"}}{{/link-to}}
{{#link-to 'adminUser' model.approvedBy}}{{model.approvedBy.username}}{{/link-to}}
{{i18n "admin.user.approved_by"}}
{{#link-to "adminUser" model.approvedBy}}
{{avatar model.approvedBy imageSize="small"}}
{{/link-to}}
{{#link-to "adminUser" model.approvedBy}}
{{model.approvedBy.username}}
{{/link-to}}
{{else}}
{{i18n 'no_value'}}
{{i18n "no_value"}}
{{/if}}
</div>
<div class='controls'>
<div class="controls">
{{#if model.approved}}
{{i18n 'admin.user.approve_success'}}
{{i18n "admin.user.approve_success"}}
{{else}}
{{#if model.can_approve}}
{{d-button class="btn-default" action=(action "approve") icon="check" label="admin.user.approve"}}
{{d-button
class="btn-default"
action=(action "approve")
icon="check"
label="admin.user.approve"}}
{{/if}}
{{/if}}
</div>
</div>
{{/if}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.users.active'}}</div>
<div class='value'>{{i18n-yes-no model.active}}</div>
<div class='controls'>
<div class="display-row">
<div class="field">{{i18n "admin.users.active"}}</div>
<div class="value">{{i18n-yes-no model.active}}</div>
<div class="controls">
{{#if model.active}}
{{#if model.can_deactivate}}
{{d-button class="btn-default" action=(action "deactivate") label="admin.user.deactivate_account"}}
{{i18n 'admin.user.deactivate_explanation'}}
{{d-button
class="btn-default"
action=(action "deactivate")
label="admin.user.deactivate_account"}}
{{i18n "admin.user.deactivate_explanation"}}
{{/if}}
{{else}}
{{#if model.can_send_activation_email}}
{{d-button class="btn-default" action=(action "sendActivationEmail") icon="envelope" label="admin.user.send_activation_email"}}
{{d-button
class="btn-default"
action=(action "sendActivationEmail")
icon="envelope"
label="admin.user.send_activation_email"}}
{{/if}}
{{#if model.can_activate}}
{{d-button class="btn-default" action=(action "activate") icon="check" label="admin.user.activate"}}
{{d-button
class="btn-default"
action=(action "activate")
icon="check"
label="admin.user.activate"}}
{{/if}}
{{/if}}
</div>
</div>
<div class="display-row">
<div class='field'>{{i18n 'admin.user.staged'}}</div>
<div class='value'>{{i18n-yes-no model.staged}}</div>
<div class='controls'>{{i18n 'admin.user.staged_explanation'}}</div>
<div class="field">{{i18n "admin.user.staged"}}</div>
<div class="value">{{i18n-yes-no model.staged}}</div>
<div class="controls">{{i18n "admin.user.staged_explanation"}}</div>
</div>
{{#if currentUser.admin}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.api.key'}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.api.key"}}</div>
{{#if model.api_key}}
<div class='long-value'>
<div class="long-value">
{{model.api_key.key}}
{{d-button class="btn-default" action=(action "regenerateApiKey") icon="undo" label="admin.api.regenerate"}}
{{d-button class="btn-default" action=(action "revokeApiKey") icon="times" label="admin.api.revoke"}}
{{d-button
class="btn-default"
action=(action "regenerateApiKey")
icon="undo"
label="admin.api.regenerate"}}
{{d-button
class="btn-default"
action=(action "revokeApiKey")
icon="times"
label="admin.api.revoke"}}
</div>
{{else}}
<div class='value'>
<div class="value">
&mdash;
</div>
<div class='controls'>
{{d-button class="btn-default" action=(action "generateApiKey") icon="key" label="admin.api.generate"}}
<div class="controls">
{{d-button
class="btn-default"
action=(action "generateApiKey")
icon="key"
label="admin.api.generate"}}
</div>
{{/if}}
</div>
{{/if}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.admin'}}</div>
<div class='value'>{{i18n-yes-no model.admin}}</div>
<div class='controls'>
<div class="display-row">
<div class="field">{{i18n "admin.user.admin"}}</div>
<div class="value">{{i18n-yes-no model.admin}}</div>
<div class="controls">
{{#if model.can_revoke_admin}}
{{d-button class="btn-default" action=(action "revokeAdmin") icon="shield-alt" label="admin.user.revoke_admin"}}
{{d-button
class="btn-default"
action=(action "revokeAdmin")
icon="shield-alt"
label="admin.user.revoke_admin"}}
{{/if}}
{{#if model.can_grant_admin}}
{{d-button class="btn-default" action=(action "grantAdmin") icon="shield-alt" label="admin.user.grant_admin"}}
{{d-button
class="btn-default"
action=(action "grantAdmin")
icon="shield-alt"
label="admin.user.grant_admin"}}
{{/if}}
</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.moderator'}}</div>
<div class='value'>{{i18n-yes-no model.moderator}}</div>
<div class='controls'>
<div class="display-row">
<div class="field">{{i18n "admin.user.moderator"}}</div>
<div class="value">{{i18n-yes-no model.moderator}}</div>
<div class="controls">
{{#if model.can_revoke_moderation}}
{{d-button class="btn-default" action=(action "revokeModeration") icon="shield-alt" label="admin.user.revoke_moderation"}}
{{d-button
class="btn-default"
action=(action "revokeModeration")
icon="shield-alt"
label="admin.user.revoke_moderation"}}
{{/if}}
{{#if model.can_grant_moderation}}
{{d-button class="btn-default" action=(action "grantModeration") icon="shield-alt" label="admin.user.grant_moderation"}}
{{d-button
class="btn-default"
action=(action "grantModeration")
icon="shield-alt"
label="admin.user.grant_moderation"}}
{{/if}}
</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'trust_level'}}</div>
<div class="display-row">
<div class="field">{{i18n "trust_level"}}</div>
<div class="value">
{{combo-box content=site.trustLevels value=model.trust_level nameProperty="detailedName"}}
{{#if model.dirty}}
@ -295,21 +383,31 @@
{{#if model.canLockTrustLevel}}
{{#if hasLockedTrustLevel}}
{{d-icon "lock" title="admin.user.trust_level_locked_tip"}}
{{d-button class="btn-default" action=(action "lockTrustLevel") actionParam=false label="admin.user.unlock_trust_level"}}
{{d-button
class="btn-default"
action=(action "lockTrustLevel")
actionParam=false
label="admin.user.unlock_trust_level"}}
{{else}}
{{d-icon "unlock" title="admin.user.trust_level_unlocked_tip"}}
{{d-button class="btn-default" action=(action "lockTrustLevel") actionParam=true label="admin.user.lock_trust_level"}}
{{d-button
class="btn-default"
action=(action "lockTrustLevel")
actionParam=true
label="admin.user.lock_trust_level"}}
{{/if}}
{{/if}}
{{#if model.tl3Requirements}}
{{#link-to 'adminUser.tl3Requirements' model class="btn btn-default"}}{{i18n 'admin.user.trust_level_3_requirements'}}{{/link-to}}
{{#link-to "adminUser.tl3Requirements" model class="btn btn-default"}}
{{i18n "admin.user.trust_level_3_requirements"}}
{{/link-to}}
{{/if}}
</div>
</div>
<div class="user-suspended display-row {{if model.suspended 'highlight-danger'}}">
<div class='field'>{{i18n 'admin.user.suspended'}}</div>
<div class='value'>
<div class="user-suspended display-row {{if model.suspended "highlight-danger"}}">
<div class="field">{{i18n "admin.user.suspended"}}</div>
<div class="value">
{{i18n-yes-no model.suspended}}
{{#if model.suspended}}
{{#unless model.suspendedForever}}
@ -317,14 +415,14 @@
{{/unless}}
{{/if}}
</div>
<div class='controls'>
<div class="controls">
{{#if model.suspended}}
{{d-button
class="btn-danger unsuspend-user"
action=(action "unsuspend")
icon="ban"
label="admin.user.unsuspend"}}
{{i18n 'admin.user.suspended_explanation'}}
{{i18n "admin.user.suspended_explanation"}}
{{else}}
{{#if model.canSuspend}}
{{d-button
@ -332,29 +430,33 @@
action=(action "showSuspendModal")
icon="ban"
label="admin.user.suspend"}}
{{i18n 'admin.user.suspended_explanation'}}
{{i18n "admin.user.suspended_explanation"}}
{{/if}}
{{/if}}
</div>
</div>
{{#if model.suspended}}
<div class='display-row highlight-danger suspension-info'>
<div class='field'>{{i18n 'admin.user.suspended_by'}}</div>
<div class='value'>
{{#link-to 'adminUser' model.suspendedBy}}{{avatar model.suspendedBy imageSize="tiny"}}{{/link-to}}
{{#link-to 'adminUser' model.suspendedBy}}{{model.suspendedBy.username}}{{/link-to}}
<div class="display-row highlight-danger suspension-info">
<div class="field">{{i18n "admin.user.suspended_by"}}</div>
<div class="value">
{{#link-to "adminUser" model.suspendedBy}}
{{avatar model.suspendedBy imageSize="tiny"}}
{{/link-to}}
{{#link-to "adminUser" model.suspendedBy}}
{{model.suspendedBy.username}}
{{/link-to}}
</div>
<div class='controls'>
<b>{{i18n 'admin.user.suspend_reason'}}</b>:
<div class='full-reason'>{{model.full_suspend_reason}}</div>
<div class="controls">
<b>{{i18n "admin.user.suspend_reason"}}</b>:
<div class="full-reason">{{model.full_suspend_reason}}</div>
</div>
</div>
{{/if}}
<div class="display-row {{if model.silenced 'highlight-danger'}}">
<div class='field'>{{i18n 'admin.user.silenced'}}</div>
<div class='value'>
<div class="display-row {{if model.silenced "highlight-danger"}}">
<div class="field">{{i18n "admin.user.silenced"}}</div>
<div class="value">
{{i18n-yes-no model.silenced}}
{{#if model.silenced}}
{{#unless model.silencedForever}}
@ -362,7 +464,7 @@
{{/unless}}
{{/if}}
</div>
<div class='controls'>
<div class="controls">
{{#conditional-loading-spinner size="small" condition=model.silencingUser}}
{{#if model.silenced}}
{{d-button
@ -370,39 +472,43 @@
action=(action "unsilence")
icon="microphone-slash"
label="admin.user.unsilence"}}
{{i18n 'admin.user.silence_explanation'}}
{{i18n "admin.user.silence_explanation"}}
{{else}}
{{d-button
class="btn-danger silence-user"
action=(action "showSilenceModal")
icon="microphone-slash"
label="admin.user.silence"}}
{{i18n 'admin.user.silence_explanation'}}
{{i18n "admin.user.silence_explanation"}}
{{/if}}
{{/conditional-loading-spinner}}
</div>
</div>
{{#if model.silenced}}
<div class='display-row highlight-danger silence-info'>
<div class='field'>{{i18n 'admin.user.silenced_by'}}</div>
<div class='value'>
{{#link-to 'adminUser' model.silencedBy}}{{avatar model.silencedBy imageSize="tiny"}}{{/link-to}}
{{#link-to 'adminUser' model.silencedBy}}{{model.silencedBy.username}}{{/link-to}}
<div class="display-row highlight-danger silence-info">
<div class="field">{{i18n "admin.user.silenced_by"}}</div>
<div class="value">
{{#link-to "adminUser" model.silencedBy}}
{{avatar model.silencedBy imageSize="tiny"}}
{{/link-to}}
{{#link-to "adminUser" model.silencedBy}}
{{model.silencedBy.username}}
{{/link-to}}
</div>
<div class='controls'>
<b>{{i18n 'admin.user.silence_reason'}}</b>:
<div class='full-reason'>{{model.silence_reason}}</div>
<div class="controls">
<b>{{i18n "admin.user.silence_reason"}}</b>:
<div class="full-reason">{{model.silence_reason}}</div>
</div>
</div>
{{/if}}
{{#if model.tl3_requirements.penalty_counts.total}}
<div class='display-row clear-penalty-history'>
<div class='field'>{{i18n 'admin.user.penalty_count'}}</div>
<div class='value'>{{model.tl3_requirements.penalty_counts.total}}</div>
<div class="display-row clear-penalty-history">
<div class="field">{{i18n "admin.user.penalty_count"}}</div>
<div class="value">{{model.tl3_requirements.penalty_counts.total}}</div>
{{#if currentUser.admin}}
<div class='controls'>
<div class="controls">
{{d-button label="admin.user.clear_penalty_history.title"
class="btn-default"
icon="times"
@ -416,32 +522,38 @@
</section>
{{#if currentUser.admin}}
<section class='details'>
<h1>{{i18n 'admin.groups.title'}}</h1>
<div class='display-row'>
<div class='field'>{{i18n 'admin.groups.automatic'}}</div>
<div class='value'>{{{automaticGroups}}}</div>
<section class="details">
<h1>{{i18n "admin.groups.title"}}</h1>
<div class="display-row">
<div class="field">{{i18n "admin.groups.automatic"}}</div>
<div class="value">{{{automaticGroups}}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.groups.custom'}}</div>
<div class='value'>
{{admin-group-selector selected=model.customGroups available=availableGroups buffer=customGroupIdsBuffer}}
<div class="display-row">
<div class="field">{{i18n "admin.groups.custom"}}</div>
<div class="value">
{{admin-group-selector
selected=model.customGroups
available=availableGroups
buffer=customGroupIdsBuffer}}
</div>
{{#if customGroupsDirty}}
<div class='controls'>
<div class="controls">
{{d-button icon="check" class="ok" action=(action "saveCustomGroups")}}
{{d-button icon="times" class="cancel" action=(action "resetCustomGroups")}}
</div>
{{/if}}
</div>
{{#if model.customGroups}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.groups.primary'}}</div>
<div class='value'>
{{combo-box content=model.customGroups value=model.primary_group_id none="admin.groups.no_primary"}}
<div class="display-row">
<div class="field">{{i18n "admin.groups.primary"}}</div>
<div class="value">
{{combo-box
content=model.customGroups
value=model.primary_group_id
none="admin.groups.no_primary"}}
</div>
{{#if primaryGroupDirty}}
<div class='controls'>
<div class="controls">
{{d-button icon="check" class="ok" action=(action "savePrimaryGroup")}}
{{d-button icon="times" class="cancel" action=(action "resetPrimaryGroup")}}
</div>
@ -451,56 +563,60 @@
</section>
{{/if}}
<section class='details'>
<h1>{{i18n 'admin.user.activity'}}</h1>
<section class="details">
<h1>{{i18n "admin.user.activity"}}</h1>
<div class='display-row'>
<div class='field'>{{i18n 'created'}}</div>
<div class='value'>{{format-date model.created_at leaveAgo="true"}}</div>
<div class="display-row">
<div class="field">{{i18n "created"}}</div>
<div class="value">{{format-date model.created_at leaveAgo="true"}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.users.last_emailed'}}</div>
<div class='value'>{{format-date model.last_emailed_at}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.users.last_emailed"}}</div>
<div class="value">{{format-date model.last_emailed_at}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'last_seen'}}</div>
<div class='value'>{{format-date model.last_seen_at leaveAgo="true"}}</div>
<div class="display-row">
<div class="field">{{i18n "last_seen"}}</div>
<div class="value">{{format-date model.last_seen_at leaveAgo="true"}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.like_count'}}</div>
<div class='value'>{{model.like_given_count}} / {{model.like_count}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.like_count"}}</div>
<div class="value">{{model.like_given_count}} / {{model.like_count}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.topics_entered'}}</div>
<div class='value'>{{model.topics_entered}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.topics_entered"}}</div>
<div class="value">{{model.topics_entered}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.post_count'}}</div>
<div class='value'>{{model.post_count}}</div>
<div class='controls'>
<div class="display-row">
<div class="field">{{i18n "admin.user.post_count"}}</div>
<div class="value">{{model.post_count}}</div>
<div class="controls">
{{#if model.can_delete_all_posts}}
{{#if model.post_count}}
{{d-button class="btn-danger" action=(action "deleteAllPosts") icon="far-trash-alt" label="admin.user.delete_all_posts"}}
{{d-button
class="btn-danger"
action=(action "deleteAllPosts")
icon="far-trash-alt"
label="admin.user.delete_all_posts"}}
{{/if}}
{{else}}
{{deleteAllPostsExplanation}}
{{/if}}
</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.posts_read_count'}}</div>
<div class='value'>{{model.posts_read_count}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.posts_read_count"}}</div>
<div class="value">{{model.posts_read_count}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.warnings_received_count'}}</div>
<div class='value'>{{model.warnings_received_count}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.warnings_received_count"}}</div>
<div class="value">{{model.warnings_received_count}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.flags_given_received_count'}}</div>
<div class='value'>
<div class="display-row">
<div class="field">{{i18n "admin.user.flags_given_received_count"}}</div>
<div class="value">
{{model.flags_given_count}} / {{model.flags_received_count}}
</div>
<div class='controls'>
<div class="controls">
{{#if model.flags_received_count}}
{{d-button
class="btn-default"
@ -511,46 +627,46 @@
{{/if}}
</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.private_topics_count'}}</div>
<div class='value'>{{model.private_topics_count}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.private_topics_count"}}</div>
<div class="value">{{model.private_topics_count}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.time_read'}}</div>
<div class='value'>{{{format-duration model.time_read}}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.time_read"}}</div>
<div class="value">{{{format-duration model.time_read}}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'user.invited.days_visited'}}</div>
<div class='value'>{{{model.days_visited}}}</div>
<div class="display-row">
<div class="field">{{i18n "user.invited.days_visited"}}</div>
<div class="value">{{{model.days_visited}}}</div>
</div>
</section>
{{#if model.single_sign_on_record}}
<section class='details'>
<h1>{{i18n 'admin.user.sso.title'}}</h1>
<section class="details">
<h1>{{i18n "admin.user.sso.title"}}</h1>
{{#with model.single_sign_on_record as |sso|}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.sso.external_id'}}</div>
<div class='value'>{{sso.external_id}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.sso.external_id"}}</div>
<div class="value">{{sso.external_id}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.sso.external_username'}}</div>
<div class='value'>{{sso.external_username}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.sso.external_username"}}</div>
<div class="value">{{sso.external_username}}</div>
</div>
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.sso.external_name'}}</div>
<div class='value'>{{sso.external_name}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.sso.external_name"}}</div>
<div class="value">{{sso.external_name}}</div>
</div>
{{#if sso.external_email}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.sso.external_email'}}</div>
<div class='value'>{{sso.external_email}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.sso.external_email"}}</div>
<div class="value">{{sso.external_email}}</div>
</div>
{{/if}}
<div class='display-row'>
<div class='field'>{{i18n 'admin.user.sso.external_avatar_url'}}</div>
<div class='value'>{{sso.external_avatar_url}}</div>
<div class="display-row">
<div class="field">{{i18n "admin.user.sso.external_avatar_url"}}</div>
<div class="value">{{sso.external_avatar_url}}</div>
</div>
{{/with}}
</section>
@ -563,7 +679,12 @@
<div class="pull-right">
{{#if model.active}}
{{#if model.can_impersonate}}
{{d-button class="btn-danger" action=(action "impersonate") icon="crosshairs" label="admin.impersonate.title" title="admin.impersonate.help"}}
{{d-button
class="btn-danger"
action=(action "impersonate")
icon="crosshairs"
label="admin.impersonate.title"
title="admin.impersonate.help"}}
{{/if}}
{{/if}}
@ -590,4 +711,5 @@
</div>
{{/if}}
</section>
<div class="clearfix"></div>