X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fmoderation%2Fuser-moderation-dropdown.component.ts;h=82f39050e691b2d96d207b046dcafd80dfd36b6a;hb=923ff87da2761fd88a8ca269ac1ef403abb583d2;hp=89f275a04fcd5ef83de3f5c24ea4be980efd5ee5;hpb=51e028a94e79957a4ef6a620b9ef3c956064f05e;p=github%2FChocobozzz%2FPeerTube.git 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 89f275a04..82f39050e 100644 --- a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts @@ -7,21 +7,23 @@ import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core' import { User, UserRight } from '../../../../../shared/models/users' import { Account } from '@app/shared/account/account.model' import { BlocklistService } from '@app/shared/blocklist' -import { ServerConfig } from '@shared/models' +import { ServerConfig, BulkRemoveCommentsOfBody } from '@shared/models' +import { BulkService } from '../bulk/bulk.service' @Component({ selector: 'my-user-moderation-dropdown', templateUrl: './user-moderation-dropdown.component.html' }) export class UserModerationDropdownComponent implements OnInit, OnChanges { - @ViewChild('userBanModal', { static: false }) userBanModal: UserBanModalComponent + @ViewChild('userBanModal') userBanModal: UserBanModalComponent @Input() user: User @Input() account: Account @Input() buttonSize: 'normal' | 'small' = 'normal' - @Input() placement = 'left' + @Input() placement = 'left-top left-bottom auto' @Input() label: string + @Input() container: 'body' | undefined = undefined @Output() userChanged = new EventEmitter() @Output() userDeleted = new EventEmitter() @@ -37,6 +39,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { private serverService: ServerService, private userService: UserService, private blocklistService: BlocklistService, + private bulkService: BulkService, private i18n: I18n ) { } @@ -228,6 +231,21 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { ) } + async bulkRemoveCommentsOf (body: BulkRemoveCommentsOfBody) { + const message = this.i18n('Are you sure you want to remove all the comments of this account?') + const res = await this.confirmService.confirm(message, this.i18n('Delete account comments')) + if (res === false) return + + this.bulkService.removeCommentsOf(body) + .subscribe( + () => { + this.notifier.success(this.i18n('Will remove comments of this account (may take several minutes).')) + }, + + err => this.notifier.error(err.message) + ) + } + getRouterUserEditLink (user: User) { return [ '/admin', 'users', 'update', user.id ] } @@ -244,19 +262,23 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.userActions.push([ { label: this.i18n('Edit user'), + description: this.i18n('Change quota, role, and more.'), linkBuilder: ({ user }) => this.getRouterUserEditLink(user) }, { label: this.i18n('Delete user'), + description: this.i18n('Videos will be deleted, comments will be tombstoned.'), handler: ({ user }) => this.removeUser(user) }, { - label: this.i18n('Ban user'), + label: this.i18n('Ban'), + description: this.i18n('User won\'t be able to login anymore, but videos and comments will be kept as is.'), handler: ({ user }) => this.openBanUserModal(user), isDisplayed: ({ user }) => !user.blocked }, { label: this.i18n('Unban user'), + description: this.i18n('Allow the user to login and create videos/comments again'), handler: ({ user }) => this.unbanUser(user), isDisplayed: ({ user }) => user.blocked }, @@ -274,60 +296,83 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.userActions.push([ { label: this.i18n('Mute this account'), + description: this.i18n('Hide any content from that user for you.'), isDisplayed: ({ account }) => account.mutedByUser === false, handler: ({ account }) => this.blockAccountByUser(account) }, { label: this.i18n('Unmute this account'), + description: this.i18n('Show back content from that user for you.'), isDisplayed: ({ account }) => account.mutedByUser === true, handler: ({ account }) => this.unblockAccountByUser(account) }, { label: this.i18n('Mute the instance'), + description: this.i18n('Hide any content from that instance for you.'), isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === false, handler: ({ account }) => this.blockServerByUser(account.host) }, { label: this.i18n('Unmute the instance'), + description: this.i18n('Show back content from that instance for you.'), isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, handler: ({ account }) => this.unblockServerByUser(account.host) + }, + { + label: this.i18n('Remove comments from your videos'), + description: this.i18n('Remove comments of this account from your videos.'), + handler: ({ account }) => this.bulkRemoveCommentsOf({ accountName: account.nameWithHost, scope: 'my-videos' }) } ]) let instanceActions: DropdownAction<{ user: User, account: Account }>[] = [] - // Instance actions + // Instance actions on account blocklists if (authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) { instanceActions = instanceActions.concat([ { label: this.i18n('Mute this account by your instance'), + description: this.i18n('Hide any content from that user for you, your instance and its users.'), isDisplayed: ({ account }) => account.mutedByInstance === false, handler: ({ account }) => this.blockAccountByInstance(account) }, { label: this.i18n('Unmute this account by your instance'), + description: this.i18n('Show back content from that user for you, your instance and its users.'), isDisplayed: ({ account }) => account.mutedByInstance === true, handler: ({ account }) => this.unblockAccountByInstance(account) } ]) } - // Instance actions + // Instance actions on server blocklists if (authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) { instanceActions = instanceActions.concat([ { label: this.i18n('Mute the instance by your instance'), + description: this.i18n('Hide any content from that instance for you, your instance and its users.'), isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === false, handler: ({ account }) => this.blockServerByInstance(account.host) }, { label: this.i18n('Unmute the instance by your instance'), + description: this.i18n('Show back content from that instance for you, your instance and its users.'), isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, handler: ({ account }) => this.unblockServerByInstance(account.host) } ]) } + if (authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) { + instanceActions = instanceActions.concat([ + { + label: this.i18n('Remove comments from your instance'), + description: this.i18n('Remove comments of this account from your instance.'), + handler: ({ account }) => this.bulkRemoveCommentsOf({ accountName: account.nameWithHost, scope: 'instance' }) + } + ]) + } + if (instanceActions.length !== 0) { this.userActions.push(instanceActions) }