aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <chocobozzz@framasoft.org>2019-12-27 10:11:11 +0100
committerChocobozzz <chocobozzz@framasoft.org>2019-12-27 10:11:11 +0100
commit51e028a94e79957a4ef6a620b9ef3c956064f05e (patch)
tree57603f8edfa6b7862ff200f7a70ceb523d4b0d34
parent822c7e610d19e3320519a6ae5c90c01db971f03f (diff)
parentedf1a4e5204189f7c352c007232c2463158aa6d7 (diff)
downloadPeerTube-51e028a94e79957a4ef6a620b9ef3c956064f05e.tar.gz
PeerTube-51e028a94e79957a4ef6a620b9ef3c956064f05e.tar.zst
PeerTube-51e028a94e79957a4ef6a620b9ef3c956064f05e.zip
Merge branch 'comment-user-moderation' into 'develop'
Add user moderation dropdown to comments See merge request framasoft/peertube/PeerTube!27
-rw-r--r--client/src/app/shared/moderation/user-moderation-dropdown.component.html2
-rw-r--r--client/src/app/shared/moderation/user-moderation-dropdown.component.ts10
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.html3
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.scss7
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts35
5 files changed, 47 insertions, 10 deletions
diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.html b/client/src/app/shared/moderation/user-moderation-dropdown.component.html
index 7367a7e59..adb672322 100644
--- a/client/src/app/shared/moderation/user-moderation-dropdown.component.html
+++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.html
@@ -3,6 +3,6 @@
3 3
4 <my-action-dropdown 4 <my-action-dropdown
5 [actions]="userActions" [entry]="{ user: user, account: account }" 5 [actions]="userActions" [entry]="{ user: user, account: account }"
6 [buttonSize]="buttonSize" [placement]="placement" 6 [buttonSize]="buttonSize" [placement]="placement" [label]="label"
7 ></my-action-dropdown> 7 ></my-action-dropdown>
8</ng-container> \ No newline at end of file 8</ng-container> \ No newline at end of file
diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts
index d82dc3d94..89f275a04 100644
--- a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts
+++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts
@@ -21,6 +21,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
21 21
22 @Input() buttonSize: 'normal' | 'small' = 'normal' 22 @Input() buttonSize: 'normal' | 'small' = 'normal'
23 @Input() placement = 'left' 23 @Input() placement = 'left'
24 @Input() label: string
24 25
25 @Output() userChanged = new EventEmitter() 26 @Output() userChanged = new EventEmitter()
26 @Output() userDeleted = new EventEmitter() 27 @Output() userDeleted = new EventEmitter()
@@ -36,7 +37,6 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
36 private serverService: ServerService, 37 private serverService: ServerService,
37 private userService: UserService, 38 private userService: UserService,
38 private blocklistService: BlocklistService, 39 private blocklistService: BlocklistService,
39 private auth: AuthService,
40 private i18n: I18n 40 private i18n: I18n
41 ) { } 41 ) { }
42 42
@@ -243,20 +243,20 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
243 if (this.user && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) { 243 if (this.user && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) {
244 this.userActions.push([ 244 this.userActions.push([
245 { 245 {
246 label: this.i18n('Edit'), 246 label: this.i18n('Edit user'),
247 linkBuilder: ({ user }) => this.getRouterUserEditLink(user) 247 linkBuilder: ({ user }) => this.getRouterUserEditLink(user)
248 }, 248 },
249 { 249 {
250 label: this.i18n('Delete'), 250 label: this.i18n('Delete user'),
251 handler: ({ user }) => this.removeUser(user) 251 handler: ({ user }) => this.removeUser(user)
252 }, 252 },
253 { 253 {
254 label: this.i18n('Ban'), 254 label: this.i18n('Ban user'),
255 handler: ({ user }) => this.openBanUserModal(user), 255 handler: ({ user }) => this.openBanUserModal(user),
256 isDisplayed: ({ user }) => !user.blocked 256 isDisplayed: ({ user }) => !user.blocked
257 }, 257 },
258 { 258 {
259 label: this.i18n('Unban'), 259 label: this.i18n('Unban user'),
260 handler: ({ user }) => this.unbanUser(user), 260 handler: ({ user }) => this.unbanUser(user),
261 isDisplayed: ({ user }) => user.blocked 261 isDisplayed: ({ user }) => user.blocked
262 }, 262 },
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 e26100346..d5aacf107 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
@@ -36,6 +36,9 @@
36 <div class="comment-actions"> 36 <div class="comment-actions">
37 <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div> 37 <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div>
38 <div *ngIf="isRemovableByUser()" (click)="onWantToDelete()" class="comment-action-delete" i18n>Delete</div> 38 <div *ngIf="isRemovableByUser()" (click)="onWantToDelete()" class="comment-action-delete" i18n>Delete</div>
39 <my-user-moderation-dropdown
40 buttonSize="small" [account]="commentAccount" [user]="commentUser" label="Options" placement="bottom-left auto"
41 ></my-user-moderation-dropdown>
39 </div> 42 </div>
40 </ng-container> 43 </ng-container>
41 44
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.scss b/client/src/app/videos/+video-watch/comment/video-comment.component.scss
index c70914f9b..cebb24c12 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.scss
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.scss
@@ -114,6 +114,7 @@
114 margin-bottom: 10px; 114 margin-bottom: 10px;
115 display: flex; 115 display: flex;
116 116
117 ::ng-deep .dropdown-toggle,
117 .comment-action-reply, 118 .comment-action-reply,
118 .comment-action-delete { 119 .comment-action-delete {
119 color: $grey-foreground-color; 120 color: $grey-foreground-color;
@@ -124,6 +125,12 @@
124 color: var(--mainForegroundColor); 125 color: var(--mainForegroundColor);
125 } 126 }
126 } 127 }
128
129 ::ng-deep .action-button {
130 background-color: transparent;
131 padding: 0;
132 font-weight: unset;
133 }
127 } 134 }
128 } 135 }
129 136
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 b2bf3ee1b..0d48f0a82 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,10 +1,14 @@
1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
2import { UserRight } from '../../../../../../shared/models/users' 2import { User, UserRight } from '../../../../../../shared/models/users'
3import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' 3import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
4import { AuthService } from '../../../core/auth' 4import { AuthService } from '@app/core/auth'
5import { Video } from '../../../shared/video/video.model' 5import { AccountService } from '@app/shared/account/account.service'
6import { Video } from '@app/shared/video/video.model'
6import { VideoComment } from './video-comment.model' 7import { VideoComment } from './video-comment.model'
7import { MarkdownService } from '@app/shared/renderer' 8import { MarkdownService } from '@app/shared/renderer'
9import { Account } from '@app/shared/account/account.model'
10import { Notifier } from '@app/core'
11import { UserService } from '@app/shared'
8 12
9@Component({ 13@Component({
10 selector: 'my-video-comment', 14 selector: 'my-video-comment',
@@ -28,9 +32,15 @@ export class VideoCommentComponent implements OnInit, OnChanges {
28 sanitizedCommentHTML = '' 32 sanitizedCommentHTML = ''
29 newParentComments: VideoComment[] = [] 33 newParentComments: VideoComment[] = []
30 34
35 commentAccount: Account
36 commentUser: User
37
31 constructor ( 38 constructor (
32 private markdownService: MarkdownService, 39 private markdownService: MarkdownService,
33 private authService: AuthService 40 private authService: AuthService,
41 private accountService: AccountService,
42 private userService: UserService,
43 private notifier: Notifier
34 ) {} 44 ) {}
35 45
36 get user () { 46 get user () {
@@ -90,9 +100,26 @@ export class VideoCommentComponent implements OnInit, OnChanges {
90 ) 100 )
91 } 101 }
92 102
103 private getUserIfNeeded (account: Account) {
104 if (!account.userId) return
105 if (!this.authService.isLoggedIn()) return
106
107 const user = this.authService.getUser()
108 if (user.hasRight(UserRight.MANAGE_USERS)) {
109 this.userService.getUser(account.userId)
110 .subscribe(
111 user => this.commentUser = user,
112
113 err => this.notifier.error(err.message)
114 )
115 }
116 }
117
93 private async init () { 118 private async init () {
94 const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true) 119 const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true)
95 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html) 120 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html)
96 this.newParentComments = this.parentComments.concat([ this.comment ]) 121 this.newParentComments = this.parentComments.concat([ this.comment ])
122 this.commentAccount = new Account(this.comment.account)
123 this.getUserIfNeeded(this.commentAccount)
97 } 124 }
98} 125}