-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/report-modals/comment-report.component'
+import { VideoComment, VideoCommentThreadTree } from '@app/shared/shared-video-comment'
+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'
@Component({
selector: 'my-video-comment',
styleUrls: ['./video-comment.component.scss']
})
export class VideoCommentComponent implements OnInit, OnChanges {
+ @ViewChild('commentReportModal') commentReportModal: CommentReportComponent
+
@Input() video: Video
@Input() comment: VideoComment
@Input() parentComments: VideoComment[] = []
@Output() resetReply = new EventEmitter()
@Output() timestampClicked = new EventEmitter<number>()
+ prependModerationActions: DropdownAction<any>[]
+
sanitizedCommentHTML = ''
newParentComments: VideoComment[] = []
commentUser: User
constructor (
+ private i18n: I18n,
private markdownService: MarkdownService,
private authService: AuthService,
private userService: UserService,
} else {
this.comment.account = null
}
+
+ if (this.isUserLoggedIn() && this.authService.getUser().account.id !== this.comment.account.id) {
+ this.prependModerationActions = [
+ {
+ label: this.i18n('Report comment'),
+ handler: () => this.showReportModal()
+ }
+ ]
+ } else {
+ this.prependModerationActions = undefined
+ }
+ }
+
+ private showReportModal () {
+ this.commentReportModal.show()
}
}