diff options
Diffstat (limited to 'client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts')
-rw-r--r-- | client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts index 0d19565ef..787318c2c 100644 --- a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts | |||
@@ -7,6 +7,16 @@ import { BlocklistService } from './blocklist.service' | |||
7 | import { BulkService } from './bulk.service' | 7 | import { BulkService } from './bulk.service' |
8 | import { UserBanModalComponent } from './user-ban-modal.component' | 8 | import { UserBanModalComponent } from './user-ban-modal.component' |
9 | 9 | ||
10 | export type AccountMutedStatus = | ||
11 | Pick<Account, 'id' | 'nameWithHost' | 'host' | 'userId' | | ||
12 | 'mutedByInstance' | 'mutedByUser' | 'mutedServerByInstance' | 'mutedServerByUser'> | ||
13 | |||
14 | export type UserModerationDisplayType = { | ||
15 | myAccount?: boolean | ||
16 | instanceAccount?: boolean | ||
17 | instanceUser?: boolean | ||
18 | } | ||
19 | |||
10 | @Component({ | 20 | @Component({ |
11 | selector: 'my-user-moderation-dropdown', | 21 | selector: 'my-user-moderation-dropdown', |
12 | templateUrl: './user-moderation-dropdown.component.html' | 22 | templateUrl: './user-moderation-dropdown.component.html' |
@@ -15,8 +25,8 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
15 | @ViewChild('userBanModal') userBanModal: UserBanModalComponent | 25 | @ViewChild('userBanModal') userBanModal: UserBanModalComponent |
16 | 26 | ||
17 | @Input() user: User | 27 | @Input() user: User |
18 | @Input() account: Account | 28 | @Input() account: AccountMutedStatus |
19 | @Input() prependActions: DropdownAction<{ user: User, account: Account }>[] | 29 | @Input() prependActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[] |
20 | 30 | ||
21 | @Input() buttonSize: 'normal' | 'small' = 'normal' | 31 | @Input() buttonSize: 'normal' | 'small' = 'normal' |
22 | @Input() buttonStyled = true | 32 | @Input() buttonStyled = true |
@@ -24,10 +34,16 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
24 | @Input() label: string | 34 | @Input() label: string |
25 | @Input() container: 'body' | undefined = undefined | 35 | @Input() container: 'body' | undefined = undefined |
26 | 36 | ||
37 | @Input() displayOptions: UserModerationDisplayType = { | ||
38 | myAccount: true, | ||
39 | instanceAccount: true, | ||
40 | instanceUser: true | ||
41 | } | ||
42 | |||
27 | @Output() userChanged = new EventEmitter() | 43 | @Output() userChanged = new EventEmitter() |
28 | @Output() userDeleted = new EventEmitter() | 44 | @Output() userDeleted = new EventEmitter() |
29 | 45 | ||
30 | userActions: DropdownAction<{ user: User, account: Account }>[][] = [] | 46 | userActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[][] = [] |
31 | 47 | ||
32 | requiresEmailVerification = false | 48 | requiresEmailVerification = false |
33 | 49 | ||
@@ -111,7 +127,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
111 | }) | 127 | }) |
112 | } | 128 | } |
113 | 129 | ||
114 | blockAccountByUser (account: Account) { | 130 | blockAccountByUser (account: AccountMutedStatus) { |
115 | this.blocklistService.blockAccountByUser(account) | 131 | this.blocklistService.blockAccountByUser(account) |
116 | .subscribe({ | 132 | .subscribe({ |
117 | next: () => { | 133 | next: () => { |
@@ -125,7 +141,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
125 | }) | 141 | }) |
126 | } | 142 | } |
127 | 143 | ||
128 | unblockAccountByUser (account: Account) { | 144 | unblockAccountByUser (account: AccountMutedStatus) { |
129 | this.blocklistService.unblockAccountByUser(account) | 145 | this.blocklistService.unblockAccountByUser(account) |
130 | .subscribe({ | 146 | .subscribe({ |
131 | next: () => { | 147 | next: () => { |
@@ -167,7 +183,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
167 | }) | 183 | }) |
168 | } | 184 | } |
169 | 185 | ||
170 | blockAccountByInstance (account: Account) { | 186 | blockAccountByInstance (account: AccountMutedStatus) { |
171 | this.blocklistService.blockAccountByInstance(account) | 187 | this.blocklistService.blockAccountByInstance(account) |
172 | .subscribe({ | 188 | .subscribe({ |
173 | next: () => { | 189 | next: () => { |
@@ -181,7 +197,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
181 | }) | 197 | }) |
182 | } | 198 | } |
183 | 199 | ||
184 | unblockAccountByInstance (account: Account) { | 200 | unblockAccountByInstance (account: AccountMutedStatus) { |
185 | this.blocklistService.unblockAccountByInstance(account) | 201 | this.blocklistService.unblockAccountByInstance(account) |
186 | .subscribe({ | 202 | .subscribe({ |
187 | next: () => { | 203 | next: () => { |
@@ -246,7 +262,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
246 | return user && this.authService.getUser().id === user.id | 262 | return user && this.authService.getUser().id === user.id |
247 | } | 263 | } |
248 | 264 | ||
249 | private isMyAccount (account: Account) { | 265 | private isMyAccount (account: AccountMutedStatus) { |
250 | return account && this.authService.getUser().account.id === account.id | 266 | return account && this.authService.getUser().account.id === account.id |
251 | } | 267 | } |
252 | 268 | ||
@@ -267,9 +283,9 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
267 | } | 283 | } |
268 | 284 | ||
269 | private buildMyAccountModerationActions () { | 285 | private buildMyAccountModerationActions () { |
270 | if (!this.account || !this.authService.isLoggedIn()) return [] | 286 | if (!this.account || !this.displayOptions.myAccount || !this.authService.isLoggedIn()) return [] |
271 | 287 | ||
272 | const myAccountActions: DropdownAction<{ user: User, account: Account }>[] = [ | 288 | const myAccountActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[] = [ |
273 | { | 289 | { |
274 | label: $localize`My account moderation`, | 290 | label: $localize`My account moderation`, |
275 | class: [ 'red' ], | 291 | class: [ 'red' ], |
@@ -315,9 +331,9 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
315 | 331 | ||
316 | const authUser = this.authService.getUser() | 332 | const authUser = this.authService.getUser() |
317 | 333 | ||
318 | let instanceActions: DropdownAction<{ user: User, account: Account }>[] = [] | 334 | let instanceActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[] = [] |
319 | 335 | ||
320 | if (this.user && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) { | 336 | if (this.user && this.displayOptions.instanceUser && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) { |
321 | instanceActions = instanceActions.concat([ | 337 | instanceActions = instanceActions.concat([ |
322 | { | 338 | { |
323 | label: $localize`Edit user`, | 339 | label: $localize`Edit user`, |
@@ -351,7 +367,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
351 | } | 367 | } |
352 | 368 | ||
353 | // Instance actions on account blocklists | 369 | // Instance actions on account blocklists |
354 | if (this.account && authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) { | 370 | if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) { |
355 | instanceActions = instanceActions.concat([ | 371 | instanceActions = instanceActions.concat([ |
356 | { | 372 | { |
357 | label: $localize`Mute this account`, | 373 | label: $localize`Mute this account`, |
@@ -369,7 +385,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
369 | } | 385 | } |
370 | 386 | ||
371 | // Instance actions on server blocklists | 387 | // Instance actions on server blocklists |
372 | if (this.account && authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) { | 388 | if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) { |
373 | instanceActions = instanceActions.concat([ | 389 | instanceActions = instanceActions.concat([ |
374 | { | 390 | { |
375 | label: $localize`Mute the instance`, | 391 | label: $localize`Mute the instance`, |
@@ -386,7 +402,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
386 | ]) | 402 | ]) |
387 | } | 403 | } |
388 | 404 | ||
389 | if (this.account && authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) { | 405 | if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) { |
390 | instanceActions = instanceActions.concat([ | 406 | instanceActions = instanceActions.concat([ |
391 | { | 407 | { |
392 | label: $localize`Remove comments from your instance`, | 408 | label: $localize`Remove comments from your instance`, |