Merge pull request #1401 from coralproject/account-history-patches

Account history
This commit is contained in:
Wyatt Johnson
2018-02-23 13:17:07 -07:00
committed by GitHub
11 changed files with 131 additions and 17 deletions
@@ -15,6 +15,10 @@
}
}
.username {
word-break: break-all;
}
.headerRowItem {
color: #595959;
font-weight: bold;
@@ -5,7 +5,10 @@ import styles from './AccountHistory.css';
import cn from 'classnames';
import flatten from 'lodash/flatten';
import orderBy from 'lodash/orderBy';
import has from 'lodash/has';
import moment from 'moment';
import t from 'coral-framework/services/i18n';
import { Icon } from 'coral-ui';
const buildUserHistory = (userState = {}) => {
return orderBy(
@@ -29,31 +32,39 @@ const readableDuration = (startDate, endDate) => {
const durAsHours = dur.asHours().toFixed(0);
return durAsHours > 23
? `${durAsDays} ${durAsDays > 1 ? 'days' : 'day'}`
: `${durAsHours} ${durAsHours > 1 ? 'hours' : 'hour'}`;
? durAsDays > 1
? t('suspenduser.days', durAsDays)
: t('suspenduser.day', durAsDays)
: durAsHours > 1
? t('suspenduser.hours', durAsHours)
: t('suspenduser.hour', durAsHours);
};
const buildActionResponse = (typename, created_at, until, status) => {
switch (typename) {
case 'UsernameStatusHistory':
return `Username ${status}`;
return t('account_history.username_status', status);
case 'BannedStatusHistory':
return status ? 'User banned' : 'Ban removed';
return status
? t('account_history.user_banned')
: t('account_history.ban_removed');
case 'SuspensionStatusHistory':
return until
? `Suspended, ${readableDuration(created_at, until)}`
: 'Suspension removed';
? t('account_history.suspended', readableDuration(created_at, until))
: t('account_history.suspension_removed');
default:
return '-';
}
};
const getModerationValue = (userId, assignedBy = {}) => {
if (assignedBy && userId !== assignedBy.id) {
return assignedBy.username;
}
return 'SYSTEM';
};
const getModerationValue = assignedBy =>
has(assignedBy, 'username') ? (
assignedBy.username
) : (
<span>
<Icon name="computer" /> {t('account_history.system')}
</span>
);
class AccountHistory extends React.Component {
render() {
@@ -68,9 +79,15 @@ class AccountHistory extends React.Component {
'talk-admin-account-history-header-row'
)}
>
<div className={styles.headerRowItem}>Date</div>
<div className={styles.headerRowItem}>Action</div>
<div className={styles.headerRowItem}>Moderation</div>
<div className={styles.headerRowItem}>
{t('account_history.date')}
</div>
<div className={styles.headerRowItem}>
{t('account_history.action')}
</div>
<div className={styles.headerRowItem}>
{t('account_history.taken_by')}
</div>
</div>
{userHistory.map(
({ __typename, created_at, assigned_by, until, status }) => (
@@ -98,10 +115,11 @@ class AccountHistory extends React.Component {
<div
className={cn(
styles.item,
styles.username,
'talk-admin-account-history-row-assigned-by'
)}
>
{getModerationValue(user.id, assigned_by)}
{getModerationValue(assigned_by)}
</div>
</div>
)
+10
View File
@@ -432,6 +432,16 @@ da:
all: "All"
rejected: "Rejected"
account_history: "Account History"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "Denne bruger efterligner"
user_no_comment: "Du har aldrig efterladt en kommentar. Deltag i samtalen"
username_offensive: "Dette brugernavn er stødende"
+10
View File
@@ -431,6 +431,16 @@ de:
all: "Alle"
rejected: "Abgelehnte"
account_history: "Konto-Verlauf"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "Gibt sich für jemand anderen aus"
user_no_comment: "Sie haben noch keinen Kommentar abgegeben. Teilen Sie Ihre Meinung mit uns!"
username_offensive: "Dieser Nutzername ist unangemessen"
+13 -1
View File
@@ -396,6 +396,8 @@ en:
one_hour: "1 hour"
hours: "{0} hours"
days: "{0} days"
hour: "{0} hours"
day: "{0} days"
cancel: "Cancel"
suspend_user: "Suspend User"
email_message_suspend: "Dear {0},\n\nIn accordance with {1}s community guidelines, your account has been temporarily suspended. During the suspension, you will be unable to comment, flag or engage with fellow commenters. Please rejoin the conversation {2}."
@@ -434,6 +436,16 @@ en:
all: "All"
rejected: "Rejected"
account_history: "Account History"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "This user is impersonating"
user_no_comment: "You've never left a comment. Join the conversation!"
username_offensive: "This username is offensive"
@@ -462,4 +474,4 @@ en:
close: "Close this Installer"
admin_sidebar:
view_options: "View Options"
sort_comments: "Sort Comments"
sort_comments: "Sort Comments"
+10
View File
@@ -433,6 +433,16 @@ es:
all: "All"
rejected: "Rejected"
account_history: "Account History"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "Este usuario suplanta a alguien"
user_no_comment: "No has dejado aún ningún comentario. ¡Únete a la conversación!"
username_offensive: "Este nombre de usuario es ofensivo"
+10
View File
@@ -433,6 +433,16 @@ fr:
all: "All"
rejected: "Rejected"
account_history: "Account History"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "Cet utilisateur se fait passer pour quelqu'un d'autre"
user_no_comment: "Vous n'avez jamais laissé de commentaire. Rejoignez la conversation !"
username_offensive: "Ce nom d'utilisateur est offensant"
+10
View File
@@ -432,6 +432,16 @@ nl_NL:
all: "Alle"
rejected: "Afgewezen"
account_history: "Accountgeschiedenis"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "Deze gebruiker imiteert"
user_no_comment: "Je hebt nog niet eerder gereageerd. Laat je mening horen!"
username_offensive: "Dit is een aanstootgevende gebruikersnaam."
+10
View File
@@ -431,6 +431,16 @@ pt_BR:
all: "All"
rejected: "Rejected"
account_history: "Account History"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "Este usuário está representando"
user_no_comment: "Você nunca deixou um comentário. Participe da conversa!"
username_offensive: "Esse nome de usuário é ofensivo"
+10
View File
@@ -433,6 +433,16 @@ zh_CN:
all: "All"
rejected: "Rejected"
account_history: "Account History"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "冒名用户"
user_no_comment: "您未曾发表评论。现在就来加入对话吧!"
username_offensive: "用户名有冒犯性"
+10
View File
@@ -433,6 +433,16 @@ zh_TW:
all: "All"
rejected: "Rejected"
account_history: "Account History"
account_history:
user_banned: "User banned"
ban_removed: "Ban removed"
username_status: "Username {0}"
suspended: "Suspended, {0}"
suspension_removed: "Suspension removed"
system: "System"
date: "Date"
action: "Action"
taken_by: "Taken By"
user_impersonating: "此用戶正在冒充"
user_no_comment: "您尚未評論過。加入對話吧!"
username_offensive: "這個用戶名有冒犯性"