]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/admin.component.ts
Refactor - improve offset content handling with fixed sub-menu and broadcast-message
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / admin.component.ts
index c1c160ad191dfb2765e24b92233f03c3dff000ea..66e068c4ccaeb718b6940a16a53559e53be7d8b3 100644 (file)
@@ -1,5 +1,5 @@
 import { Component, OnInit } from '@angular/core'
-import { AuthService } from '@app/core'
+import { AuthService, ScreenService } from '@app/core'
 import { ListOverflowItem } from '@app/shared/shared-main'
 import { I18n } from '@ngx-translate/i18n-polyfill'
 import { UserRight } from '@shared/models'
@@ -15,26 +15,31 @@ export class AdminComponent implements OnInit {
 
   constructor (
     private auth: AuthService,
+    private screen: ScreenService,
     private i18n: I18n
-  ) {}
+  ) { }
+
+  get isBroadcastMessageDisplayed () {
+    return this.screen.isBroadcastMessageDisplayed
+  }
 
   ngOnInit () {
-    const federationItems: TopMenuDropdownParam = {
-      label: this.i18n('Federation'),
+    const federationItems: TopMenuDropdownParam = {
+      label: this.i18n('Federation'),
       children: [
         {
           label: this.i18n('Instances you follow'),
-          routerLink: '/admin/follows/following-list',
-          iconName: 'sign-out'
+          routerLink: '/admin/follows/following-list',
+          iconName: 'following'
         },
         {
           label: this.i18n('Instances following you'),
-          routerLink: '/admin/follows/followers-list',
-          iconName: 'sign-in'
+          routerLink: '/admin/follows/followers-list',
+          iconName: 'follower'
         },
         {
           label: this.i18n('Video redundancies'),
-          routerLink: '/admin/follows/video-redundancies-list',
+          routerLink: '/admin/follows/video-redundancies-list',
           iconName: 'videos'
         }
       ]
@@ -44,33 +49,54 @@ export class AdminComponent implements OnInit {
       label: this.i18n('Moderation'),
       children: []
     }
-    if (this.hasVideoAbusesRight()) moderationItems.children.push({
-      label: this.i18n('Video reports'),
-      routerLink: '/admin/moderation/video-abuses/list',
-      iconName: 'flag'
-    })
-    if (this.hasVideoBlocklistRight()) moderationItems.children.push({
-      label: this.i18n('Video blocks'),
-      routerLink: '/admin/moderation/video-blocks/list',
-      iconName: 'cross'
-    })
-    if (this.hasAccountsBlocklistRight()) moderationItems.children.push({
-      label: this.i18n('Muted accounts'),
-      routerLink: '/admin/moderation/blocklist/accounts',
-      iconName: 'user'
-    })
-    if (this.hasServersBlocklistRight()) moderationItems.children.push({
-      label: this.i18n('Muted servers'),
-      routerLink: '/admin/moderation/blocklist/servers',
-      iconName: 'server'
-    })
-
-    if (this.hasUsersRight()) this.menuEntries.push({ label: this.i18n('Users'), routerLink: '/admin/users' })
+
+    if (this.hasAbusesRight()) {
+      moderationItems.children.push({
+        label: this.i18n('Reports'),
+        routerLink: '/admin/moderation/abuses/list',
+        iconName: 'flag'
+      })
+    }
+    if (this.hasVideoBlocklistRight()) {
+      moderationItems.children.push({
+        label: this.i18n('Video blocks'),
+        routerLink: '/admin/moderation/video-blocks/list',
+        iconName: 'cross'
+      })
+    }
+    if (this.hasAccountsBlocklistRight()) {
+      moderationItems.children.push({
+        label: this.i18n('Muted accounts'),
+        routerLink: '/admin/moderation/blocklist/accounts',
+        iconName: 'user-x'
+      })
+    }
+    if (this.hasServersBlocklistRight()) {
+      moderationItems.children.push({
+        label: this.i18n('Muted servers'),
+        routerLink: '/admin/moderation/blocklist/servers',
+        iconName: 'peertube-x'
+      })
+    }
+
+    if (this.hasUsersRight()) {
+      this.menuEntries.push({ label: this.i18n('Users'), routerLink: '/admin/users' })
+    }
+
     if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
-    if (this.hasVideoAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
-    if (this.hasConfigRight()) this.menuEntries.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' })
-    if (this.hasPluginsRight()) this.menuEntries.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' })
-    if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) this.menuEntries.push({ label: this.i18n('System'), routerLink: '/admin/system' })
+    if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
+
+    if (this.hasConfigRight()) {
+      this.menuEntries.push({ label: this.i18n('Configuration'), routerLink: '/admin/config' })
+    }
+
+    if (this.hasPluginsRight()) {
+      this.menuEntries.push({ label: this.i18n('Plugins/Themes'), routerLink: '/admin/plugins' })
+    }
+
+    if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
+      this.menuEntries.push({ label: this.i18n('System'), routerLink: '/admin/system' })
+    }
   }
 
   hasUsersRight () {
@@ -81,8 +107,8 @@ export class AdminComponent implements OnInit {
     return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
   }
 
-  hasVideoAbusesRight () {
-    return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_ABUSES)
+  hasAbusesRight () {
+    return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
   }
 
   hasVideoBlocklistRight () {