]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Admin menu header consistency for system entries
authorChocobozzz <me@florianbigard.com>
Wed, 20 Oct 2021 08:27:51 +0000 (10:27 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 20 Oct 2021 08:27:51 +0000 (10:27 +0200)
client/src/app/+admin/admin.component.ts
client/src/app/+admin/system/system.component.html
client/src/app/+admin/system/system.component.scss [deleted file]
client/src/app/+admin/system/system.component.ts

index 4b6fab6ed382e2b47350c61346febb5fcf00d77b..15739f8d34dc59ec2d78a72aaf9fc790a7c6a64c 100644 (file)
@@ -22,7 +22,24 @@ export class AdminComponent implements OnInit {
   }
 
   ngOnInit () {
-    const federationItems: TopMenuDropdownParam = {
+    this.buildOverviewItems()
+    this.buildFederationItems()
+    this.buildModerationItems()
+    this.buildConfigurationItems()
+    this.buildPluginItems()
+    this.buildSystemItems()
+  }
+
+  private buildOverviewItems () {
+    if (this.hasUsersRight()) {
+      this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' })
+    }
+  }
+
+  private buildFederationItems () {
+    if (!this.hasServerFollowRight()) return
+
+    this.menuEntries.push({
       label: $localize`Federation`,
       children: [
         {
@@ -41,8 +58,10 @@ export class AdminComponent implements OnInit {
           iconName: 'videos'
         }
       ]
-    }
+    })
+  }
 
+  private buildModerationItems () {
     const moderationItems: TopMenuDropdownParam = {
       label: $localize`Moderation`,
       children: []
@@ -55,6 +74,7 @@ export class AdminComponent implements OnInit {
         iconName: 'flag'
       })
     }
+
     if (this.hasVideoBlocklistRight()) {
       moderationItems.children.push({
         label: $localize`Video blocks`,
@@ -62,6 +82,7 @@ export class AdminComponent implements OnInit {
         iconName: 'cross'
       })
     }
+
     if (this.hasVideoCommentsRight()) {
       moderationItems.children.push({
         label: $localize`Video comments`,
@@ -69,6 +90,7 @@ export class AdminComponent implements OnInit {
         iconName: 'message-circle'
       })
     }
+
     if (this.hasAccountsBlocklistRight()) {
       moderationItems.children.push({
         label: $localize`Muted accounts`,
@@ -76,6 +98,7 @@ export class AdminComponent implements OnInit {
         iconName: 'user-x'
       })
     }
+
     if (this.hasServersBlocklistRight()) {
       moderationItems.children.push({
         label: $localize`Muted servers`,
@@ -84,71 +107,101 @@ export class AdminComponent implements OnInit {
       })
     }
 
-    if (this.hasUsersRight()) {
-      this.menuEntries.push({ label: $localize`Users`, routerLink: '/admin/users' })
-    }
-
-    if (this.hasServerFollowRight()) this.menuEntries.push(federationItems)
-    if (this.hasAbusesRight() || this.hasVideoBlocklistRight()) this.menuEntries.push(moderationItems)
+    if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
+  }
 
+  private buildConfigurationItems () {
     if (this.hasConfigRight()) {
       this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
     }
+  }
 
+  private buildPluginItems () {
     if (this.hasPluginsRight()) {
       this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
     }
+  }
+
+  private buildSystemItems () {
+    const systemItems: TopMenuDropdownParam = {
+      label: $localize`System`,
+      children: []
+    }
+
+    if (this.hasJobsRight()) {
+      systemItems.children.push({
+        label: $localize`Jobs`,
+        iconName: 'circle-tick',
+        routerLink: '/admin/system/jobs'
+      })
+    }
+
+    if (this.hasLogsRight()) {
+      systemItems.children.push({
+        label: $localize`Logs`,
+        iconName: 'playlists',
+        routerLink: '/admin/system/logs'
+      })
+    }
+
+    if (this.hasDebugRight()) {
+      systemItems.children.push({
+        label: $localize`Debug`,
+        iconName: 'cog',
+        routerLink: '/admin/system/debug'
+      })
+    }
 
-    if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
-      this.menuEntries.push({ label: $localize`System`, routerLink: '/admin/system' })
+    if (systemItems.children.length !== 0) {
+      this.menuEntries.push(systemItems)
     }
   }
 
-  hasUsersRight () {
+  private hasUsersRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
   }
 
-  hasServerFollowRight () {
+  private hasServerFollowRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
   }
 
-  hasAbusesRight () {
+  private hasAbusesRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
   }
 
-  hasVideoBlocklistRight () {
+  private hasVideoBlocklistRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
   }
 
-  hasAccountsBlocklistRight () {
+  private hasAccountsBlocklistRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
   }
 
-  hasServersBlocklistRight () {
+  private hasServersBlocklistRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
   }
 
-  hasConfigRight () {
+  private hasConfigRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
   }
 
-  hasPluginsRight () {
+  private hasPluginsRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
   }
 
-  hasLogsRight () {
+  private hasLogsRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
   }
 
-  hasJobsRight () {
+  private hasJobsRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
   }
 
-  hasDebugRight () {
+  private hasDebugRight () {
     return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
   }
 
-  hasVideoCommentsRight () {
+  private hasVideoCommentsRight () {
     return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
   }
 }
index 5385887b70a367ca31bcb2ed6728aa0d33eb2f43..0680b43f9c6ae05df91c576141f20ed411d07c7d 100644 (file)
@@ -1,11 +1 @@
-<div class="admin-sub-header">
-  <div class="admin-sub-nav">
-    <a *ngIf="hasJobsRight()" i18n routerLink="jobs" routerLinkActive="active">Jobs</a>
-
-    <a *ngIf="hasLogsRight()" i18n routerLink="logs" routerLinkActive="active">Logs</a>
-
-    <a *ngIf="hasDebugRight()" i18n routerLink="debug" routerLinkActive="active">Debug</a>
-  </div>
-</div>
-
 <router-outlet></router-outlet>
diff --git a/client/src/app/+admin/system/system.component.scss b/client/src/app/+admin/system/system.component.scss
deleted file mode 100644 (file)
index 18858ac..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-@use '_variables' as *;
-@use '_mixins' as *;
-
-.form-sub-title {
-  @include margin-right(30px);
-
-  flex-grow: 0;
-}
index b544c2a97905ab4b76daecc7fdc34c66ef96dbe3..b63160b861ba61f5a62f88cb033d65ac3635db7d 100644 (file)
@@ -1,24 +1,8 @@
 import { Component } from '@angular/core'
-import { UserRight } from '@shared/models'
-import { AuthService } from '@app/core'
 
 @Component({
   templateUrl: './system.component.html',
-  styleUrls: [ './system.component.scss' ]
+  styleUrls: []
 })
 export class SystemComponent {
-
-  constructor (private auth: AuthService) {}
-
-  hasLogsRight () {
-    return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
-  }
-
-  hasJobsRight () {
-    return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
-  }
-
-  hasDebugRight () {
-    return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
-  }
 }