From 45ae994a442dd21ed630bef95d56559f8cc6029c Mon Sep 17 00:00:00 2001 From: kimsible Date: Fri, 7 Aug 2020 17:49:56 +0200 Subject: Move delete, delete & redraft actions to options --- .../comment/video-comment.component.ts | 36 +++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'client/src/app/+videos/+video-watch/comment/video-comment.component.ts') 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 507132909..c2964d370 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 @@ -115,6 +115,10 @@ export class VideoCommentComponent implements OnInit, OnChanges { return this.comment.account && this.isUserLoggedIn() && this.user.account.id === this.comment.account.id && this.comment.totalReplies === 0 } + isReportableByUser() { + return this.comment.account && this.isUserLoggedIn() && this.comment.isDeleted === false && this.authService.getUser().account.id !== this.comment.account.id + } + switchToDefaultAvatar ($event: Event) { ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() } @@ -146,14 +150,30 @@ export class VideoCommentComponent implements OnInit, OnChanges { this.comment.account = null } - if (this.isUserLoggedIn() && this.comment.isDeleted === false && this.authService.getUser().account.id !== this.comment.account.id) { - this.prependModerationActions = [ - { - label: $localize`Report comment`, - handler: () => this.showReportModal() - } - ] - } else { + this.prependModerationActions = [] + + if (this.isReportableByUser()) { + this.prependModerationActions.push({ + label: $localize`Report comment`, + handler: () => this.showReportModal() + }) + } + + if (this.isRemovableByUser()) { + this.prependModerationActions.push({ + label: $localize`Remove comment`, + handler: () => this.onWantToDelete() + }) + } + + if (this.isRedraftableByUser()) { + this.prependModerationActions.push({ + label: $localize`Remove & re-draft comment`, + handler: () => this.onWantToRedraft() + }) + } + + if (this.prependModerationActions.length === 0) { this.prependModerationActions = undefined } } -- cgit v1.2.3