aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-30 09:59:19 +0200
committerChocobozzz <me@florianbigard.com>2019-07-30 09:59:19 +0200
commita95a4cc89155f448e6f9ca0957170f3c72a9d964 (patch)
treef390fa3eccef0991db5694ef58d6716228a7f67a /client/src/app/+admin
parentdc8902634864841be7ca483b8e1c0f5afa609c32 (diff)
downloadPeerTube-a95a4cc89155f448e6f9ca0957170f3c72a9d964.tar.gz
PeerTube-a95a4cc89155f448e6f9ca0957170f3c72a9d964.tar.zst
PeerTube-a95a4cc89155f448e6f9ca0957170f3c72a9d964.zip
Moderators can only manage users
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/users/user-edit/user-create.component.ts4
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html2
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts20
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts3
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts19
5 files changed, 35 insertions, 13 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts
index 9a6801806..3b57a49c6 100644
--- a/client/src/app/+admin/users/user-edit/user-create.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-create.component.ts
@@ -1,6 +1,6 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router' 2import { Router } from '@angular/router'
3import { Notifier, ServerService } from '@app/core' 3import { AuthService, Notifier, ServerService } from '@app/core'
4import { UserCreate, UserRole } from '../../../../../../shared' 4import { UserCreate, UserRole } from '../../../../../../shared'
5import { UserEdit } from './user-edit' 5import { UserEdit } from './user-edit'
6import { I18n } from '@ngx-translate/i18n-polyfill' 6import { I18n } from '@ngx-translate/i18n-polyfill'
@@ -8,7 +8,6 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
8import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' 8import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
9import { ConfigService } from '@app/+admin/config/shared/config.service' 9import { ConfigService } from '@app/+admin/config/shared/config.service'
10import { UserService } from '@app/shared' 10import { UserService } from '@app/shared'
11import { UserAdminFlag } from '@shared/models/users/user-flag.model'
12 11
13@Component({ 12@Component({
14 selector: 'my-user-create', 13 selector: 'my-user-create',
@@ -22,6 +21,7 @@ export class UserCreateComponent extends UserEdit implements OnInit {
22 protected serverService: ServerService, 21 protected serverService: ServerService,
23 protected formValidatorService: FormValidatorService, 22 protected formValidatorService: FormValidatorService,
24 protected configService: ConfigService, 23 protected configService: ConfigService,
24 protected auth: AuthService,
25 private userValidatorsService: UserValidatorsService, 25 private userValidatorsService: UserValidatorsService,
26 private router: Router, 26 private router: Router,
27 private notifier: Notifier, 27 private notifier: Notifier,
diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.html b/client/src/app/+admin/users/user-edit/user-edit.component.html
index 400bac5d4..cb0f36f05 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.component.html
+++ b/client/src/app/+admin/users/user-edit/user-edit.component.html
@@ -41,7 +41,7 @@
41 <label i18n for="role">Role</label> 41 <label i18n for="role">Role</label>
42 <div class="peertube-select-container"> 42 <div class="peertube-select-container">
43 <select id="role" formControlName="role"> 43 <select id="role" formControlName="role">
44 <option *ngFor="let role of roles" [value]="role.value"> 44 <option *ngFor="let role of getRoles()" [value]="role.value">
45 {{ role.label }} 45 {{ role.label }}
46 </option> 46 </option>
47 </select> 47 </select>
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts
index ee6d2c489..6625d65d6 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -1,22 +1,34 @@
1import { ServerService } from '../../../core' 1import { AuthService, ServerService } from '../../../core'
2import { FormReactive } from '../../../shared' 2import { FormReactive } from '../../../shared'
3import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared' 3import { USER_ROLE_LABELS, UserRole, VideoResolution } from '../../../../../../shared'
4import { ConfigService } from '@app/+admin/config/shared/config.service' 4import { ConfigService } from '@app/+admin/config/shared/config.service'
5import { UserAdminFlag } from '@shared/models/users/user-flag.model' 5import { UserAdminFlag } from '@shared/models/users/user-flag.model'
6 6
7export abstract class UserEdit extends FormReactive { 7export abstract class UserEdit extends FormReactive {
8 videoQuotaOptions: { value: string, label: string }[] = [] 8 videoQuotaOptions: { value: string, label: string }[] = []
9 videoQuotaDailyOptions: { value: string, label: string }[] = [] 9 videoQuotaDailyOptions: { value: string, label: string }[] = []
10 roles = Object.keys(USER_ROLE_LABELS)
11 .map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
12 username: string 10 username: string
13 userId: number 11 userId: number
14 12
15 protected abstract serverService: ServerService 13 protected abstract serverService: ServerService
16 protected abstract configService: ConfigService 14 protected abstract configService: ConfigService
15 protected abstract auth: AuthService
17 abstract isCreation (): boolean 16 abstract isCreation (): boolean
18 abstract getFormButtonTitle (): string 17 abstract getFormButtonTitle (): string
19 18
19 getRoles () {
20 const authUser = this.auth.getUser()
21
22 if (authUser.role === UserRole.ADMINISTRATOR) {
23 return Object.keys(USER_ROLE_LABELS)
24 .map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
25 }
26
27 return [
28 { value: UserRole.USER.toString(), label: USER_ROLE_LABELS[UserRole.USER] }
29 ]
30 }
31
20 isTranscodingInformationDisplayed () { 32 isTranscodingInformationDisplayed () {
21 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10) 33 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
22 34
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts
index 04b2935f4..c7052a925 100644
--- a/client/src/app/+admin/users/user-edit/user-update.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-update.component.ts
@@ -1,7 +1,7 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { Subscription } from 'rxjs' 3import { Subscription } from 'rxjs'
4import { Notifier } from '@app/core' 4import { AuthService, Notifier } from '@app/core'
5import { ServerService } from '../../../core' 5import { ServerService } from '../../../core'
6import { UserEdit } from './user-edit' 6import { UserEdit } from './user-edit'
7import { User, UserUpdate } from '../../../../../../shared' 7import { User, UserUpdate } from '../../../../../../shared'
@@ -29,6 +29,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
29 protected formValidatorService: FormValidatorService, 29 protected formValidatorService: FormValidatorService,
30 protected serverService: ServerService, 30 protected serverService: ServerService,
31 protected configService: ConfigService, 31 protected configService: ConfigService,
32 protected auth: AuthService,
32 private userValidatorsService: UserValidatorsService, 33 private userValidatorsService: UserValidatorsService,
33 private route: ActivatedRoute, 34 private route: ActivatedRoute,
34 private router: Router, 35 private router: Router,
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts
index c9c790689..ab82713b2 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.ts
+++ b/client/src/app/+admin/users/user-list/user-list.component.ts
@@ -1,5 +1,5 @@
1import { Component, OnInit, ViewChild } from '@angular/core' 1import { Component, OnInit, ViewChild } from '@angular/core'
2import { Notifier } from '@app/core' 2import { AuthService, Notifier } from '@app/core'
3import { SortMeta } from 'primeng/components/common/sortmeta' 3import { SortMeta } from 'primeng/components/common/sortmeta'
4import { ConfirmService, ServerService } from '../../../core' 4import { ConfirmService, ServerService } from '../../../core'
5import { RestPagination, RestTable, UserService } from '../../../shared' 5import { RestPagination, RestTable, UserService } from '../../../shared'
@@ -30,11 +30,16 @@ export class UserListComponent extends RestTable implements OnInit {
30 private confirmService: ConfirmService, 30 private confirmService: ConfirmService,
31 private serverService: ServerService, 31 private serverService: ServerService,
32 private userService: UserService, 32 private userService: UserService,
33 private auth: AuthService,
33 private i18n: I18n 34 private i18n: I18n
34 ) { 35 ) {
35 super() 36 super()
36 } 37 }
37 38
39 get authUser () {
40 return this.auth.getUser()
41 }
42
38 get requiresEmailVerification () { 43 get requiresEmailVerification () {
39 return this.serverService.getConfig().signup.requiresEmailVerification 44 return this.serverService.getConfig().signup.requiresEmailVerification
40 } 45 }
@@ -45,22 +50,26 @@ export class UserListComponent extends RestTable implements OnInit {
45 this.bulkUserActions = [ 50 this.bulkUserActions = [
46 { 51 {
47 label: this.i18n('Delete'), 52 label: this.i18n('Delete'),
48 handler: users => this.removeUsers(users) 53 handler: users => this.removeUsers(users),
54 isDisplayed: users => users.every(u => this.authUser.canManage(u))
49 }, 55 },
50 { 56 {
51 label: this.i18n('Ban'), 57 label: this.i18n('Ban'),
52 handler: users => this.openBanUserModal(users), 58 handler: users => this.openBanUserModal(users),
53 isDisplayed: users => users.every(u => u.blocked === false) 59 isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === false)
54 }, 60 },
55 { 61 {
56 label: this.i18n('Unban'), 62 label: this.i18n('Unban'),
57 handler: users => this.unbanUsers(users), 63 handler: users => this.unbanUsers(users),
58 isDisplayed: users => users.every(u => u.blocked === true) 64 isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === true)
59 }, 65 },
60 { 66 {
61 label: this.i18n('Set Email as Verified'), 67 label: this.i18n('Set Email as Verified'),
62 handler: users => this.setEmailsAsVerified(users), 68 handler: users => this.setEmailsAsVerified(users),
63 isDisplayed: users => this.requiresEmailVerification && users.every(u => !u.blocked && u.emailVerified === false) 69 isDisplayed: users => {
70 return this.requiresEmailVerification &&
71 users.every(u => this.authUser.canManage(u) && !u.blocked && u.emailVerified === false)
72 }
64 } 73 }
65 ] 74 ]
66 } 75 }