diff options
author | Chocobozzz <me@florianbigard.com> | 2023-04-17 09:21:02 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-04-17 09:21:02 +0200 |
commit | 208c97e111f2610880a588964bb61a03503cfcf6 (patch) | |
tree | 3ec04f25dec1411a284aa6e453d9e2cb460ce373 /client/src/app/+admin | |
parent | 29ccdcb51f069d6a64744ffb216cb00ce4bf2d3d (diff) | |
download | PeerTube-208c97e111f2610880a588964bb61a03503cfcf6.tar.gz PeerTube-208c97e111f2610880a588964bb61a03503cfcf6.tar.zst PeerTube-208c97e111f2610880a588964bb61a03503cfcf6.zip |
Always translate user role
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r-- | client/src/app/+admin/overview/users/user-edit/user-edit.ts | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.ts b/client/src/app/+admin/overview/users/user-edit/user-edit.ts index 1edca7fbf..5d6c6a91e 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-edit.ts | |||
@@ -2,6 +2,7 @@ import { Directive, OnInit } from '@angular/core' | |||
2 | import { ConfigService } from '@app/+admin/config/shared/config.service' | 2 | import { ConfigService } from '@app/+admin/config/shared/config.service' |
3 | import { AuthService, ScreenService, ServerService, User } from '@app/core' | 3 | import { AuthService, ScreenService, ServerService, User } from '@app/core' |
4 | import { FormReactive } from '@app/shared/shared-forms' | 4 | import { FormReactive } from '@app/shared/shared-forms' |
5 | import { peertubeTranslate } from '@shared/core-utils' | ||
5 | import { USER_ROLE_LABELS } from '@shared/core-utils/users' | 6 | import { USER_ROLE_LABELS } from '@shared/core-utils/users' |
6 | import { HTMLServerConfig, UserAdminFlag, UserRole } from '@shared/models' | 7 | import { HTMLServerConfig, UserAdminFlag, UserRole } from '@shared/models' |
7 | import { SelectOptionsItem } from '../../../../../types/select-options-item.model' | 8 | import { SelectOptionsItem } from '../../../../../types/select-options-item.model' |
@@ -25,7 +26,7 @@ export abstract class UserEdit extends FormReactive implements OnInit { | |||
25 | abstract isCreation (): boolean | 26 | abstract isCreation (): boolean |
26 | abstract getFormButtonTitle (): string | 27 | abstract getFormButtonTitle (): string |
27 | 28 | ||
28 | ngOnInit (): void { | 29 | ngOnInit () { |
29 | this.serverConfig = this.serverService.getHTMLConfig() | 30 | this.serverConfig = this.serverService.getHTMLConfig() |
30 | 31 | ||
31 | this.buildRoles() | 32 | this.buildRoles() |
@@ -49,15 +50,18 @@ export abstract class UserEdit extends FormReactive implements OnInit { | |||
49 | buildRoles () { | 50 | buildRoles () { |
50 | const authUser = this.auth.getUser() | 51 | const authUser = this.auth.getUser() |
51 | 52 | ||
52 | if (authUser.role.id === UserRole.ADMINISTRATOR) { | 53 | this.serverService.getServerLocale() |
53 | this.roles = Object.keys(USER_ROLE_LABELS) | 54 | .subscribe(translations => { |
54 | .map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) | 55 | if (authUser.role.id === UserRole.ADMINISTRATOR) { |
55 | return | 56 | this.roles = Object.keys(USER_ROLE_LABELS) |
56 | } | 57 | .map(key => ({ value: key.toString(), label: peertubeTranslate(USER_ROLE_LABELS[key], translations) })) |
57 | 58 | return | |
58 | this.roles = [ | 59 | } |
59 | { value: UserRole.USER.toString(), label: USER_ROLE_LABELS[UserRole.USER] } | 60 | |
60 | ] | 61 | this.roles = [ |
62 | { value: UserRole.USER.toString(), label: peertubeTranslate(USER_ROLE_LABELS[UserRole.USER], translations) } | ||
63 | ] | ||
64 | }) | ||
61 | } | 65 | } |
62 | 66 | ||
63 | displayDangerZone () { | 67 | displayDangerZone () { |