]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account.component.ts
Reorganize left menu and account menu
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account.component.ts
index fed6e6b0494a7f7572350f88925689fdcf6e85b6..d6e9d1c157211911184a7535fddfa8c6677dba88 100644 (file)
@@ -1,58 +1,62 @@
-import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ServerService } from '@app/core'
-import { NavigationStart, Router } from '@angular/router'
-import { filter } from 'rxjs/operators'
-import { I18n } from '@ngx-translate/i18n-polyfill'
-import { Subscription } from 'rxjs'
+import { Component, OnInit } from '@angular/core'
+import { AuthUser, ScreenService } from '@app/core'
+import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
 
 @Component({
   selector: 'my-my-account',
   templateUrl: './my-account.component.html',
   styleUrls: [ './my-account.component.scss' ]
 })
-export class MyAccountComponent implements OnInit, OnDestroy {
-
-  libraryLabel = ''
-
-  private routeSub: Subscription
+export class MyAccountComponent implements OnInit {
+  menuEntries: TopMenuDropdownParam[] = []
+  user: AuthUser
 
   constructor (
-    private serverService: ServerService,
-    private router: Router,
-    private i18n: I18n
-  ) {}
+    private screenService: ScreenService
+    ) { }
 
-  ngOnInit () {
-    this.updateLibraryLabel(this.router.url)
-
-    this.routeSub = this.router.events
-        .pipe(filter(event => event instanceof NavigationStart))
-        .subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url))
+  get isBroadcastMessageDisplayed () {
+    return this.screenService.isBroadcastMessageDisplayed
   }
 
-  ngOnDestroy () {
-    if (this.routeSub) this.routeSub.unsubscribe()
+  ngOnInit (): void {
+    this.buildMenu()
   }
 
-  isVideoImportEnabled () {
-    const importConfig = this.serverService.getConfig().import.videos
+  private buildMenu () {
+    const moderationEntries: TopMenuDropdownParam = {
+      label: $localize`Moderation`,
+      children: [
+        {
+          label: $localize`Muted accounts`,
+          routerLink: '/my-account/blocklist/accounts',
+          iconName: 'user-x'
+        },
+        {
+          label: $localize`Muted servers`,
+          routerLink: '/my-account/blocklist/servers',
+          iconName: 'peertube-x'
+        },
+        {
+          label: $localize`Abuse reports`,
+          routerLink: '/my-account/abuses',
+          iconName: 'flag'
+        }
+      ]
+    }
 
-    return importConfig.http.enabled || importConfig.torrent.enabled
-  }
+    this.menuEntries = [
+      {
+        label: $localize`Settings`,
+        routerLink: '/my-account/settings'
+      },
 
-  private updateLibraryLabel (url: string) {
-    const [ path ] = url.split('?')
-
-    if (path === '/my-account/video-channels') {
-      this.libraryLabel = this.i18n('Channels')
-    } else if (path === '/my-account/videos') {
-      this.libraryLabel = this.i18n('Videos')
-    } else if (path === '/my-account/subscriptions') {
-      this.libraryLabel = this.i18n('Subscriptions')
-    } else if (path === '/my-account/video-imports') {
-      this.libraryLabel = this.i18n('Video imports')
-    } else {
-      this.libraryLabel = ''
-    }
+      {
+        label: $localize`Notifications`,
+        routerLink: '/my-account/notifications'
+      },
+
+      moderationEntries
+    ]
   }
 }