Adds user and message to flagaction to display in FE.

This commit is contained in:
gaba
2017-03-20 13:38:11 -07:00
parent 9e76ca5d27
commit be2ecf0838
5 changed files with 44 additions and 17 deletions
@@ -320,3 +320,7 @@
.flaggedByLabel {
font-weight: bold;
}
.flaggedReasons {
padding-top: 15px;
}
@@ -45,15 +45,28 @@ const User = props => {
)}
</div>
<div className={styles.flaggedReasons}>
{user.actions.map(
(action, i) => {
return <span key={i}>
{action.id}
{action.reason}
{action.user && action.user.username}
</span>;
}
)}
{ user.action_summaries.map(
(action_sum, i ) => {
return <div key={i}>
<span className={styles.flaggedByLabel}>
{lang.t(`community.${action_sum.reason}`)} ({action_sum.count})
</span>
{user.actions.map(
// find the action by action_sum.reason
(action, j) => {
if (action.reason === action_sum.reason) {
return <p className={styles.flaggedByReason} key={j}>
{action.user && action.user.username}: {action.message ? action.message : 'n/a'}
</p>;
}
return null;
}
)}
</div>;
}
)}
</div>
</div>
<div className={styles.sideActions}>
@@ -9,14 +9,18 @@ query Users ($n: ACTION_TYPE) {
created_at
... on FlagAction {
reason
}
user {
username
message
user {
id
username
}
}
}
action_summaries {
count
reason
... on FlagActionSummary {
reason
}
}
}
}
+9 -3
View File
@@ -1,9 +1,15 @@
const FlagAction = {
// Stored in the metadata, extract and return.
reason({metadata: {reason}}) {
return reason;
}
message({metadata: {message}}) {
return message;
},
reason({group_id}) {
return group_id;
},
user({user_id}, _, {loaders: {Users}}) {
return Users.getByID.load(user_id);
},
};
module.exports = FlagAction;
+1 -1
View File
@@ -31,7 +31,7 @@ type User {
username: String!
# Action summaries against the user.
action_summaries: [FlagActionSummary]
action_summaries: [ActionSummary]
# Actions completed on the parent.
actions: [Action]