X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fmenu%2Fmenu.service.ts;h=d865c7da2e7ce2e5f0e75c1370571e6d6ec915b8;hb=2c8380a46f34631e705b1564938343cacfa4b0bc;hp=77592cbb60cc9bf9aeaa64b6afb39841596373e4;hpb=1c5e49e75284100b7b1fc8b4e73c8ba53fe22e89;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index 77592cbb6..d865c7da2 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts @@ -2,23 +2,31 @@ import { fromEvent } from 'rxjs' import { debounceTime } from 'rxjs/operators' import { Injectable } from '@angular/core' import { GlobalIconName } from '@app/shared/shared-icons' -import { sortObjectComparator } from '@shared/core-utils/miscs/miscs' -import { ServerConfig } from '@shared/models/server' +import { HTMLServerConfig } from '@shared/models/server' import { ScreenService } from '../wrappers' export type MenuLink = { icon: GlobalIconName + iconClass?: string + label: string - menuLabel: string + // Used by the left menu for example + shortLabel: string + path: string - priority: number +} + +export type MenuSection = { + key: string + title: string + links: MenuLink[] } @Injectable() export class MenuService { isMenuDisplayed = true isMenuChangedByUser = false - menuWidth = 240 // should be kept equal to $menu-width + menuWidth = 240 // should be kept equal to $menu-width constructor ( private screenService: ScreenService @@ -48,7 +56,7 @@ export class MenuService { // On touch screens, lock body scroll and display content overlay when memu is opened if (this.isMenuDisplayed) { document.body.classList.add('menu-open') - this.screenService.onFingerSwipe('left', () => { this.setMenuDisplay(false) }) + this.screenService.onFingerSwipe('left', () => this.setMenuDisplay(false)) return } @@ -59,51 +67,98 @@ export class MenuService { this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser } - buildCommonLinks (config: ServerConfig) { - let entries: MenuLink[] = [ + buildLibraryLinks (userCanSeeVideosLink: boolean): MenuSection { + let links: MenuLink[] = [] + + if (userCanSeeVideosLink) { + links.push({ + path: '/my-library/video-channels', + icon: 'channel' as GlobalIconName, + iconClass: 'channel-icon', + shortLabel: $localize`Channels`, + label: $localize`My channels` + }) + + links.push({ + path: '/my-library/videos', + icon: 'videos' as GlobalIconName, + shortLabel: $localize`Videos`, + label: $localize`My videos` + }) + } + + links = links.concat([ + { + path: '/my-library/video-playlists', + icon: 'playlists' as GlobalIconName, + shortLabel: $localize`Playlists`, + label: $localize`My playlists` + }, + { + path: '/videos/subscriptions', + icon: 'subscriptions' as GlobalIconName, + shortLabel: $localize`Subscriptions`, + label: $localize`My subscriptions` + }, + { + path: '/my-library/history/videos', + icon: 'history' as GlobalIconName, + shortLabel: $localize`History`, + label: $localize`My history` + } + ]) + + return { + key: 'in-my-library', + title: $localize`In my library`, + links + } + } + + buildCommonLinks (config: HTMLServerConfig): MenuSection { + let links: MenuLink[] = [] + + if (config.homepage.enabled) { + links.push({ + icon: 'home' as 'home', + label: $localize`Home`, + shortLabel: $localize`Home`, + path: '/home' + }) + } + + links = links.concat([ { icon: 'globe' as 'globe', label: $localize`Discover videos`, - menuLabel: $localize`Discover`, - path: '/videos/overview', - priority: 150 + shortLabel: $localize`Discover`, + path: '/videos/overview' }, { icon: 'trending' as 'trending', label: $localize`Trending videos`, - menuLabel: $localize`Trending`, - path: '/videos/trending', - priority: 140 + shortLabel: $localize`Trending`, + path: '/videos/trending' }, { - icon: 'recently-added' as 'recently-added', + icon: 'add' as 'add', label: $localize`Recently added videos`, - menuLabel: $localize`Recently added`, - path: '/videos/recently-added', - priority: 130 + shortLabel: $localize`Recently added`, + path: '/videos/recently-added' }, { - icon: 'octagon' as 'octagon', + icon: 'local' as 'local', label: $localize`Local videos`, - menuLabel: $localize`Local videos`, - path: '/videos/local', - priority: 120 + shortLabel: $localize`Local videos`, + path: '/videos/local' } - ] + ]) - if (config.homepage.enabled) { - entries.push({ - icon: 'home' as 'home', - label: $localize`Home`, - menuLabel: $localize`Home`, - path: '/home', - priority: 160 - }) + return { + key: 'on-instance', + title: $localize`ON ${config.instance.name}`, + links } - - entries = entries.sort(sortObjectComparator('priority', 'desc')) - - return entries } private handleWindowResize () {