aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account
diff options
context:
space:
mode:
authorKim <1877318+kimsible@users.noreply.github.com>2020-07-28 15:18:38 +0200
committerGitHub <noreply@github.com>2020-07-28 15:18:38 +0200
commitdfe3f7b72ef46401206f6f461077a7984a0c72f0 (patch)
tree775a747f2dd4bc098afc2ec254792e2e8e8cbbb4 /client/src/app/+my-account
parent0579dee3b29e301838387f53b91b58bff2ffb19a (diff)
downloadPeerTube-dfe3f7b72ef46401206f6f461077a7984a0c72f0.tar.gz
PeerTube-dfe3f7b72ef46401206f6f461077a7984a0c72f0.tar.zst
PeerTube-dfe3f7b72ef46401206f6f461077a7984a0c72f0.zip
Add alert and hide upload view when no upload is possible (#2966)
* Add alert and hide upload view when no upload is possible * Add about instance link to alert * Hide videos and imports links when no upload is possible * Correct curly spacing lint * Put logic canUpload to User model + add isHidden param to to-menu-dropdown * Use canSeeVideoLinks from user model * Rename and change logic canUpload to isUploadDisabled * Use isDisplayed() method intead of isHidden value * Refactor client and check videos count using quota Co-authored-by: kimsible <kimsible@users.noreply.github.com> Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'client/src/app/+my-account')
-rw-r--r--client/src/app/+my-account/my-account.component.ts33
1 files changed, 22 insertions, 11 deletions
diff --git a/client/src/app/+my-account/my-account.component.ts b/client/src/app/+my-account/my-account.component.ts
index 07cab37fc..5b2238f5a 100644
--- a/client/src/app/+my-account/my-account.component.ts
+++ b/client/src/app/+my-account/my-account.component.ts
@@ -1,5 +1,5 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ServerService } from '@app/core' 2import { AuthService, ServerService, AuthUser } from '@app/core'
3import { I18n } from '@ngx-translate/i18n-polyfill' 3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { ServerConfig } from '@shared/models' 4import { ServerConfig } from '@shared/models'
5import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component' 5import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
@@ -11,11 +11,13 @@ import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdo
11}) 11})
12export class MyAccountComponent implements OnInit { 12export class MyAccountComponent implements OnInit {
13 menuEntries: TopMenuDropdownParam[] = [] 13 menuEntries: TopMenuDropdownParam[] = []
14 user: AuthUser
14 15
15 private serverConfig: ServerConfig 16 private serverConfig: ServerConfig
16 17
17 constructor ( 18 constructor (
18 private serverService: ServerService, 19 private serverService: ServerService,
20 private authService: AuthService,
19 private i18n: I18n 21 private i18n: I18n
20 ) { } 22 ) { }
21 23
@@ -24,6 +26,20 @@ export class MyAccountComponent implements OnInit {
24 this.serverService.getConfig() 26 this.serverService.getConfig()
25 .subscribe(config => this.serverConfig = config) 27 .subscribe(config => this.serverConfig = config)
26 28
29 this.user = this.authService.getUser()
30
31 this.authService.userInformationLoaded.subscribe(
32 () => this.buildMenu()
33 )
34 }
35
36 isVideoImportEnabled () {
37 const importConfig = this.serverConfig.import.videos
38
39 return importConfig.http.enabled || importConfig.torrent.enabled
40 }
41
42 private buildMenu () {
27 const libraryEntries: TopMenuDropdownParam = { 43 const libraryEntries: TopMenuDropdownParam = {
28 label: this.i18n('My library'), 44 label: this.i18n('My library'),
29 children: [ 45 children: [
@@ -35,7 +51,8 @@ export class MyAccountComponent implements OnInit {
35 { 51 {
36 label: this.i18n('My videos'), 52 label: this.i18n('My videos'),
37 routerLink: '/my-account/videos', 53 routerLink: '/my-account/videos',
38 iconName: 'videos' 54 iconName: 'videos',
55 isDisplayed: () => this.user.canSeeVideosLink
39 }, 56 },
40 { 57 {
41 label: this.i18n('My playlists'), 58 label: this.i18n('My playlists'),
@@ -45,7 +62,7 @@ export class MyAccountComponent implements OnInit {
45 { 62 {
46 label: this.i18n('My subscriptions'), 63 label: this.i18n('My subscriptions'),
47 routerLink: '/my-account/subscriptions', 64 routerLink: '/my-account/subscriptions',
48 iconName: 'subscriptions' 65 iconName: 'inbox-full'
49 }, 66 },
50 { 67 {
51 label: this.i18n('My history'), 68 label: this.i18n('My history'),
@@ -59,7 +76,8 @@ export class MyAccountComponent implements OnInit {
59 libraryEntries.children.push({ 76 libraryEntries.children.push({
60 label: 'My imports', 77 label: 'My imports',
61 routerLink: '/my-account/video-imports', 78 routerLink: '/my-account/video-imports',
62 iconName: 'cloud-download' 79 iconName: 'cloud-download',
80 isDisplayed: () => this.user.canSeeVideosLink
63 }) 81 })
64 } 82 }
65 83
@@ -97,11 +115,4 @@ export class MyAccountComponent implements OnInit {
97 miscEntries 115 miscEntries
98 ] 116 ]
99 } 117 }
100
101 isVideoImportEnabled () {
102 const importConfig = this.serverConfig.import.videos
103
104 return importConfig.http.enabled || importConfig.torrent.enabled
105 }
106
107} 118}