Admin menu header consistency for system entries
This commit is contained in:
parent
c4c0c31144
commit
dbb76162b9
|
@ -22,7 +22,24 @@ export class AdminComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
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`,
|
label: $localize`Federation`,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -41,8 +58,10 @@ export class AdminComponent implements OnInit {
|
||||||
iconName: 'videos'
|
iconName: 'videos'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildModerationItems () {
|
||||||
const moderationItems: TopMenuDropdownParam = {
|
const moderationItems: TopMenuDropdownParam = {
|
||||||
label: $localize`Moderation`,
|
label: $localize`Moderation`,
|
||||||
children: []
|
children: []
|
||||||
|
@ -55,6 +74,7 @@ export class AdminComponent implements OnInit {
|
||||||
iconName: 'flag'
|
iconName: 'flag'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasVideoBlocklistRight()) {
|
if (this.hasVideoBlocklistRight()) {
|
||||||
moderationItems.children.push({
|
moderationItems.children.push({
|
||||||
label: $localize`Video blocks`,
|
label: $localize`Video blocks`,
|
||||||
|
@ -62,6 +82,7 @@ export class AdminComponent implements OnInit {
|
||||||
iconName: 'cross'
|
iconName: 'cross'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasVideoCommentsRight()) {
|
if (this.hasVideoCommentsRight()) {
|
||||||
moderationItems.children.push({
|
moderationItems.children.push({
|
||||||
label: $localize`Video comments`,
|
label: $localize`Video comments`,
|
||||||
|
@ -69,6 +90,7 @@ export class AdminComponent implements OnInit {
|
||||||
iconName: 'message-circle'
|
iconName: 'message-circle'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasAccountsBlocklistRight()) {
|
if (this.hasAccountsBlocklistRight()) {
|
||||||
moderationItems.children.push({
|
moderationItems.children.push({
|
||||||
label: $localize`Muted accounts`,
|
label: $localize`Muted accounts`,
|
||||||
|
@ -76,6 +98,7 @@ export class AdminComponent implements OnInit {
|
||||||
iconName: 'user-x'
|
iconName: 'user-x'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasServersBlocklistRight()) {
|
if (this.hasServersBlocklistRight()) {
|
||||||
moderationItems.children.push({
|
moderationItems.children.push({
|
||||||
label: $localize`Muted servers`,
|
label: $localize`Muted servers`,
|
||||||
|
@ -84,71 +107,101 @@ export class AdminComponent implements OnInit {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasUsersRight()) {
|
if (moderationItems.children.length !== 0) this.menuEntries.push(moderationItems)
|
||||||
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)
|
|
||||||
|
|
||||||
|
private buildConfigurationItems () {
|
||||||
if (this.hasConfigRight()) {
|
if (this.hasConfigRight()) {
|
||||||
this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
|
this.menuEntries.push({ label: $localize`Configuration`, routerLink: '/admin/config' })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildPluginItems () {
|
||||||
if (this.hasPluginsRight()) {
|
if (this.hasPluginsRight()) {
|
||||||
this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
|
this.menuEntries.push({ label: $localize`Plugins/Themes`, routerLink: '/admin/plugins' })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.hasJobsRight() || this.hasLogsRight() || this.hasDebugRight()) {
|
private buildSystemItems () {
|
||||||
this.menuEntries.push({ label: $localize`System`, routerLink: '/admin/system' })
|
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 (systemItems.children.length !== 0) {
|
||||||
|
this.menuEntries.push(systemItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasUsersRight () {
|
private hasUsersRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_USERS)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasServerFollowRight () {
|
private hasServerFollowRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAbusesRight () {
|
private hasAbusesRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_ABUSES)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasVideoBlocklistRight () {
|
private hasVideoBlocklistRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAccountsBlocklistRight () {
|
private hasAccountsBlocklistRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasServersBlocklistRight () {
|
private hasServersBlocklistRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasConfigRight () {
|
private hasConfigRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_CONFIGURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPluginsRight () {
|
private hasPluginsRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_PLUGINS)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasLogsRight () {
|
private hasLogsRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_LOGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasJobsRight () {
|
private hasJobsRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasDebugRight () {
|
private hasDebugRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
|
return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasVideoCommentsRight () {
|
private hasVideoCommentsRight () {
|
||||||
return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
|
return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
<router-outlet></router-outlet>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
@use '_variables' as *;
|
|
||||||
@use '_mixins' as *;
|
|
||||||
|
|
||||||
.form-sub-title {
|
|
||||||
@include margin-right(30px);
|
|
||||||
|
|
||||||
flex-grow: 0;
|
|
||||||
}
|
|
|
@ -1,24 +1,8 @@
|
||||||
import { Component } from '@angular/core'
|
import { Component } from '@angular/core'
|
||||||
import { UserRight } from '@shared/models'
|
|
||||||
import { AuthService } from '@app/core'
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './system.component.html',
|
templateUrl: './system.component.html',
|
||||||
styleUrls: [ './system.component.scss' ]
|
styleUrls: []
|
||||||
})
|
})
|
||||||
export class SystemComponent {
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue