aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/overview/users
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-05-24 16:29:01 +0200
committerChocobozzz <me@florianbigard.com>2022-06-08 13:40:40 +0200
commiteaa529528cafcfb291009f9f99d296c81e792899 (patch)
treec8e3562f73312fb331a363e1daeaeb4949cc8448 /client/src/app/+admin/overview/users
parente435cf44c00aba359bf0f265d06bff4841b3f7fe (diff)
downloadPeerTube-eaa529528cafcfb291009f9f99d296c81e792899.tar.gz
PeerTube-eaa529528cafcfb291009f9f99d296c81e792899.tar.zst
PeerTube-eaa529528cafcfb291009f9f99d296c81e792899.zip
Support ICU in TS components
Diffstat (limited to 'client/src/app/+admin/overview/users')
-rw-r--r--client/src/app/+admin/overview/users/user-list/user-list.component.ts47
1 files changed, 36 insertions, 11 deletions
diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.ts
index 9d11bd02e..f7dc22256 100644
--- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts
+++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts
@@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api'
2import { Component, OnInit, ViewChild } from '@angular/core' 2import { Component, OnInit, ViewChild } from '@angular/core'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { AuthService, ConfirmService, LocalStorageService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' 4import { AuthService, ConfirmService, LocalStorageService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
5import { getAPIHost } from '@app/helpers' 5import { prepareIcu, getAPIHost } from '@app/helpers'
6import { AdvancedInputFilter } from '@app/shared/shared-forms' 6import { AdvancedInputFilter } from '@app/shared/shared-forms'
7import { Actor, DropdownAction } from '@app/shared/shared-main' 7import { Actor, DropdownAction } from '@app/shared/shared-main'
8import { AccountMutedStatus, BlocklistService, UserBanModalComponent, UserModerationDisplayType } from '@app/shared/shared-moderation' 8import { AccountMutedStatus, BlocklistService, UserBanModalComponent, UserModerationDisplayType } from '@app/shared/shared-moderation'
@@ -209,13 +209,25 @@ export class UserListComponent extends RestTable implements OnInit {
209 } 209 }
210 210
211 async unbanUsers (users: User[]) { 211 async unbanUsers (users: User[]) {
212 const res = await this.confirmService.confirm($localize`Do you really want to unban ${users.length} users?`, $localize`Unban`) 212 const res = await this.confirmService.confirm(
213 prepareIcu($localize`Do you really want to unban {count, plural, =1 {1 user} other {{count} users}}?`)(
214 { count: users.length },
215 $localize`Do you really want to unban ${users.length} users?`
216 ),
217 $localize`Unban`
218 )
219
213 if (res === false) return 220 if (res === false) return
214 221
215 this.userAdminService.unbanUsers(users) 222 this.userAdminService.unbanUsers(users)
216 .subscribe({ 223 .subscribe({
217 next: () => { 224 next: () => {
218 this.notifier.success($localize`${users.length} users unbanned.`) 225 this.notifier.success(
226 prepareIcu($localize`{count, plural, =1 {1 user} other {{count} users}} unbanned.`)(
227 { count: users.length },
228 $localize`${users.length} users unbanned.`
229 )
230 )
219 this.reloadData() 231 this.reloadData()
220 }, 232 },
221 233
@@ -224,21 +236,28 @@ export class UserListComponent extends RestTable implements OnInit {
224 } 236 }
225 237
226 async removeUsers (users: User[]) { 238 async removeUsers (users: User[]) {
227 for (const user of users) { 239 if (users.some(u => u.username === 'root')) {
228 if (user.username === 'root') { 240 this.notifier.error($localize`You cannot delete root.`)
229 this.notifier.error($localize`You cannot delete root.`) 241 return
230 return
231 }
232 } 242 }
233 243
234 const message = $localize`If you remove these users, you will not be able to create others with the same username!` 244 const message = $localize`<p>You can't create users or channels with a username that already used by a deleted user/channel.</p>` +
245 $localize`It means the following usernames will be permanently deleted and cannot be recovered:` +
246 '<ul>' + users.map(u => '<li>' + u.username + '</li>').join('') + '</ul>'
247
235 const res = await this.confirmService.confirm(message, $localize`Delete`) 248 const res = await this.confirmService.confirm(message, $localize`Delete`)
236 if (res === false) return 249 if (res === false) return
237 250
238 this.userAdminService.removeUser(users) 251 this.userAdminService.removeUser(users)
239 .subscribe({ 252 .subscribe({
240 next: () => { 253 next: () => {
241 this.notifier.success($localize`${users.length} users deleted.`) 254 this.notifier.success(
255 prepareIcu($localize`{count, plural, =1 {1 user} other {{count} users}} deleted.`)(
256 { count: users.length },
257 $localize`${users.length} users deleted.`
258 )
259 )
260
242 this.reloadData() 261 this.reloadData()
243 }, 262 },
244 263
@@ -250,7 +269,13 @@ export class UserListComponent extends RestTable implements OnInit {
250 this.userAdminService.updateUsers(users, { emailVerified: true }) 269 this.userAdminService.updateUsers(users, { emailVerified: true })
251 .subscribe({ 270 .subscribe({
252 next: () => { 271 next: () => {
253 this.notifier.success($localize`${users.length} users email set as verified.`) 272 this.notifier.success(
273 prepareIcu($localize`{count, plural, =1 {1 user} other {{count} users}} email set as verified.`)(
274 { count: users.length },
275 $localize`${users.length} users email set as verified.`
276 )
277 )
278
254 this.reloadData() 279 this.reloadData()
255 }, 280 },
256 281