From 0b75d4645355b58d167836460ac609934ddb4118 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 13 Sep 2019 08:37:12 -0700 Subject: [PATCH] Add Creator flair for post creator / OPs comments - Fixes #275 --- ui/src/components/comment-node.tsx | 9 +++++++++ ui/src/components/comment-nodes.tsx | 2 ++ ui/src/components/post.tsx | 2 ++ ui/src/translations/en.ts | 1 + 4 files changed, 14 insertions(+) diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index a4e398f10..b45f13fcc 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -33,6 +33,7 @@ interface CommentNodeProps { markable?: boolean; moderators: Array; admins: Array; + postCreatorId?: number; } export class CommentNode extends Component { @@ -87,6 +88,9 @@ export class CommentNode extends Component { {this.isAdmin &&
  • #
  • } + {this.isPostCreator && +
  • #
  • + } {(node.comment.banned_from_community || node.comment.banned) &&
  • #
  • } @@ -255,6 +259,7 @@ export class CommentNode extends Component { locked={this.props.locked} moderators={this.props.moderators} admins={this.props.admins} + postCreatorId={this.props.postCreatorId} /> } {/* A collapsed clearfix */} @@ -275,6 +280,10 @@ export class CommentNode extends Component { return this.props.admins && isMod(this.props.admins.map(a => a.id), this.props.node.comment.creator_id); } + get isPostCreator(): boolean { + return this.props.node.comment.creator_id == this.props.postCreatorId; + } + get canMod(): boolean { if (this.props.admins && this.props.moderators) { diff --git a/ui/src/components/comment-nodes.tsx b/ui/src/components/comment-nodes.tsx index fca323e39..1e61c2f04 100644 --- a/ui/src/components/comment-nodes.tsx +++ b/ui/src/components/comment-nodes.tsx @@ -9,6 +9,7 @@ interface CommentNodesProps { nodes: Array; moderators?: Array; admins?: Array; + postCreatorId?: number; noIndent?: boolean; viewOnly?: boolean; locked?: boolean; @@ -31,6 +32,7 @@ export class CommentNodes extends Component )} diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 5047d20b6..07bddd343 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -183,6 +183,7 @@ export class Post extends Component { locked={this.state.post.locked} moderators={this.state.moderators} admins={this.state.admins} + postCreatorId={this.state.post.creator_id} /> )} @@ -256,6 +257,7 @@ export class Post extends Component { locked={this.state.post.locked} moderators={this.state.moderators} admins={this.state.admins} + postCreatorId={this.state.post.creator_id} /> ); diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts index 5ec036713..459e3b79c 100644 --- a/ui/src/translations/en.ts +++ b/ui/src/translations/en.ts @@ -64,6 +64,7 @@ export const en = { save: 'save', unsave: 'unsave', create: 'create', + creator: 'creator', username: 'Username', email_or_username: 'Email or Username', number_of_users:'{{count}} Users',