From 8ca56654a176ee8f350d31282c6cac4a59f58499 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 9 Jul 2020 11:58:46 +0200 Subject: Add ability to report comments in front end --- .../comment/video-comment.component.html | 5 ++++ .../comment/video-comment.component.ts | 27 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'client/src/app/+videos/+video-watch/comment') diff --git a/client/src/app/+videos/+video-watch/comment/video-comment.component.html b/client/src/app/+videos/+video-watch/comment/video-comment.component.html index 002de57e4..f02ea549a 100644 --- a/client/src/app/+videos/+video-watch/comment/video-comment.component.html +++ b/client/src/app/+videos/+video-watch/comment/video-comment.component.html @@ -45,6 +45,7 @@
Delete
@@ -93,3 +94,7 @@ + + + + diff --git a/client/src/app/+videos/+video-watch/comment/video-comment.component.ts b/client/src/app/+videos/+video-watch/comment/video-comment.component.ts index 27846c1ad..2a4a6e737 100644 --- a/client/src/app/+videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/+videos/+video-watch/comment/video-comment.component.ts @@ -1,7 +1,10 @@ -import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' + +import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core' import { MarkdownService, Notifier, UserService } from '@app/core' import { AuthService } from '@app/core/auth' -import { Account, Actor, Video } from '@app/shared/shared-main' +import { Account, Actor, DropdownAction, Video } from '@app/shared/shared-main' +import { CommentReportComponent } from '@app/shared/shared-moderation/comment-report.component' +import { I18n } from '@ngx-translate/i18n-polyfill' import { User, UserRight } from '@shared/models' import { VideoCommentThreadTree } from './video-comment-thread-tree.model' import { VideoComment } from './video-comment.model' @@ -12,6 +15,8 @@ import { VideoComment } from './video-comment.model' styleUrls: ['./video-comment.component.scss'] }) export class VideoCommentComponent implements OnInit, OnChanges { + @ViewChild('commentReportModal') commentReportModal: CommentReportComponent + @Input() video: Video @Input() comment: VideoComment @Input() parentComments: VideoComment[] = [] @@ -26,6 +31,8 @@ export class VideoCommentComponent implements OnInit, OnChanges { @Output() resetReply = new EventEmitter() @Output() timestampClicked = new EventEmitter() + prependModerationActions: DropdownAction[] + sanitizedCommentHTML = '' newParentComments: VideoComment[] = [] @@ -33,6 +40,7 @@ export class VideoCommentComponent implements OnInit, OnChanges { commentUser: User constructor ( + private i18n: I18n, private markdownService: MarkdownService, private authService: AuthService, private userService: UserService, @@ -127,5 +135,20 @@ export class VideoCommentComponent implements OnInit, OnChanges { } else { this.comment.account = null } + + if (this.isUserLoggedIn()) { + this.prependModerationActions = [ + { + label: this.i18n('Report comment'), + handler: () => this.showReportModal() + } + ] + } else { + this.prependModerationActions = undefined + } + } + + private showReportModal () { + this.commentReportModal.show() } } -- cgit v1.2.3