import { BulkService } from './bulk.service'
import { UserBanModalComponent } from './user-ban-modal.component'
+export type AccountMutedStatus =
+ Pick<Account, 'id' | 'nameWithHost' | 'host' | 'userId' |
+ 'mutedByInstance' | 'mutedByUser' | 'mutedServerByInstance' | 'mutedServerByUser'>
+
+export type UserModerationDisplayType = {
+ myAccount?: boolean
+ instanceAccount?: boolean
+ instanceUser?: boolean
+}
+
@Component({
selector: 'my-user-moderation-dropdown',
templateUrl: './user-moderation-dropdown.component.html'
@ViewChild('userBanModal') userBanModal: UserBanModalComponent
@Input() user: User
- @Input() account: Account
- @Input() prependActions: DropdownAction<{ user: User, account: Account }>[]
+ @Input() account: AccountMutedStatus
+ @Input() prependActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[]
@Input() buttonSize: 'normal' | 'small' = 'normal'
@Input() buttonStyled = true
@Input() label: string
@Input() container: 'body' | undefined = undefined
+ @Input() displayOptions: UserModerationDisplayType = {
+ myAccount: true,
+ instanceAccount: true,
+ instanceUser: true
+ }
+
@Output() userChanged = new EventEmitter()
@Output() userDeleted = new EventEmitter()
- userActions: DropdownAction<{ user: User, account: Account }>[][] = []
+ userActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[][] = []
requiresEmailVerification = false
return
}
- const message = $localize`If you remove user ${user.username}, you won't be able to create another with the same username!`
+ // eslint-disable-next-line max-len
+ const message = $localize`If you remove this user, you won't be able to create another user or channel with <strong>${user.username}</strong> username!`
const res = await this.confirmService.confirm(message, $localize`Delete ${user.username}`)
if (res === false) return
})
}
- blockAccountByUser (account: Account) {
+ blockAccountByUser (account: AccountMutedStatus) {
this.blocklistService.blockAccountByUser(account)
.subscribe({
next: () => {
})
}
- unblockAccountByUser (account: Account) {
+ unblockAccountByUser (account: AccountMutedStatus) {
this.blocklistService.unblockAccountByUser(account)
.subscribe({
next: () => {
})
}
- blockAccountByInstance (account: Account) {
+ blockAccountByInstance (account: AccountMutedStatus) {
this.blocklistService.blockAccountByInstance(account)
.subscribe({
next: () => {
})
}
- unblockAccountByInstance (account: Account) {
+ unblockAccountByInstance (account: AccountMutedStatus) {
this.blocklistService.unblockAccountByInstance(account)
.subscribe({
next: () => {
return user && this.authService.getUser().id === user.id
}
- private isMyAccount (account: Account) {
+ private isMyAccount (account: AccountMutedStatus) {
return account && this.authService.getUser().account.id === account.id
}
}
private buildMyAccountModerationActions () {
- if (!this.account || !this.authService.isLoggedIn()) return []
+ if (!this.account || !this.displayOptions.myAccount || !this.authService.isLoggedIn()) return []
- const myAccountActions: DropdownAction<{ user: User, account: Account }>[] = [
+ const myAccountActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[] = [
{
label: $localize`My account moderation`,
class: [ 'red' ],
const authUser = this.authService.getUser()
- let instanceActions: DropdownAction<{ user: User, account: Account }>[] = []
+ let instanceActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[] = []
- if (this.user && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) {
+ if (this.user && this.displayOptions.instanceUser && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) {
instanceActions = instanceActions.concat([
{
label: $localize`Edit user`,
}
// Instance actions on account blocklists
- if (this.account && authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) {
+ if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) {
instanceActions = instanceActions.concat([
{
label: $localize`Mute this account`,
}
// Instance actions on server blocklists
- if (this.account && authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) {
+ if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) {
instanceActions = instanceActions.concat([
{
label: $localize`Mute the instance`,
])
}
- if (this.account && authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) {
+ if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) {
instanceActions = instanceActions.concat([
{
label: $localize`Remove comments from your instance`,